diff --git a/papers/format.md b/papers/format.md index a61bb6266..1f44f9ac6 100644 --- a/papers/format.md +++ b/papers/format.md @@ -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 diff --git a/src/engine/engine.h b/src/engine/engine.h index be04d1cbb..f4324fb6c 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -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, diff --git a/src/engine/fileOps.cpp b/src/engine/fileOps.cpp index dd3ff37e2..b8c57c5b3 100644 --- a/src/engine/fileOps.cpp +++ b/src/engine/fileOps.cpp @@ -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; iwriteString(song.notes,false); + w->writeF(song.masterVol); + /// INSTRUMENT for (int i=0; iapu.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; } } diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index 6c825cb71..5fb0c4e86 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -1294,17 +1294,17 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi } for (int i=0; iisStereo()) { for (size_t j=0; jsong.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; isong.systemLen; i++) { snprintf(id,31,"MixS%d",i); bool doInvert=e->song.systemVol[i]&128;