Skip to content

Commit

Permalink
230918.1931 implemented MS mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ea7kir committed Sep 18, 2023
1 parent 575b5fc commit 31df0c8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

A Peak Programme Meter (PPM) displays audio levels on a logarithmic scale numbered 1 to 7. It responds fast to peaks and returns slowly. The attack and return ballists allow an experienced operator to produce a consistent volume levels accros varrying material.

MS mode (ie Mid/Side) can be selected with an external toggle switch.

It is not a True Peak Meter, VU Meter or a modern Loudness Meter. However, it has been in use for decades and is highly respected by many profession audio enginers. Invented by the BBC and evolved to the current specification emulated here. It is identical in everyway to the EBU and SABC meters, except for the scale markings. A VU meter is slow to respond to peaks and does not have a logrithmic scale. A True Peak Meter reponds to very short peaks, but does not measure volume. A Loudness Meter does what if says on the tin, but could be overkill for DATV.

NOTE: The above is a simplified summary to what is a very complicated subject.
Expand All @@ -19,7 +21,6 @@ SLAVE mode has not been investigated.

## TODO

- Implement MS mode using the -6dB standard. This will require an external switch connected to a GPIO line and I will need to convert my mono pre-amplifier to stereo.
- Test with Justin's USB-I2S and HDMI->I2S adapters.

## Hardware
Expand All @@ -32,6 +33,8 @@ Any "Standard/Philips" i2s input device, such as a TOSLINK, S/PDIF or Analogue t

Example: [AudioPhonics Stereo ADC Board WM8782](<https://www.audiophonics.fr/en/devices-hifi-audio-adc/stereo-adc-board-wm8782-i2s-24bit-192khz-p-14897.html>)

External toggle switch to enable MS mode.

## Pin Connections
The i2s specification omits to provide a standard for the bus names.

Expand Down Expand Up @@ -71,6 +74,8 @@ left

The T-Display-S3R8 must be powered via the Type-C USB socket. A normal USB data cable for firmware flashing, or a power only cable for normal use. Attepts to feed power in via any other means is not reccomended.

Connect a toogle switch between GPIO Pin 1 and GND to enable MS mode.

## Firmware Installation
There are two ways of flashing the firmare to the LilyGo T-Display-S3R8. The easiest would to download and install [Flash Tools for Windows](https://www.espressif.com/en/support/download/other-tools), select ESP32-S3, and use the PPM binary included in the release by moving it to the Flash Download Tools bin folder. I haven't been able to test this procedure, because I don't own a Windows and I haven't discovered how to build a bin file. The 'Build Filesystem Image' command doesn't succeed.

Expand Down Expand Up @@ -133,6 +138,8 @@ Response to isolated bursts of sine wave whose steady state amplitude deflects t
0.5ms of 10kHz -17.0 ±2.0dB
Return time: 24 dB in 2.8 ±0.3 seconds (from Mark 7 to Mark 1)
MS mode conforms to the -6dB standard.
```

## License
Expand Down
1 change: 1 addition & 0 deletions src/I2S_Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define EA7_CLK_to_mck_io GPIO_NUM_3 /* green */

// NOTE: ESP32 supports setting MCK only on GPIO_NUM_1, GPIO_NUM_2 or GPIO_NUM_3
// However, GPIO_NUM_1 is now being used to enable MS mode.

#define EA7_SampleRate 48000

Expand Down
4 changes: 0 additions & 4 deletions src/PPM_Meter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ void PPM_ProcessAndStore(int16_t rawL, int16_t rawR)
integratedL = integratedValueFromRaw(integratedL, rawL);
integratedR = integratedValueFromRaw(integratedR, rawR);

// TODO: lock
storedIntegratedValue.mu.lock();
storedIntegratedValue.left = integratedL;
storedIntegratedValue.right = integratedR;
// TODO: unlock
storedIntegratedValue.mu.unlock();
}

Expand Down Expand Up @@ -175,11 +173,9 @@ void Task_PPM_UpdateNeedles(void *pvParameters)
theSprite.print(markData[i].label);
}

// TODO: lock
storedIntegratedValue.mu.lock();
integratedL = storedIntegratedValue.left;
integratedR = storedIntegratedValue.right;
// TODO: unlock
storedIntegratedValue.mu.unlock();

// Frankly, the balistics looked nicer when I was integrating the angles (not the raw values).
Expand Down
15 changes: 13 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "PPM_Meter.hpp"
#include "I2S_Input.hpp"

#define MS_SWITCH 1

TaskHandle_t ReadI2S_handle = NULL;
TaskHandle_t UpdateScreen_handle = NULL;
QueueHandle_t xStructQueue = NULL;
Expand All @@ -39,8 +41,15 @@ void Task_ReadI2S(void *pvParameters)

// log_i("count %i, rawL %i, rawR %i", (int)rawSample.count, (int)rawSample.left[0], (int)rawSample.right[0]);

xMessage.left = rawSample.left;
xMessage.right = rawSample.right;
bool stateMSmode = !digitalRead(MS_SWITCH);

if (stateMSmode) {
xMessage.left = (rawSample.left - rawSample.right) / 2;
xMessage.right = (rawSample.left + rawSample.right) / 2;
} else {
xMessage.left = rawSample.left;
xMessage.right = rawSample.right;
}

xQueueSend(xStructQueue, (void *)&xMessage, (TickType_t)0);

Expand Down Expand Up @@ -76,6 +85,8 @@ void Task_UpdateBallistiics(void *pvParameters)

void setup()
{
pinMode(MS_SWITCH, INPUT_PULLUP);

// Serial.begin(115200);
// delay(1000);
// // esp_log_level_set("*", ESP_LOG_ERROR); // set all components to ERROR level
Expand Down

0 comments on commit 31df0c8

Please sign in to comment.