diff --git a/plugin_setup.php b/plugin_setup.php index fc4f9d3..e9a1d89 100755 --- a/plugin_setup.php +++ b/plugin_setup.php @@ -68,6 +68,10 @@ function OnConnectionChanged() {
*Can be set as high as 120dBμV, but voltage accuracy above 115dBμV is not guaranteed.

Preemphasis: "50us", "75μs (USA, default)"=>"75us"), "fpp-vastfmt", ""); ?>

Antenna Tuning Capacitor (0=Auto, 1-191): * 0.25pF

+

Enable Audio Limitter:

+

Enable Audio Compression:

+

Audio Compression Threshold (-64 - 0 db):

+

Audio Gain (0 - 16):

diff --git a/src/FPPVastFM.cpp b/src/FPPVastFM.cpp index c361cc4..77068ca 100755 --- a/src/FPPVastFM.cpp +++ b/src/FPPVastFM.cpp @@ -67,6 +67,11 @@ class FPPVastFMPlugin : public FPPPlugin { si4713 = new VASTFMT(); } if (si4713->isOk()) { + si4713->enableAudioCompression(settings["AudioCompression"] == "True"); + si4713->enableAudioLimitter(settings["AudioLimitter"] == "True"); + si4713->setAudioGain(std::stoi(settings["AudioGain"])); + si4713->setAudioCompressionThreshold(std::stoi(settings["AudioCompressionThreshold"])); + si4713->Init(); std::string rev = si4713->getRev(); @@ -268,6 +273,10 @@ class FPPVastFMPlugin : public FPPPlugin { #else setIfNotFound("ResetPin", "4"); #endif + setIfNotFound("AudioCompression", "True"); + setIfNotFound("AudioLimitter", "True"); + setIfNotFound("AudioGain", "5"); + setIfNotFound("AudioCompressionThreshold", "-15"); } void setIfNotFound(const std::string &s, const std::string &v, bool emptyAllowed = false) { if (settings.find(s) == settings.end()) { diff --git a/src/Si4713.cpp b/src/Si4713.cpp index 841ea46..df53c02 100755 --- a/src/Si4713.cpp +++ b/src/Si4713.cpp @@ -94,12 +94,16 @@ void Si4713::Init() { std::string rev = getRev(); //setProperty(SI4713_PROP_REFCLK_FREQ, 32768); // crystal is 32.768 setProperty(SI4713_PROP_TX_PREEMPHASIS, isEUPremphasis ? 1 : 0); // 75uS pre-emph (default for US) - setProperty(SI4713_PROP_TX_ACOMP_ENABLE, 0x03); // turn on limiter and AGC - setProperty(SI4713_PROP_TX_ACOMP_THRESHOLD, 0x10000-15); // -15 dBFS + uint16_t t = audioCompression ? 0x1 : 0; + if (audioLimitter) { + t |= 0x2; + } + setProperty(SI4713_PROP_TX_ACOMP_ENABLE, t); // turn on limiter and AGC + setProperty(SI4713_PROP_TX_ACOMP_THRESHOLD, 0x10000 + audioCompressionThreshold); setProperty(SI4713_PROP_TX_ATTACK_TIME, 0); // 0.5 ms setProperty(SI4713_PROP_TX_RELEASE_TIME, 4); // 1000 ms - setProperty(SI4713_PROP_TX_ACOMP_GAIN, 5); // dB + setProperty(SI4713_PROP_TX_ACOMP_GAIN, audioGain); // dB } @@ -307,7 +311,7 @@ void Si4713::sendTimestamp() { offset = abs(offset) & 0x1F; } - uint8_t sb = TX_RDS_BUFF_IN_LDBUFF | TX_RDS_BUFF_IN_FIFO; + uint8_t sb = TX_RDS_BUFF_IN_LDBUFF;// | TX_RDS_BUFF_IN_FIFO; std::vector out(6); uint8_t arg1 = (MJD >> 15); diff --git a/src/Si4713.h b/src/Si4713.h index ebe9422..1878650 100755 --- a/src/Si4713.h +++ b/src/Si4713.h @@ -34,6 +34,10 @@ class Si4713 { int titlePos, int titleLen); void sendTimestamp(); + void enableAudioCompression(bool b = true) { audioCompression = b; } + void enableAudioLimitter(bool b = true) { audioLimitter = b; } + void setAudioGain(int i) {audioGain = i;} + void setAudioCompressionThreshold(int i) { audioCompressionThreshold = i;} private: void sendRtPlusInfo(int content1, int content1_pos, int content1_len, int content2, int content2_pos, int content2_len); @@ -47,6 +51,11 @@ class Si4713 { int pty = 2; std::vector lastStation; std::string lastRDS; + + bool audioCompression = true; + bool audioLimitter = true; + int audioGain = 5; + int audioCompressionThreshold = -15; }; #endif