Skip to content

Commit

Permalink
Expose some more advanced settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dkulp committed Aug 16, 2020
1 parent f7a4300 commit 1612e8e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
4 changes: 4 additions & 0 deletions plugin_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ function OnConnectionChanged() {
<br /><sup>*</sup>Can be set as high as 120dB&mu;V, but voltage accuracy above 115dB&mu;V is not guaranteed.</p>
<p>Preemphasis: <?php PrintSettingSelect("Preemphasis", "Preemphasis", 2, 0, "75us", Array("50&mu;s (Europe, Australia, Japan)"=>"50us", "75&mu;s (USA, default)"=>"75us"), "fpp-vastfmt", ""); ?></p>
<p>Antenna Tuning Capacitor (0=Auto, 1-191): <?php PrintSettingTextSaved("AntCap", 2, 0, 3, 3, "fpp-vastfmt", "0"); ?> * 0.25pF </p>
<p>Enable Audio Limitter: <?php PrintSettingCheckbox("AudioLimitter", "AudioLimitter", 2, 0, "True", "False", "fpp-vastfmt", "", "True"); ?></p>
<p>Enable Audio Compression: <?php PrintSettingCheckbox("AudioCompression", "AudioCompression", 2, 0, "True", "False", "fpp-vastfmt", "", "True"); ?></p>
<p>Audio Compression Threshold (-64 - 0 db): <?php PrintSettingTextSaved("AudioCompressionThreshold", 2, 0, 3, 3, "fpp-vastfmt", "-15"); ?></p>
<p>Audio Gain (0 - 16): <?php PrintSettingTextSaved("AudioGain", 2, 0, 3, 3, "fpp-vastfmt", "5"); ?></p>
</fieldset>
</div>

Expand Down
9 changes: 9 additions & 0 deletions src/FPPVastFM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()) {
Expand Down
12 changes: 8 additions & 4 deletions src/Si4713.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down Expand Up @@ -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<uint8_t> out(6);

uint8_t arg1 = (MJD >> 15);
Expand Down
9 changes: 9 additions & 0 deletions src/Si4713.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -47,6 +51,11 @@ class Si4713 {
int pty = 2;
std::vector<std::string> lastStation;
std::string lastRDS;

bool audioCompression = true;
bool audioLimitter = true;
int audioGain = 5;
int audioCompressionThreshold = -15;
};

#endif

0 comments on commit 1612e8e

Please sign in to comment.