diff --git a/src/engine/platform/msm5232.cpp b/src/engine/platform/msm5232.cpp index d19719db..74a063ba 100644 --- a/src/engine/platform/msm5232.cpp +++ b/src/engine/platform/msm5232.cpp @@ -52,7 +52,6 @@ void DivPlatformMSM5232::acquire(short* bufL, short* bufR, size_t start, size_t regPool[w.addr&0x0f]=w.val; writes.pop(); } - memset(temp,0,16*sizeof(short)); for (int i=0; i<8; i++) { int o=( @@ -64,7 +63,15 @@ void DivPlatformMSM5232::acquire(short* bufL, short* bufR, size_t start, size_t oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(o,-32768,32767); } - msm->sound_stream_update(temp); + clockDriftLFOPos+=clockDriftLFOSpeed; + clockDriftLFOPos&=(1U<<21)-1; + clockDriftAccum+=clockDriftLFOWave[clockDriftLFOPos>>13]; + if (clockDriftAccum>=2048) { + clockDriftAccum-=2048; + } else { + memset(temp,0,16*sizeof(short)); + msm->sound_stream_update(temp); + } //printf("tempL: %d tempR: %d\n",tempL,tempR); bufL[h]=0; @@ -328,6 +335,8 @@ void DivPlatformMSM5232::reset() { cycles=0; curChan=-1; delay=500; + clockDriftLFOPos=0; + clockDriftAccum=0; for (int i=0; i<2; i++) { groupControl[i]=15|(groupEnv[i]?0x20:0); @@ -399,6 +408,11 @@ void DivPlatformMSM5232::setFlags(const DivConfig& flags) { capacitance[6]*0.000000001, capacitance[7]*0.000000001 ); + + for (int i=0; i<256; i++) { + clockDriftLFOWave[i]=(1.0+sin(M_PI*(double)i/128.0))*flags.getInt("vibDepth",0.0f); + } + clockDriftLFOSpeed=flags.getInt("vibSpeed",0); } void DivPlatformMSM5232::poke(unsigned int addr, unsigned short val) { diff --git a/src/engine/platform/msm5232.h b/src/engine/platform/msm5232.h index 34412b9a..3e2bf71a 100644 --- a/src/engine/platform/msm5232.h +++ b/src/engine/platform/msm5232.h @@ -57,6 +57,7 @@ class DivPlatformMSM5232: public DivDispatch { DivDispatchOscBuffer* oscBuf[8]; int partVolume[8]; int initPartVolume[8]; + int clockDriftLFOWave[256]; double capacitance[8]; bool isMuted[8]; bool updateGroup[2]; @@ -73,7 +74,8 @@ class DivPlatformMSM5232: public DivDispatch { }; std::queue writes; - int cycles, curChan, delay, detune; + int cycles, curChan, delay, detune, clockDriftAccum; + unsigned int clockDriftLFOPos, clockDriftLFOSpeed; short temp[16]; msm5232_device* msm; unsigned char regPool[128]; diff --git a/src/gui/sysConf.cpp b/src/gui/sysConf.cpp index a1dc3181..9e2d165f 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -1298,6 +1298,8 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo } case DIV_SYSTEM_MSM5232: { int detune=flags.getInt("detune",0); + int vibSpeed=flags.getInt("vibSpeed",0); + float vibDepth=flags.getFloat("vibDepth",0.0f); bool groupEnv[2]; int groupVol[8]; float capValue[8]; @@ -1377,8 +1379,23 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo altered=true; } + ImGui::Text("Global vibrato:"); + + if (CWSliderInt("Speed",&vibSpeed,0,256)) { + if (vibSpeed<0) vibSpeed=0; + if (vibSpeed>256) vibSpeed=256; + altered=true; + } rightClickable + if (CWSliderFloat("Depth",&vibDepth,0.0f,256.0f)) { + if (vibDepth<0) vibDepth=0; + if (vibDepth>256) vibDepth=256; + altered=true; + } rightClickable + if (altered) { flags.set("detune",detune); + flags.set("vibSpeed",vibSpeed); + flags.set("vibDepth",vibDepth); flags.set("capValue0",capValue[0]); flags.set("capValue1",capValue[1]);