new chan osc, part 7

i am done
This commit is contained in:
tildearrow 2025-03-02 16:14:49 -05:00
parent 6265d2cd39
commit 49a8693dcb
35 changed files with 606 additions and 217 deletions

View file

@ -188,6 +188,10 @@ void DivPlatformOPL::acquire_nuked(short** buf, size_t len) {
thread_local ymfm::ymfm_output<2> aOut;
thread_local short pcmBuf[24];
for (int i=0; i<totalChans; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
os[0]=0; os[1]=0; os[2]=0; os[3]=0; os[4]=0; os[5]=0;
if (!writes.empty() && --delay<0) {
@ -254,9 +258,9 @@ void DivPlatformOPL::acquire_nuked(short** buf, size_t len) {
if (!isMuted[adpcmChan]) {
os[0]-=aOut.data[0]>>3;
os[1]-=aOut.data[0]>>3;
oscBuf[adpcmChan]->data[oscBuf[adpcmChan]->needle++]=aOut.data[0]>>1;
oscBuf[adpcmChan]->putSample(h,aOut.data[0]>>1);
} else {
oscBuf[adpcmChan]->data[oscBuf[adpcmChan]->needle++]=0;
oscBuf[adpcmChan]->putSample(h,0);
}
}
@ -277,13 +281,13 @@ void DivPlatformOPL::acquire_nuked(short** buf, size_t len) {
if (fm.channel[i].out[3]!=NULL) {
chOut+=*fm.channel[ch].out[3];
}
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(chOut<<(i==melodicChans?1:2),-32768,32767);
oscBuf[i]->putSample(h,CLAMP(chOut<<(i==melodicChans?1:2),-32768,32767));
}
// special
oscBuf[melodicChans+1]->data[oscBuf[melodicChans+1]->needle++]=fm.slot[16].out*4;
oscBuf[melodicChans+2]->data[oscBuf[melodicChans+2]->needle++]=fm.slot[14].out*4;
oscBuf[melodicChans+3]->data[oscBuf[melodicChans+3]->needle++]=fm.slot[17].out*4;
oscBuf[melodicChans+4]->data[oscBuf[melodicChans+4]->needle++]=fm.slot[13].out*4;
oscBuf[melodicChans+1]->putSample(h,fm.slot[16].out*4);
oscBuf[melodicChans+2]->putSample(h,fm.slot[14].out*4);
oscBuf[melodicChans+3]->putSample(h,fm.slot[17].out*4);
oscBuf[melodicChans+4]->putSample(h,fm.slot[13].out*4);
} else {
for (int i=0; i<chans; i++) {
unsigned char ch=outChanMap[i];
@ -301,13 +305,13 @@ void DivPlatformOPL::acquire_nuked(short** buf, size_t len) {
if (fm.channel[i].out[3]!=NULL) {
chOut+=*fm.channel[ch].out[3];
}
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(chOut<<2,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(chOut<<2,-32768,32767));
}
}
if (chipType==4) {
for (int i=pcmChanOffs; i<pcmChanOffs+24; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(pcmBuf[i-pcmChanOffs],-32768,32767);
oscBuf[i]->putSample(h,CLAMP(pcmBuf[i-pcmChanOffs],-32768,32767));
}
}
@ -344,6 +348,10 @@ void DivPlatformOPL::acquire_nuked(short** buf, size_t len) {
buf[5][h]=os[5];
}
}
for (int i=0; i<totalChans; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformOPL::acquire_ymfm1(short** buf, size_t len) {
@ -356,6 +364,10 @@ void DivPlatformOPL::acquire_ymfm1(short** buf, size_t len) {
fmChan[i]=fme->debug_channel(i);
}
for (int i=0; i<totalChans; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
if (!writes.empty() && --delay<0) {
QueuedWrite& w=writes.front();
@ -377,18 +389,22 @@ void DivPlatformOPL::acquire_ymfm1(short** buf, size_t len) {
if (properDrums) {
for (int i=0; i<7; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fmChan[i]->debug_output(0)<<2,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(fmChan[i]->debug_output(0)<<2,-32768,32767));
}
oscBuf[7]->data[oscBuf[7]->needle++]=CLAMP(fmChan[7]->debug_special1()<<2,-32768,32767);
oscBuf[8]->data[oscBuf[8]->needle++]=CLAMP(fmChan[8]->debug_special1()<<2,-32768,32767);
oscBuf[9]->data[oscBuf[9]->needle++]=CLAMP(fmChan[8]->debug_special2()<<2,-32768,32767);
oscBuf[10]->data[oscBuf[10]->needle++]=CLAMP(fmChan[7]->debug_special2()<<2,-32768,32767);
oscBuf[7]->putSample(h,CLAMP(fmChan[7]->debug_special1()<<2,-32768,32767));
oscBuf[8]->putSample(h,CLAMP(fmChan[8]->debug_special1()<<2,-32768,32767));
oscBuf[9]->putSample(h,CLAMP(fmChan[8]->debug_special2()<<2,-32768,32767));
oscBuf[10]->putSample(h,CLAMP(fmChan[7]->debug_special2()<<2,-32768,32767));
} else {
for (int i=0; i<9; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fmChan[i]->debug_output(0)<<2,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(fmChan[i]->debug_output(0)<<2,-32768,32767));
}
}
}
for (int i=0; i<totalChans; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformOPL::acquire_ymfm2(short** buf, size_t len) {
@ -401,6 +417,10 @@ void DivPlatformOPL::acquire_ymfm2(short** buf, size_t len) {
fmChan[i]=fme->debug_channel(i);
}
for (int i=0; i<totalChans; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
if (!writes.empty() && --delay<0) {
QueuedWrite& w=writes.front();
@ -422,18 +442,22 @@ void DivPlatformOPL::acquire_ymfm2(short** buf, size_t len) {
if (properDrums) {
for (int i=0; i<7; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fmChan[i]->debug_output(0)<<2,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(fmChan[i]->debug_output(0)<<2,-32768,32767));
}
oscBuf[7]->data[oscBuf[7]->needle++]=CLAMP(fmChan[7]->debug_special1()<<2,-32768,32767);
oscBuf[8]->data[oscBuf[8]->needle++]=CLAMP(fmChan[8]->debug_special1()<<2,-32768,32767);
oscBuf[9]->data[oscBuf[9]->needle++]=CLAMP(fmChan[8]->debug_special2()<<2,-32768,32767);
oscBuf[10]->data[oscBuf[10]->needle++]=CLAMP(fmChan[7]->debug_special2()<<2,-32768,32767);
oscBuf[7]->putSample(h,CLAMP(fmChan[7]->debug_special1()<<2,-32768,32767));
oscBuf[8]->putSample(h,CLAMP(fmChan[8]->debug_special1()<<2,-32768,32767));
oscBuf[9]->putSample(h,CLAMP(fmChan[8]->debug_special2()<<2,-32768,32767));
oscBuf[10]->putSample(h,CLAMP(fmChan[7]->debug_special2()<<2,-32768,32767));
} else {
for (int i=0; i<9; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fmChan[i]->debug_output(0)<<2,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(fmChan[i]->debug_output(0)<<2,-32768,32767));
}
}
}
for (int i=0; i<totalChans; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformOPL::acquire_ymfm8950(short** buf, size_t len) {
@ -447,6 +471,10 @@ void DivPlatformOPL::acquire_ymfm8950(short** buf, size_t len) {
fmChan[i]=fme->debug_channel(i);
}
for (int i=0; i<totalChans; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
if (!writes.empty() && --delay<0) {
QueuedWrite& w=writes.front();
@ -468,20 +496,24 @@ void DivPlatformOPL::acquire_ymfm8950(short** buf, size_t len) {
if (properDrums) {
for (int i=0; i<7; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fmChan[i]->debug_output(0)<<2,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(fmChan[i]->debug_output(0)<<2,-32768,32767));
}
oscBuf[7]->data[oscBuf[7]->needle++]=CLAMP(fmChan[7]->debug_special1()<<2,-32768,32767);
oscBuf[8]->data[oscBuf[8]->needle++]=CLAMP(fmChan[8]->debug_special1()<<2,-32768,32767);
oscBuf[9]->data[oscBuf[9]->needle++]=CLAMP(fmChan[8]->debug_special2()<<2,-32768,32767);
oscBuf[10]->data[oscBuf[10]->needle++]=CLAMP(fmChan[7]->debug_special2()<<2,-32768,32767);
oscBuf[11]->data[oscBuf[11]->needle++]=CLAMP(abe->get_last_out(0),-32768,32767);
oscBuf[7]->putSample(h,CLAMP(fmChan[7]->debug_special1()<<2,-32768,32767));
oscBuf[8]->putSample(h,CLAMP(fmChan[8]->debug_special1()<<2,-32768,32767));
oscBuf[9]->putSample(h,CLAMP(fmChan[8]->debug_special2()<<2,-32768,32767));
oscBuf[10]->putSample(h,CLAMP(fmChan[7]->debug_special2()<<2,-32768,32767));
oscBuf[11]->putSample(h,CLAMP(abe->get_last_out(0),-32768,32767));
} else {
for (int i=0; i<9; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fmChan[i]->debug_output(0)<<2,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(fmChan[i]->debug_output(0)<<2,-32768,32767));
}
oscBuf[9]->data[oscBuf[9]->needle++]=CLAMP(abe->get_last_out(0),-32768,32767);
oscBuf[9]->putSample(h,CLAMP(abe->get_last_out(0),-32768,32767));
}
}
for (int i=0; i<totalChans; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformOPL::acquire_ymfm3(short** buf, size_t len) {
@ -494,6 +526,10 @@ void DivPlatformOPL::acquire_ymfm3(short** buf, size_t len) {
fmChan[i]=fme->debug_channel(i);
}
for (int i=0; i<totalChans; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
if (!writes.empty() && --delay<0) {
QueuedWrite& w=writes.front();
@ -552,15 +588,15 @@ void DivPlatformOPL::acquire_ymfm3(short** buf, size_t len) {
chOut=fmChan[ch]->debug_output(3);
}
if (i==15) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(chOut,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(chOut,-32768,32767));
} else {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(chOut<<1,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(chOut<<1,-32768,32767));
}
}
oscBuf[16]->data[oscBuf[16]->needle++]=CLAMP(fmChan[7]->debug_special2()<<1,-32768,32767);
oscBuf[17]->data[oscBuf[17]->needle++]=CLAMP(fmChan[8]->debug_special1()<<1,-32768,32767);
oscBuf[18]->data[oscBuf[18]->needle++]=CLAMP(fmChan[8]->debug_special2()<<1,-32768,32767);
oscBuf[19]->data[oscBuf[19]->needle++]=CLAMP(fmChan[7]->debug_special1()<<1,-32768,32767);
oscBuf[16]->putSample(h,CLAMP(fmChan[7]->debug_special2()<<1,-32768,32767));
oscBuf[17]->putSample(h,CLAMP(fmChan[8]->debug_special1()<<1,-32768,32767));
oscBuf[18]->putSample(h,CLAMP(fmChan[8]->debug_special2()<<1,-32768,32767));
oscBuf[19]->putSample(h,CLAMP(fmChan[7]->debug_special1()<<1,-32768,32767));
} else {
for (int i=0; i<18; i++) {
unsigned char ch=outChanMap[i];
@ -575,10 +611,14 @@ void DivPlatformOPL::acquire_ymfm3(short** buf, size_t len) {
if (chOut==0) {
chOut=fmChan[ch]->debug_output(3);
}
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(chOut<<1,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(chOut<<1,-32768,32767));
}
}
}
for (int i=0; i<totalChans; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformOPL::acquire_ymfm4(short** buf, size_t len) {
@ -597,6 +637,10 @@ void DivPlatformOPL::acquire_ymfm4(short** buf, size_t len) {
pcmChan[i]=pcme->debug_channel(i);
}
for (int i=0; i<totalChans; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
if (!writes.empty() && --delay<0) {
QueuedWrite& w=writes.front();
@ -644,15 +688,15 @@ void DivPlatformOPL::acquire_ymfm4(short** buf, size_t len) {
chOut=fmChan[ch]->debug_output(3);
}
if (i==15) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(chOut,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(chOut,-32768,32767));
} else {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(chOut<<1,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(chOut<<1,-32768,32767));
}
}
oscBuf[16]->data[oscBuf[16]->needle++]=CLAMP(fmChan[7]->debug_special2()<<1,-32768,32767);
oscBuf[17]->data[oscBuf[17]->needle++]=CLAMP(fmChan[8]->debug_special1()<<1,-32768,32767);
oscBuf[18]->data[oscBuf[18]->needle++]=CLAMP(fmChan[8]->debug_special2()<<1,-32768,32767);
oscBuf[19]->data[oscBuf[19]->needle++]=CLAMP(fmChan[7]->debug_special1()<<1,-32768,32767);
oscBuf[16]->putSample(h,CLAMP(fmChan[7]->debug_special2()<<1,-32768,32767));
oscBuf[17]->putSample(h,CLAMP(fmChan[8]->debug_special1()<<1,-32768,32767));
oscBuf[18]->putSample(h,CLAMP(fmChan[8]->debug_special2()<<1,-32768,32767));
oscBuf[19]->putSample(h,CLAMP(fmChan[7]->debug_special1()<<1,-32768,32767));
} else {
for (int i=0; i<18; i++) {
unsigned char ch=outChanMap[i];
@ -667,7 +711,7 @@ void DivPlatformOPL::acquire_ymfm4(short** buf, size_t len) {
if (chOut==0) {
chOut=fmChan[ch]->debug_output(3);
}
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(chOut<<1,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(chOut<<1,-32768,32767));
}
}
for (int i=0; i<24; i++) {
@ -676,9 +720,13 @@ void DivPlatformOPL::acquire_ymfm4(short** buf, size_t len) {
chOut+=pcmChan[i]->debug_output(1);
chOut+=pcmChan[i]->debug_output(2);
chOut+=pcmChan[i]->debug_output(3);
oscBuf[oscOffs]->data[oscBuf[oscOffs]->needle++]=CLAMP(chOut<<1,-32768,32767);
oscBuf[oscOffs]->putSample(h,CLAMP(chOut<<1,-32768,32767));
}
}
for (int i=0; i<totalChans; i++) {
oscBuf[i]->end(len);
}
}
static const int cycleMap[18]={
@ -707,6 +755,10 @@ void DivPlatformOPL::acquire_nukedLLE2(short** buf, size_t len) {
int chOut[11];
thread_local ymfm::ymfm_output<2> aOut;
for (int i=0; i<totalChans; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
int curCycle=0;
unsigned char subCycle=0;
@ -825,7 +877,7 @@ void DivPlatformOPL::acquire_nukedLLE2(short** buf, size_t len) {
}
if (chOut[i]<-32768) chOut[i]=-32768;
if (chOut[i]>32767) chOut[i]=32767;
oscBuf[i]->data[oscBuf[i]->needle++]=chOut[i];
oscBuf[i]->putSample(h,chOut[i]);
}
if (chipType==8950) {
@ -835,9 +887,9 @@ void DivPlatformOPL::acquire_nukedLLE2(short** buf, size_t len) {
if (!isMuted[adpcmChan]) {
dacOut-=aOut.data[0]>>3;
oscBuf[adpcmChan]->data[oscBuf[adpcmChan]->needle++]=aOut.data[0]>>1;
oscBuf[adpcmChan]->putSample(h,aOut.data[0]>>1);
} else {
oscBuf[adpcmChan]->data[oscBuf[adpcmChan]->needle++]=0;
oscBuf[adpcmChan]->putSample(h,0);
}
}
@ -846,12 +898,20 @@ void DivPlatformOPL::acquire_nukedLLE2(short** buf, size_t len) {
buf[0][h]=dacOut;
}
for (int i=0; i<totalChans; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformOPL::acquire_nukedLLE3(short** buf, size_t len) {
int chOut[20];
int ch=0;
for (int i=0; i<totalChans; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
int curCycle=0;
unsigned char subCycle=0;
@ -956,7 +1016,7 @@ void DivPlatformOPL::acquire_nukedLLE3(short** buf, size_t len) {
}*/
if (chOut[i]<-32768) chOut[i]=-32768;
if (chOut[i]>32767) chOut[i]=32767;
oscBuf[i]->data[oscBuf[i]->needle++]=chOut[i];
oscBuf[i]->putSample(h,chOut[i]);
}
for (int i=0; i<MIN(4,totalOutputs); i++) {
@ -966,6 +1026,10 @@ void DivPlatformOPL::acquire_nukedLLE3(short** buf, size_t len) {
buf[i][h]=dacOut3[i];
}
}
for (int i=0; i<totalChans; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformOPL::acquire(short** buf, size_t len) {
@ -3146,7 +3210,7 @@ void DivPlatformOPL::setFlags(const DivConfig& flags) {
compatYPitch=flags.getBool("compatYPitch",false);
for (int i=0; i<44; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
}