add sample preview volume setting

it was too loud
This commit is contained in:
tildearrow 2023-09-11 16:04:19 -05:00
parent 41bd28c41a
commit 41544bcced
5 changed files with 31 additions and 2 deletions

View file

@ -3246,6 +3246,10 @@ void DivEngine::setMetronomeVol(float vol) {
metroVol=vol;
}
void DivEngine::setSamplePreviewVol(float vol) {
previewVol=vol;
}
void DivEngine::setConsoleMode(bool enable) {
consoleMode=enable;
}
@ -3450,6 +3454,7 @@ bool DivEngine::initAudioBackend() {
clampSamples=getConfInt("clampSamples",0);
lowLatency=getConfInt("lowLatency",0);
metroVol=(float)(getConfInt("metroVol",100))/100.0f;
previewVol=(float)(getConfInt("sampleVol",50))/100.0f;
midiOutClock=getConfInt("midiOutClock",0);
midiOutTime=getConfInt("midiOutTime",0);
midiOutTimeRate=getConfInt("midiOutTimeRate",0);
@ -3457,6 +3462,8 @@ bool DivEngine::initAudioBackend() {
midiOutMode=getConfInt("midiOutMode",DIV_MIDI_MODE_NOTE);
if (metroVol<0.0f) metroVol=0.0f;
if (metroVol>2.0f) metroVol=2.0f;
if (previewVol<0.0f) previewVol=0.0f;
if (previewVol>1.0f) previewVol=1.0f;
renderPoolThreads=getConfInt("renderPoolThreads",0);
if (lowLatency) logI("using low latency mode.");

View file

@ -490,6 +490,7 @@ class DivEngine {
float metroFreq, metroPos;
float metroAmp;
float metroVol;
float previewVol;
size_t totalProcessed;
@ -729,6 +730,9 @@ class DivEngine {
int getSamplePreviewPos();
double getSamplePreviewRate();
// set sample preview volume (1.0 = 100%)
void setSamplePreviewVol(float vol);
// trigger sample preview
void previewSample(int sample, int note=-1, int pStart=-1, int pEnd=-1);
void stopSamplePreview();
@ -1282,6 +1286,7 @@ class DivEngine {
metroPos(0),
metroAmp(0.0f),
metroVol(1.0f),
previewVol(1.0f),
totalProcessed(0),
renderPoolThreads(0),
renderPool(NULL),

View file

@ -2202,7 +2202,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
} else if (srcPortSet==0xffd) {
// sample preview
for (size_t j=0; j<size; j++) {
out[destSubPort][j]+=samp_bbOut[j]/32768.0;
out[destSubPort][j]+=previewVol*(samp_bbOut[j]/32768.0);
}
} else if (srcPortSet==0xffe && playing && !halted) {
// metronome

View file

@ -1503,6 +1503,7 @@ class FurnaceGUI {
int separateFMColors;
int insEditColorize;
int metroVol;
int sampleVol;
int pushNibble;
int scrollChangesOrder;
int oplStandardWaveNames;
@ -1683,6 +1684,7 @@ class FurnaceGUI {
separateFMColors(0),
insEditColorize(0),
metroVol(100),
sampleVol(50),
pushNibble(0),
scrollChangesOrder(0),
oplStandardWaveNames(0),

View file

@ -967,7 +967,7 @@ void FurnaceGUI::drawSettings() {
// SUBSECTION METRONOME
CONFIG_SUBSECTION("Metronome");
ImGui::AlignTextToFramePadding();
ImGui::Text("Metronome volume");
ImGui::Text("Volume");
ImGui::SameLine();
if (ImGui::SliderInt("##MetroVol",&settings.metroVol,0,200,"%d%%")) {
if (settings.metroVol<0) settings.metroVol=0;
@ -975,6 +975,17 @@ void FurnaceGUI::drawSettings() {
e->setMetronomeVol(((float)settings.metroVol)/100.0f);
}
// SUBSECTION SAMPLE PREVIEW
CONFIG_SUBSECTION("Sample preview");
ImGui::AlignTextToFramePadding();
ImGui::Text("Volume");
ImGui::SameLine();
if (ImGui::SliderInt("##SampleVol",&settings.sampleVol,0,100,"%d%%")) {
if (settings.sampleVol<0) settings.sampleVol=0;
if (settings.sampleVol>100) settings.sampleVol=100;
e->setSamplePreviewVol(((float)settings.sampleVol)/100.0f);
}
END_SECTION;
}
CONFIG_SECTION("MIDI") {
@ -3246,6 +3257,7 @@ void FurnaceGUI::syncSettings() {
settings.separateFMColors=e->getConfInt("separateFMColors",0);
settings.insEditColorize=e->getConfInt("insEditColorize",0);
settings.metroVol=e->getConfInt("metroVol",100);
settings.sampleVol=e->getConfInt("sampleVol",50);
settings.pushNibble=e->getConfInt("pushNibble",0);
settings.scrollChangesOrder=e->getConfInt("scrollChangesOrder",0);
settings.oplStandardWaveNames=e->getConfInt("oplStandardWaveNames",0);
@ -3407,6 +3419,7 @@ void FurnaceGUI::syncSettings() {
clampSetting(settings.separateFMColors,0,1);
clampSetting(settings.insEditColorize,0,1);
clampSetting(settings.metroVol,0,200);
clampSetting(settings.sampleVol,0,100);
clampSetting(settings.pushNibble,0,1);
clampSetting(settings.scrollChangesOrder,0,2);
clampSetting(settings.oplStandardWaveNames,0,1);
@ -3535,6 +3548,7 @@ void FurnaceGUI::syncSettings() {
e->setMidiDirect(midiMap.directChannel);
e->setMetronomeVol(((float)settings.metroVol)/100.0f);
e->setSamplePreviewVol(((float)settings.sampleVol)/100.0f);
}
void FurnaceGUI::commitSettings() {
@ -3656,6 +3670,7 @@ void FurnaceGUI::commitSettings() {
e->setConf("separateFMColors",settings.separateFMColors);
e->setConf("insEditColorize",settings.insEditColorize);
e->setConf("metroVol",settings.metroVol);
e->setConf("sampleVol",settings.sampleVol);
e->setConf("pushNibble",settings.pushNibble);
e->setConf("scrollChangesOrder",settings.scrollChangesOrder);
e->setConf("oplStandardWaveNames",settings.oplStandardWaveNames);