diff --git a/README.md b/README.md index 8c6dce8..6057a06 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 @@ -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]() +External toggle switch to enable MS mode. + ## Pin Connections The i2s specification omits to provide a standard for the bus names. @@ -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. @@ -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 diff --git a/src/I2S_Input.cpp b/src/I2S_Input.cpp index 3d93e54..9e31cd8 100644 --- a/src/I2S_Input.cpp +++ b/src/I2S_Input.cpp @@ -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 diff --git a/src/PPM_Meter.cpp b/src/PPM_Meter.cpp index 0e9eb72..b543173 100644 --- a/src/PPM_Meter.cpp +++ b/src/PPM_Meter.cpp @@ -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(); } @@ -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). diff --git a/src/main.cpp b/src/main.cpp index 29bc166..67ce2dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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; @@ -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); @@ -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