GUI: add metronome volume setting

This commit is contained in:
tildearrow 2022-04-13 02:29:07 -05:00
parent 2cd454a59d
commit 2e2fafd878
5 changed files with 28 additions and 5 deletions

View file

@ -2025,6 +2025,10 @@ void DivEngine::setMetronome(bool enable) {
metroAmp=0;
}
void DivEngine::setMetronomeVol(float vol) {
metroVol=vol;
}
void DivEngine::setConsoleMode(bool enable) {
consoleMode=enable;
}
@ -2196,6 +2200,9 @@ bool DivEngine::initAudioBackend() {
lowQuality=getConfInt("audioQuality",0);
forceMono=getConfInt("forceMono",0);
metroVol=(float)(getConfInt("metroVol",100))/100.0f;
if (metroVol<0.0f) metroVol=0.0f;
if (metroVol>2.0f) metroVol=2.0f;
switch (audioEngine) {
case DIV_AUDIO_JACK:

View file

@ -252,6 +252,7 @@ class DivEngine {
size_t metroTickLen;
float metroFreq, metroPos;
float metroAmp;
float metroVol;
size_t totalProcessed;
@ -622,6 +623,9 @@ class DivEngine {
// set metronome
void setMetronome(bool enable);
// set metronome volume (1.0 = 100%)
void setMetronomeVol(float vol);
// halt now
void halt();
@ -772,6 +776,7 @@ class DivEngine {
metroFreq(0),
metroPos(0),
metroAmp(0.0f),
metroVol(1.0f),
totalProcessed(0),
oscBuf{NULL,NULL},
oscSize(1),

View file

@ -1925,8 +1925,8 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
metroAmp=0.7f;
}
if (metroAmp>0.0f) {
out[0][i]+=(sin(metroPos*2*M_PI))*metroAmp;
out[1][i]+=(sin(metroPos*2*M_PI))*metroAmp;
out[0][i]+=(sin(metroPos*2*M_PI))*metroAmp*metroVol;
out[1][i]+=(sin(metroPos*2*M_PI))*metroAmp*metroVol;
}
metroAmp-=0.0003f;
if (metroAmp<0.0f) metroAmp=0.0f;