MSM5232: oh come on why didn't I commit this?

This commit is contained in:
tildearrow 2022-10-04 03:34:38 -05:00
parent 8ab0d28ace
commit 263982719d
3 changed files with 36 additions and 3 deletions

View File

@ -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) {

View File

@ -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<QueuedWrite> 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];

View File

@ -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]);