volume changes

as of now the master volume is 1.0x (it was 2.0x before)
NES has also been amplified.
these changes should not affect older songs.
This commit is contained in:
tildearrow 2022-02-24 17:56:19 -05:00
parent 82c8b97d9c
commit 4b6d9adcb9
7 changed files with 36 additions and 10 deletions

View file

@ -25,6 +25,8 @@ furthermore, an `or reserved` indicates this field is always present, but is res
the format versions are:
- 59: Furnace dev59
- 58: Furnace dev58
- 57: Furnace dev57
- 53: Furnace 0.5.7
@ -201,6 +203,8 @@ size | description
S?? | channel short names
| - same as above
STR | song comment
4f | master volume, 1.0f=100% (>=59)
| this is 2.0f for modules before 59
# instrument

View file

@ -37,8 +37,8 @@
warnings+=(String("\n")+x); \
}
#define DIV_VERSION "dev58"
#define DIV_ENGINE_VERSION 58
#define DIV_VERSION "dev59"
#define DIV_ENGINE_VERSION 59
enum DivStatusView {
DIV_STATUS_NOTHING=0,

View file

@ -841,7 +841,12 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
if (tchans>DIV_MAX_CHANS) tchans=DIV_MAX_CHANS;
// system volume
for (int i=0; i<32; i++) ds.systemVol[i]=reader.readC();
for (int i=0; i<32; i++) {
ds.systemVol[i]=reader.readC();
if (ds.version<59 && ds.system[i]==DIV_SYSTEM_NES) {
ds.systemVol[i]/=4;
}
}
// system panning
for (int i=0; i<32; i++) ds.systemPan[i]=reader.readC();
@ -999,6 +1004,12 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
ds.notes=reader.readString();
}
if (ds.version>=59) {
ds.masterVol=reader.readF();
} else {
ds.masterVol=2.0f;
}
// read instruments
for (int i=0; i<ds.insLen; i++) {
DivInstrument* ins=new DivInstrument;
@ -1444,6 +1455,8 @@ SafeWriter* DivEngine::saveFur() {
w->writeString(song.notes,false);
w->writeF(song.masterVol);
/// INSTRUMENT
for (int i=0; i<song.insLen; i++) {
DivInstrument* ins=song.ins[i];

View file

@ -99,7 +99,10 @@ void DivPlatformNES::acquire(short* bufL, short* bufR, size_t start, size_t len)
if (nes->apu.clocked) {
nes->apu.clocked=false;
}
bufL[i]=(pulse_output(nes)+tnd_output(nes))*30;
int sample=(pulse_output(nes)+tnd_output(nes)-128)<<7;
if (sample>32767) sample=32767;
if (sample<-32768) sample=-32768;
bufL[i]=sample;
}
}

View file

@ -1294,17 +1294,17 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
}
for (int i=0; i<song.systemLen; i++) {
float volL=((float)song.systemVol[i]/64.0f)*((float)MIN(127,127-(int)song.systemPan[i])/127.0f);
float volR=((float)song.systemVol[i]/64.0f)*((float)MIN(127,127+(int)song.systemPan[i])/127.0f);
float volL=((float)song.systemVol[i]/64.0f)*((float)MIN(127,127-(int)song.systemPan[i])/127.0f)*song.masterVol;
float volR=((float)song.systemVol[i]/64.0f)*((float)MIN(127,127+(int)song.systemPan[i])/127.0f)*song.masterVol;
if (disCont[i].dispatch->isStereo()) {
for (size_t j=0; j<size; j++) {
out[0][j]+=((float)disCont[i].bbOut[0][j]/16384.0)*volL;
out[1][j]+=((float)disCont[i].bbOut[1][j]/16384.0)*volR;
out[0][j]+=((float)disCont[i].bbOut[0][j]/32768.0)*volL;
out[1][j]+=((float)disCont[i].bbOut[1][j]/32768.0)*volR;
}
} else {
for (size_t j=0; j<size; j++) {
out[0][j]+=((float)disCont[i].bbOut[0][j]/16384.0)*volL;
out[1][j]+=((float)disCont[i].bbOut[0][j]/16384.0)*volR;
out[0][j]+=((float)disCont[i].bbOut[0][j]/32768.0)*volL;
out[1][j]+=((float)disCont[i].bbOut[0][j]/32768.0)*volR;
}
}
}

View file

@ -241,6 +241,7 @@ struct DivSong {
bool pal;
bool customTempo;
int hz, patLen, ordersLen, insLen, waveLen, sampleLen;
float masterVol;
float tuning;
// compatibility flags
@ -308,6 +309,7 @@ struct DivSong {
insLen(0),
waveLen(0),
sampleLen(0),
masterVol(1.0f),
tuning(440.0f),
limitSlides(false),
linearPitch(true),

View file

@ -1345,6 +1345,10 @@ void FurnaceGUI::drawMixer() {
ImGui::SetNextWindowSizeConstraints(ImVec2(400.0f*dpiScale,200.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale));
if (ImGui::Begin("Mixer",&mixerOpen,settings.allowEditDocking?0:ImGuiWindowFlags_NoDocking)) {
char id[32];
if (ImGui::SliderFloat("Master Volume",&e->song.masterVol,0,3,"%.2fx")) {
if (e->song.masterVol<0) e->song.masterVol=0;
if (e->song.masterVol>3) e->song.masterVol=3;
}
for (int i=0; i<e->song.systemLen; i++) {
snprintf(id,31,"MixS%d",i);
bool doInvert=e->song.systemVol[i]&128;