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);
}
}

View file

@ -47,6 +47,10 @@ void DivPlatformOPLL::acquire_nuked(short** buf, size_t len) {
thread_local int o[2];
thread_local int os;
for (int i=0; i<11; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
os=0;
for (int i=0; i<9; i++) {
@ -71,17 +75,17 @@ void DivPlatformOPLL::acquire_nuked(short** buf, size_t len) {
unsigned char nextOut=cycleMapOPLL[fm.cycles];
if ((nextOut>=6 && properDrums) || !isMuted[nextOut]) {
os+=(o[0]+o[1]);
if (vrc7 || (fm.rm_enable&0x20)) oscBuf[nextOut]->data[oscBuf[nextOut]->needle++]=(o[0]+o[1])<<6;
if (vrc7 || (fm.rm_enable&0x20)) oscBuf[nextOut]->putSample(h,(o[0]+o[1])<<6);
} else {
if (vrc7 || (fm.rm_enable&0x20)) oscBuf[nextOut]->data[oscBuf[nextOut]->needle++]=0;
if (vrc7 || (fm.rm_enable&0x20)) oscBuf[nextOut]->putSample(h,0);
}
}
if (!(vrc7 || (fm.rm_enable&0x20))) for (int i=0; i<9; i++) {
unsigned char ch=visMapOPLL[i];
if ((i>=6 && properDrums) || !isMuted[ch]) {
oscBuf[ch]->data[oscBuf[ch]->needle++]=(fm.output_ch[i])<<6;
oscBuf[ch]->putSample(h,(fm.output_ch[i])<<6);
} else {
oscBuf[ch]->data[oscBuf[ch]->needle++]=0;
oscBuf[ch]->putSample(h,0);
}
}
os*=50;
@ -89,6 +93,10 @@ void DivPlatformOPLL::acquire_nuked(short** buf, size_t len) {
if (os>32767) os=32767;
buf[0][h]=os;
}
for (int i=0; i<11; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformOPLL::acquire_ymfm(short** buf, size_t len) {
@ -101,6 +109,10 @@ static const unsigned char freakingDrumMap[5]={
void DivPlatformOPLL::acquire_emu(short** buf, size_t len) {
thread_local int os;
for (int i=0; i<11; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
if (!writes.empty()) {
QueuedWrite& w=writes.front();
@ -116,12 +128,16 @@ void DivPlatformOPLL::acquire_emu(short** buf, size_t len) {
for (int i=0; i<11; i++) {
if (i>=6 && properDrums) {
oscBuf[i]->data[oscBuf[i]->needle++]=(-fm_emu->ch_out[freakingDrumMap[i-6]])<<3;
oscBuf[i]->putSample(h,(-fm_emu->ch_out[freakingDrumMap[i-6]])<<3);
} else {
oscBuf[i]->data[oscBuf[i]->needle++]=(-fm_emu->ch_out[i])<<3;
oscBuf[i]->putSample(h,(-fm_emu->ch_out[i])<<3);
}
}
}
for (int i=0; i<11; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformOPLL::acquire(short** buf, size_t len) {
@ -1175,15 +1191,7 @@ void DivPlatformOPLL::setFlags(const DivConfig& flags) {
rate=chipClock/36;
}
for (int i=0; i<11; i++) {
if (selCore==1) {
oscBuf[i]->rate=rate;
} else {
if (i>=6 && properDrumsSys) {
oscBuf[i]->rate=rate;
} else {
oscBuf[i]->rate=rate/2;
}
}
oscBuf[i]->setRate(rate);
}
noTopHatFreq=flags.getBool("noTopHatFreq",false);
fixedAll=flags.getBool("fixedAll",true);

View file

@ -55,6 +55,10 @@ const char** DivPlatformPCE::getRegisterSheet() {
}
void DivPlatformPCE::acquire(short** buf, size_t len) {
for (int i=0; i<6; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
// PCM part
for (int i=0; i<6; i++) {
@ -100,7 +104,7 @@ void DivPlatformPCE::acquire(short** buf, size_t len) {
pce->ResetTS(0);
for (int i=0; i<6; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(pce->channel[i].blip_prev_samp[0]+pce->channel[i].blip_prev_samp[1],-32768,32767);
oscBuf[i]->putSample(h,CLAMP(pce->channel[i].blip_prev_samp[0]+pce->channel[i].blip_prev_samp[1],-32768,32767));
}
tempL[0]=(tempL[0]>>1)+(tempL[0]>>2);
@ -115,6 +119,10 @@ void DivPlatformPCE::acquire(short** buf, size_t len) {
buf[0][h]=tempL[0];
buf[1][h]=tempR[0];
}
for (int i=0; i<6; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformPCE::updateWave(int ch) {
@ -656,7 +664,7 @@ void DivPlatformPCE::setFlags(const DivConfig& flags) {
antiClickEnabled=!flags.getBool("noAntiClick",false);
rate=chipClock/(coreQuality>>1);
for (int i=0; i<6; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
if (pce!=NULL) {

View file

@ -354,9 +354,7 @@ void DivPlatformPCSpeaker::acquire_real(blip_buffer_t** bb, size_t off, size_t l
}
}
out=(pos>(freq>>1) && !isMuted[0])?32767:0;
oscBuf->data[oscBuf->needle++]=out;
} else {
oscBuf->data[oscBuf->needle++]=0;
}
//buf[0][i]=0;
}

View file

@ -74,6 +74,10 @@ void DivPlatformPOKEY::acquire(short** buf, size_t len) {
}
void DivPlatformPOKEY::acquireMZ(short* buf, size_t len) {
for (int i=0; i<4; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
@ -86,29 +90,47 @@ void DivPlatformPOKEY::acquireMZ(short* buf, size_t len) {
if (++oscBufDelay>=14) {
oscBufDelay=0;
oscBuf[0]->data[oscBuf[0]->needle++]=pokey.outvol_0<<10;
oscBuf[1]->data[oscBuf[1]->needle++]=pokey.outvol_1<<10;
oscBuf[2]->data[oscBuf[2]->needle++]=pokey.outvol_2<<10;
oscBuf[3]->data[oscBuf[3]->needle++]=pokey.outvol_3<<10;
oscBuf[0]->putSample(h,pokey.outvol_0<<10);
oscBuf[1]->putSample(h,pokey.outvol_1<<10);
oscBuf[2]->putSample(h,pokey.outvol_2<<10);
oscBuf[3]->putSample(h,pokey.outvol_3<<10);
}
}
for (int i=0; i<4; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformPOKEY::acquireASAP(short* buf, size_t len) {
thread_local short oscB[4];
while (!writes.empty()) {
QueuedWrite w=writes.front();
altASAP.write(w.addr, w.val);
writes.pop();
}
for (int i=0; i<4; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
if (++oscBufDelay>=2) {
oscBufDelay=0;
buf[h]=altASAP.sampleAudio(oscBuf);
buf[h]=altASAP.sampleAudio(oscB);
for (int i=0; i<4; i++) {
oscBuf[i]->putSample(h,oscB[i]);
}
} else {
buf[h]=altASAP.sampleAudio();
}
}
for (int i=0; i<4; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformPOKEY::tick(bool sysTick) {
@ -488,14 +510,14 @@ void DivPlatformPOKEY::setFlags(const DivConfig& flags) {
if (useAltASAP) {
rate=chipClock/7;
for (int i=0; i<4; i++) {
oscBuf[i]->rate=rate/2;
oscBuf[i]->setRate(rate);
}
altASAP.init(chipClock,rate);
altASAP.reset();
} else {
rate=chipClock;
for (int i=0; i<4; i++) {
oscBuf[i]->rate=rate/14;
oscBuf[i]->setRate(rate);
}
}
}

View file

@ -68,17 +68,26 @@ void DivPlatformRF5C68::acquire(short** buf, size_t len) {
memset(bufC[i],0,256*sizeof(short));
}
while (len > 0) {
size_t blockLen=MIN(len,256);
for (int i=0; i<8; i++) {
oscBuf[i]->begin(len);
}
size_t lenCopy=len;
while (lenCopy > 0) {
size_t blockLen=MIN(lenCopy,256);
short* bufPtrs[2]={&buf[0][pos],&buf[1][pos]};
rf5c68.sound_stream_update(bufPtrs,chBufPtrs,blockLen);
for (int i=0; i<8; i++) {
for (size_t j=0; j<blockLen; j++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(bufC[i*2][j]+bufC[i*2+1][j])>>1;
oscBuf[i]->putSample(pos+j,(bufC[i*2][j]+bufC[i*2+1][j])>>1);
}
}
pos+=blockLen;
len-=blockLen;
lenCopy-=blockLen;
}
for (int i=0; i<8; i++) {
oscBuf[i]->end(len);
}
}
@ -375,7 +384,7 @@ void DivPlatformRF5C68::setFlags(const DivConfig& flags) {
chipType=flags.getInt("chipType",0);
rate=chipClock/384;
for (int i=0; i<8; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
rf5c68=(chipType==1)?rf5c164_device():rf5c68_device();
rf5c68.device_start(sampleMem);

View file

@ -81,15 +81,23 @@ const char** DivPlatformSCC::getRegisterSheet() {
}
void DivPlatformSCC::acquire(short** buf, size_t len) {
for (int i=0; i<5; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
scc->tick(coreQuality);
short out=(short)scc->out()<<5;
buf[0][h]=out;
for (int i=0; i<5; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=scc->voice_out(i)<<7;
oscBuf[i]->putSample(h,scc->voice_out(i)<<7);
}
}
for (int i=0; i<5; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformSCC::updateWave(int ch) {
@ -385,7 +393,7 @@ void DivPlatformSCC::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock/(coreQuality>>1);
for (int i=0; i<5; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
}

View file

@ -37,6 +37,10 @@ const char** DivPlatformSCVTone::getRegisterSheet() {
}
void DivPlatformSCVTone::acquire(short** buf, size_t len) {
for (int i=0; i<4; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
@ -46,10 +50,14 @@ void DivPlatformSCVTone::acquire(short** buf, size_t len) {
}
scv.sound_stream_update(&buf[0][h],1);
oscBuf[0]->data[oscBuf[0]->needle++]=scv.chout[0]<<3;
oscBuf[1]->data[oscBuf[1]->needle++]=scv.chout[1]<<3;
oscBuf[2]->data[oscBuf[2]->needle++]=scv.chout[2]<<3;
oscBuf[3]->data[oscBuf[3]->needle++]=scv.chout[3]<<3;
oscBuf[0]->putSample(h,scv.chout[0]<<3);
oscBuf[1]->putSample(h,scv.chout[1]<<3);
oscBuf[2]->putSample(h,scv.chout[2]<<3);
oscBuf[3]->putSample(h,scv.chout[3]<<3);
}
for (int i=0; i<4; i++) {
oscBuf[i]->end(len);
}
}
@ -334,7 +342,7 @@ void DivPlatformSCVTone::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock/4;
for (int i=0; i<4; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
//upd1771c_sound_set_clock(&scv,(unsigned int)chipClock,8);
}

View file

@ -37,6 +37,8 @@ const char** DivPlatformSCVWave::getRegisterSheet() {
}
void DivPlatformSCVWave::acquire(short** buf, size_t len) {
oscBuf[0]->begin(len);
for (size_t h=0; h<len; h++) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
@ -47,8 +49,10 @@ void DivPlatformSCVWave::acquire(short** buf, size_t len) {
scv.sound_stream_update(&buf[0][h],1);
if (isMuted[0]) buf[0][h]=0;
oscBuf[0]->data[oscBuf[0]->needle++]=buf[0][h];
oscBuf[0]->putSample(h,buf[0][h]);
}
oscBuf[0]->end(len);
}
void DivPlatformSCVWave::tick(bool sysTick) {
@ -324,9 +328,8 @@ void DivPlatformSCVWave::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock/4;
for (int i=0; i<1; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
//upd1771c_sound_set_clock(&scv,(unsigned int)chipClock,8);
}
void DivPlatformSCVWave::poke(unsigned int addr, unsigned short val) {

View file

@ -29,6 +29,10 @@
void DivPlatformSegaPCM::acquire(short** buf, size_t len) {
thread_local int os[2];
for (int i=0; i<16; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
@ -49,9 +53,13 @@ void DivPlatformSegaPCM::acquire(short** buf, size_t len) {
buf[1][h]=os[1];
for (int i=0; i<16; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(pcm.lastOut[i][0]+pcm.lastOut[i][1])>>1;
oscBuf[i]->putSample(h,(pcm.lastOut[i][0]+pcm.lastOut[i][1])>>1);
}
}
for (int i=0; i<16; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformSegaPCM::tick(bool sysTick) {
@ -551,7 +559,7 @@ void DivPlatformSegaPCM::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock/256;
for (int i=0; i<16; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
oldSlides=flags.getBool("oldSlides",false);

View file

@ -73,8 +73,11 @@ const char** DivPlatformSID2::getRegisterSheet() {
return regCheatSheetSID2;
}
void DivPlatformSID2::acquire(short** buf, size_t len)
{
void DivPlatformSID2::acquire(short** buf, size_t len) {
for (int i=0; i<3; i++) {
oscBuf[i]->begin(len);
}
for (size_t i=0; i<len; i++)
{
if (!writes.empty())
@ -96,10 +99,14 @@ void DivPlatformSID2::acquire(short** buf, size_t len)
int co=sid2->chan_out[j]>>2;
if (co<-32768) co=-32768;
if (co>32767) co=32767;
oscBuf[j]->data[oscBuf[j]->needle++]=co;
oscBuf[j]->putSample(i,co);
}
}
}
for (int i=0; i<3; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformSID2::updateFilter(int channel)
@ -710,7 +717,7 @@ void DivPlatformSID2::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock;
for (int i=0; i<3; i++) {
oscBuf[i]->rate=rate/16;
oscBuf[i]->setRate(rate);
}
keyPriority=flags.getBool("keyPriority",true);

View file

@ -94,6 +94,10 @@ const char** DivPlatformSID3::getRegisterSheet() {
void DivPlatformSID3::acquire(short** buf, size_t len)
{
for (int i=0; i<SID3_NUM_CHANNELS; i++) {
oscBuf[i]->begin(len);
}
for (size_t i=0; i<len; i++)
{
if (chan[SID3_NUM_CHANNELS - 1].pcm && chan[SID3_NUM_CHANNELS - 1].dacSample!=-1)
@ -200,12 +204,16 @@ void DivPlatformSID3::acquire(short** buf, size_t len)
for(int j = 0; j < SID3_NUM_CHANNELS - 1; j++)
{
oscBuf[j]->data[oscBuf[j]->needle++] = sid3->muted[j] ? 0 : (sid3->channel_output[j] / 4);
oscBuf[j]->putSample(i,sid3->muted[j] ? 0 : (sid3->channel_output[j] / 4));
}
oscBuf[SID3_NUM_CHANNELS - 1]->data[oscBuf[SID3_NUM_CHANNELS - 1]->needle++] = sid3->muted[SID3_NUM_CHANNELS - 1] ? 0 : (sid3->wave_channel_output / 4);
oscBuf[SID3_NUM_CHANNELS - 1]->putSample(i,sid3->muted[SID3_NUM_CHANNELS - 1] ? 0 : (sid3->wave_channel_output / 4));
}
}
for (int i=0; i<SID3_NUM_CHANNELS; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformSID3::updateFlags(int channel, bool gate)
@ -1351,7 +1359,7 @@ void DivPlatformSID3::setFlags(const DivConfig& flags) {
rate=chipClock;
sid3_set_clock_rate(sid3, chipClock);
for (int i=0; i<SID3_NUM_CHANNELS; i++) {
oscBuf[i]->rate=rate/8;
oscBuf[i]->setRate(rate);
}
}

View file

@ -54,13 +54,22 @@ void DivPlatformSM8521::acquire(short** buf, size_t len) {
regPool[w.addr&0xff]=w.val;
writes.pop();
}
for (int i=0; i<3; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
sm8521_sound_tick(&sm8521,coreQuality);
buf[0][h]=sm8521.out<<6;
for (int i=0; i<2; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=sm8521.sg[i].base.out<<7;
oscBuf[i]->putSample(h,sm8521.sg[i].base.out<<7);
}
oscBuf[2]->data[oscBuf[2]->needle++]=sm8521.noise.base.out<<7;
oscBuf[2]->putSample(h,sm8521.noise.base.out<<7);
}
for (int i=0; i<3; i++) {
oscBuf[i]->end(len);
}
}
@ -369,7 +378,7 @@ void DivPlatformSM8521::setFlags(const DivConfig& flags) {
antiClickEnabled=!flags.getBool("noAntiClick",false);
rate=chipClock/4/coreQuality; // CKIN -> fCLK(/2) -> Function blocks (/2)
for (int i=0; i<3; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
}

View file

@ -63,6 +63,11 @@ void DivPlatformSMS::poolWrite(unsigned short a, unsigned char v) {
void DivPlatformSMS::acquire_nuked(short** buf, size_t len) {
int oL=0;
int oR=0;
for (int i=0; i<4; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
if (!writes.empty()) {
QueuedWrite w=writes.front();
@ -101,12 +106,16 @@ void DivPlatformSMS::acquire_nuked(short** buf, size_t len) {
if (stereo) buf[1][h]=oR;
for (int i=0; i<4; i++) {
if (isMuted[i]) {
oscBuf[i]->data[oscBuf[i]->needle++]=0;
oscBuf[i]->putSample(h,0);
} else {
oscBuf[i]->data[oscBuf[i]->needle++]=sn_nuked.vol_table[sn_nuked.volume_out[i]]*3;
oscBuf[i]->putSample(h,sn_nuked.vol_table[sn_nuked.volume_out[i]]*3);
}
}
}
for (int i=0; i<4; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformSMS::acquire_mame(short** buf, size_t len) {
@ -122,6 +131,11 @@ void DivPlatformSMS::acquire_mame(short** buf, size_t len) {
writes.pop();
}
for (int i=0; i<4; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
short* outs[2]={
&buf[0][h],
@ -130,12 +144,16 @@ void DivPlatformSMS::acquire_mame(short** buf, size_t len) {
sn->sound_stream_update(outs,1);
for (int i=0; i<4; i++) {
if (isMuted[i]) {
oscBuf[i]->data[oscBuf[i]->needle++]=0;
oscBuf[i]->putSample(h,0);
} else {
oscBuf[i]->data[oscBuf[i]->needle++]=sn->get_channel_output(i)*3;
oscBuf[i]->putSample(h,sn->get_channel_output(i)*3);
}
}
}
for (int i=0; i<4; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformSMS::acquire(short** buf, size_t len) {
@ -638,7 +656,7 @@ void DivPlatformSMS::setFlags(const DivConfig& flags) {
rate=chipClock/divider;
for (int i=0; i<4; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
}

View file

@ -1,6 +1,6 @@
/**
* Furnace Tracker - multi-system chiptune tracker
* Copyright (C) 2021-2022 tildearrow and contributors
* Copyright (C) 2021-2025 tildearrow and contributors
*
* Original author: Piotr Fusik (http://asap.sourceforge.net)
* Rewritten based on Mikey emulation by Waldemar Pawlaszek
@ -490,7 +490,7 @@ public:
}
}
int16_t sampleAudio( DivDispatchOscBuffer** oscb )
int16_t sampleAudio( short* oscb )
{
for ( ;; )
{
@ -504,10 +504,10 @@ public:
if ( oscb != nullptr )
{
oscb[0]->data[oscb[0]->needle++]=ch0 * MAGICK_OSC_VOLUME_BOOSTER;
oscb[1]->data[oscb[1]->needle++]=ch1 * MAGICK_OSC_VOLUME_BOOSTER;
oscb[2]->data[oscb[2]->needle++]=ch2 * MAGICK_OSC_VOLUME_BOOSTER;
oscb[3]->data[oscb[3]->needle++]=ch3 * MAGICK_OSC_VOLUME_BOOSTER;
oscb[0]=ch0 * MAGICK_OSC_VOLUME_BOOSTER;
oscb[1]=ch1 * MAGICK_OSC_VOLUME_BOOSTER;
oscb[2]=ch2 * MAGICK_OSC_VOLUME_BOOSTER;
oscb[3]=ch3 * MAGICK_OSC_VOLUME_BOOSTER;
}
enqueueSampling();
@ -612,7 +612,7 @@ private:
};
//Initializing periods with safe defaults
Pokey::Pokey() : mPokeyClock{ (uint32_t)COLOR_NTSC / 2 }, mSampleRate{ mPokeyClock / 7 }, mPokey{}
Pokey::Pokey() : mPokeyClock{ (uint32_t)3579545.4545454545454545454545454545454644484879993035705375307 / 2 }, mSampleRate{ mPokeyClock / 7 }, mPokey{}
{
}
@ -638,7 +638,7 @@ void Pokey::write( uint8_t address, uint8_t value )
mPokey->write( address, value );
}
int16_t Pokey::sampleAudio( DivDispatchOscBuffer** oscb )
int16_t Pokey::sampleAudio( short* oscb )
{
assert( mPokey );
return mPokey->sampleAudio( oscb );

View file

@ -3,9 +3,6 @@
#include <cstdint>
#include <memory>
// can you forgive me
#include "../../../dispatch.h"
namespace AltASAP
{
@ -20,7 +17,7 @@ public:
~Pokey();
void write( uint8_t address, uint8_t value );
int16_t sampleAudio( DivDispatchOscBuffer** oscb = nullptr );
int16_t sampleAudio( short* oscb = nullptr );
uint8_t const* getRegisterPool();

View file

@ -58,10 +58,15 @@ const char** DivPlatformSupervision::getRegisterSheet() {
void DivPlatformSupervision::acquire(short** buf, size_t len) {
int mask_bits=0;
for (int i=0; i<4; i++)
for (int i=0; i<4; i++) {
mask_bits |= isMuted[i]?0:8>>i;
}
supervision_set_mute_mask(&svision,mask_bits);
for (int i=0; i<4; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
@ -76,7 +81,7 @@ void DivPlatformSupervision::acquire(short** buf, size_t len) {
tempR[0]=(((int)s[1])-128)*256;
for (int i=0; i<4; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP((((int)s[2+i])-128)*256,-32768,32767);
oscBuf[i]->putSample(h,CLAMP((((int)s[2+i])-128)*256,-32768,32767));
}
tempL[0]=(tempL[0]>>1)+(tempL[0]>>2);
@ -91,11 +96,14 @@ void DivPlatformSupervision::acquire(short** buf, size_t len) {
buf[0][h]=tempL[0];
buf[1][h]=tempR[0];
}
for (int i=0; i<4; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformSupervision::tick(bool sysTick) {
for (int i=0; i<4; i++) {
chan[i].std.next();
if (chan[i].std.vol.had) {
chan[i].outVol=VOL_SCALE_LINEAR(chan[i].vol&15,MIN(15,chan[i].std.vol.val),15);
@ -477,7 +485,7 @@ void DivPlatformSupervision::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock/64;
for (int i=0; i<4; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
supervision_sound_set_clock(&svision,(unsigned int)chipClock);
supervision_sound_set_flags(&svision,(unsigned int)otherFlags);

View file

@ -54,6 +54,10 @@ const char** DivPlatformSwan::getRegisterSheet() {
}
void DivPlatformSwan::acquire(short** buf, size_t len) {
for (int i=0; i<4; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
// PCM part
if (pcm && dacSample!=-1) {
@ -89,9 +93,13 @@ void DivPlatformSwan::acquire(short** buf, size_t len) {
buf[0][h]=samp[0];
buf[1][h]=samp[1];
for (int i=0; i<4; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(ws->sample_cache[i][0]+ws->sample_cache[i][1])<<6;
oscBuf[i]->putSample(h,(ws->sample_cache[i][0]+ws->sample_cache[i][1])<<6);
}
}
for (int i=0; i<4; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformSwan::updateWave(int ch) {
@ -607,7 +615,7 @@ void DivPlatformSwan::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock/coreQuality;
for (int i=0; i<4; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
}

View file

@ -36,6 +36,10 @@ const char** DivPlatformT6W28::getRegisterSheet() {
}
void DivPlatformT6W28::acquire(short** buf, size_t len) {
for (int i=0; i<4; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
cycles=0;
while (!writes.empty() && cycles<16) {
@ -54,7 +58,7 @@ void DivPlatformT6W28::acquire(short** buf, size_t len) {
tempL=0;
tempR=0;
for (int i=0; i<4; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(out[i][1].curValue+out[i][2].curValue)<<7;
oscBuf[i]->putSample(h,(out[i][1].curValue+out[i][2].curValue)<<7);
tempL+=out[i][1].curValue<<7;
tempR+=out[i][2].curValue<<7;
}
@ -67,6 +71,10 @@ void DivPlatformT6W28::acquire(short** buf, size_t len) {
buf[0][h]=tempL;
buf[1][h]=tempR;
}
for (int i=0; i<4; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformT6W28::writeOutVol(int ch) {
@ -364,7 +372,7 @@ void DivPlatformT6W28::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock/16;
for (int i=0; i<4; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
easyNoise=!flags.getBool("noEasyNoise",false);

View file

@ -40,6 +40,10 @@ const char** DivPlatformTED::getRegisterSheet() {
}
void DivPlatformTED::acquire(short** buf, size_t len) {
for (int i=0; i<2; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
@ -49,8 +53,12 @@ void DivPlatformTED::acquire(short** buf, size_t len) {
}
ted_sound_machine_calculate_samples(&ted,&buf[0][h],1,1);
oscBuf[0]->data[oscBuf[0]->needle++]=(ted.voice0_output_enabled && ted.voice0_sign)?(ted.volume<<1):0;
oscBuf[1]->data[oscBuf[1]->needle++]=(ted.voice1_output_enabled && ((ted.noise && (!(ted.noise_shift_register&1))) || (!ted.noise && ted.voice1_sign)))?(ted.volume<<1):0;
oscBuf[0]->putSample(h,(ted.voice0_output_enabled && ted.voice0_sign)?(ted.volume<<1):0);
oscBuf[1]->putSample(h,(ted.voice1_output_enabled && ((ted.noise && (!(ted.noise_shift_register&1))) || (!ted.noise && ted.voice1_sign)))?(ted.volume<<1):0);
}
for (int i=0; i<2; i++) {
oscBuf[i]->end(len);
}
}
@ -322,7 +330,7 @@ void DivPlatformTED::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock/8;
for (int i=0; i<2; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
keyPriority=flags.getBool("keyPriority",true);
}

View file

@ -39,6 +39,10 @@ const char** DivPlatformTIA::getRegisterSheet() {
}
void DivPlatformTIA::acquire(short** buf, size_t len) {
for (int i=0; i<2; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
if (softwarePitch) {
int i=-1;
@ -75,10 +79,14 @@ void DivPlatformTIA::acquire(short** buf, size_t len) {
}
if (++chanOscCounter>=114) {
chanOscCounter=0;
oscBuf[0]->data[oscBuf[0]->needle++]=tia.myChannelOut[0];
oscBuf[1]->data[oscBuf[1]->needle++]=tia.myChannelOut[1];
oscBuf[0]->putSample(h,tia.myChannelOut[0]);
oscBuf[1]->putSample(h,tia.myChannelOut[1]);
}
}
for (int i=0; i<2; i++) {
oscBuf[i]->end(len);
}
}
unsigned char DivPlatformTIA::dealWithFreq(unsigned char shape, int base, int pitch) {
@ -471,7 +479,7 @@ void DivPlatformTIA::setFlags(const DivConfig& flags) {
softwarePitch=flags.getBool("softwarePitch",false);
oldPitch=flags.getBool("oldPitch",false);
for (int i=0; i<2; i++) {
oscBuf[i]->rate=rate/114;
oscBuf[i]->setRate(rate);
}
tia.reset(mixingType);
}

View file

@ -62,6 +62,10 @@ void DivPlatformTX81Z::acquire(short** buf, size_t len) {
ymfm::ym2414::fm_engine* fme=fm_ymfm->debug_engine();
for (int i=0; i<8; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
os[0]=0; os[1]=0;
if (!writes.empty()) {
@ -82,7 +86,7 @@ void DivPlatformTX81Z::acquire(short** buf, size_t len) {
fm_ymfm->generate(&out_ymfm);
for (int i=0; i<8; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fme->debug_channel(i)->debug_output(0)+fme->debug_channel(i)->debug_output(1),-32768,32767);
oscBuf[i]->putSample(h,CLAMP(fme->debug_channel(i)->debug_output(0)+fme->debug_channel(i)->debug_output(1),-32768,32767));
}
os[0]=out_ymfm.data[0];
@ -96,6 +100,10 @@ void DivPlatformTX81Z::acquire(short** buf, size_t len) {
buf[0][h]=os[0];
buf[1][h]=os[1];
}
for (int i=0; i<8; i++) {
oscBuf[i]->begin(len);
}
}
static unsigned char noteMap[12]={
@ -1114,7 +1122,7 @@ void DivPlatformTX81Z::setFlags(const DivConfig& flags) {
rate=chipClock/64;
for (int i=0; i<8; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
}

View file

@ -94,6 +94,10 @@ const char** DivPlatformVB::getRegisterSheet() {
}
void DivPlatformVB::acquire(short** buf, size_t len) {
for (int i=0; i<6; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
cycles=0;
if (!writes.empty()) {
@ -107,7 +111,7 @@ void DivPlatformVB::acquire(short** buf, size_t len) {
tempL=0;
tempR=0;
for (int i=0; i<6; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(vb->last_output[i][0]+vb->last_output[i][1])*8;
oscBuf[i]->putSample(h,(vb->last_output[i][0]+vb->last_output[i][1])*8);
tempL+=vb->last_output[i][0];
tempR+=vb->last_output[i][1];
}
@ -120,6 +124,10 @@ void DivPlatformVB::acquire(short** buf, size_t len) {
buf[0][h]=tempL;
buf[1][h]=tempR;
}
for (int i=0; i<6; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformVB::updateWave(int ch) {
@ -586,7 +594,7 @@ void DivPlatformVB::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock/coreQuality;
for (int i=0; i<6; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
romMode=flags.getBool("romMode",false);

View file

@ -58,12 +58,17 @@ const char** DivPlatformVERA::getRegisterSheet() {
// TODO: possible sample offset latency...
void DivPlatformVERA::acquire(short** buf, size_t len) {
for (int i=0; i<17; i++) {
oscBuf[i]->begin(len);
}
// both PSG part and PCM part output a full 16-bit range, putting bufL/R
// argument right into both could cause an overflow
short whyCallItBuf[4][128];
size_t pos=0;
size_t lenCopy=0;
DivSample* s=parent->getSample(chan[16].pcm.sample);
while (len>0) {
while (lenCopy>0) {
if (s->samples>0 && chan[16].pcm.pos<s->samples) {
while (pcm_is_fifo_almost_empty(pcm)) {
short tmp_l=0;
@ -109,24 +114,30 @@ void DivPlatformVERA::acquire(short** buf, size_t len) {
// just let the buffer run out
chan[16].pcm.sample=-1;
}
int curLen=MIN(len,128);
int curLen=MIN(lenCopy,128);
memset(whyCallItBuf,0,sizeof(whyCallItBuf));
pcm_render(pcm,whyCallItBuf[2],whyCallItBuf[3],curLen);
for (int i=0; i<curLen; i++) {
psg_render(psg,&whyCallItBuf[0][i],&whyCallItBuf[1][i],1);
buf[0][pos]=(short)(((int)whyCallItBuf[0][i]+whyCallItBuf[2][i])/2);
buf[1][pos]=(short)(((int)whyCallItBuf[1][i]+whyCallItBuf[3][i])/2);
pos++;
for (int i=0; i<16; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=psg->channels[i].lastOut;
for (int j=0; j<16; j++) {
oscBuf[j]->putSample(pos,psg->channels[j].lastOut);
}
int pcmOut=(whyCallItBuf[2][i]+whyCallItBuf[3][i])>>1;
if (pcmOut<-32768) pcmOut=-32768;
if (pcmOut>32767) pcmOut=32767;
oscBuf[16]->data[oscBuf[16]->needle++]=pcmOut;
oscBuf[16]->putSample(pos,pcmOut);
pos++;
}
len-=curLen;
lenCopy-=curLen;
}
for (int i=0; i<17; i++) {
oscBuf[i]->end(len);
}
}
@ -537,7 +548,7 @@ void DivPlatformVERA::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock/512;
for (int i=0; i<17; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
}

View file

@ -46,6 +46,11 @@ void DivPlatformVIC20::acquire(short** buf, size_t len) {
0b0, 0b10, 0b100, 0b110, 0b1000, 0b1010, 0b1011, 0b1110,
0b10010, 0b10100, 0b10110, 0b11000, 0b11010, 0b100100, 0b101010, 0b101100
};
for (int i=0; i<4; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
if (hasWaveWrite) {
hasWaveWrite=false;
@ -69,9 +74,13 @@ void DivPlatformVIC20::acquire(short** buf, size_t len) {
vic_sound_machine_calculate_samples(vic,&samp,1,1,0,SAMP_DIVIDER);
buf[0][h]=samp;
for (int i=0; i<4; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=vic->ch[i].out?(vic->volume<<11):0;
oscBuf[i]->putSample(h,vic->ch[i].out?(vic->volume<<11):0);
}
}
for (int i=0; i<4; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformVIC20::calcAndWriteOutVol(int ch, int env) {
@ -345,7 +354,7 @@ void DivPlatformVIC20::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock/4;
for (int i=0; i<4; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
}

View file

@ -47,7 +47,11 @@ const char** DivPlatformVRC6::getRegisterSheet() {
}
void DivPlatformVRC6::acquire(short** buf, size_t len) {
for (size_t i=0; i<len; i++) {
for (int i=0; i<3; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
// PCM part
for (int i=0; i<2; i++) {
if (chan[i].pcm && chan[i].dacSample!=-1) {
@ -81,15 +85,15 @@ void DivPlatformVRC6::acquire(short** buf, size_t len) {
int sample=vrc6.out()<<9; // scale to 16 bit
if (sample>32767) sample=32767;
if (sample<-32768) sample=-32768;
buf[0][i]=sample;
buf[0][h]=sample;
// Oscilloscope buffer part
if (++writeOscBuf>=32) {
writeOscBuf=0;
for (int i=0; i<2; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=vrc6.pulse_out(i)<<11;
oscBuf[i]->putSample(h,vrc6.pulse_out(i)<<11);
}
oscBuf[2]->data[oscBuf[2]->needle++]=vrc6.sawtooth_out()<<10;
oscBuf[2]->putSample(h,vrc6.sawtooth_out()<<10);
}
// Command part
@ -128,6 +132,10 @@ void DivPlatformVRC6::acquire(short** buf, size_t len) {
writes.pop();
}
}
for (int i=0; i<3; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformVRC6::tick(bool sysTick) {
@ -541,7 +549,7 @@ void DivPlatformVRC6::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock;
for (int i=0; i<3; i++) {
oscBuf[i]->rate=rate/32;
oscBuf[i]->setRate(rate);
}
}

View file

@ -206,6 +206,10 @@ const char** DivPlatformX1_010::getRegisterSheet() {
}
void DivPlatformX1_010::acquire(short** buf, size_t len) {
for (int i=0; i<16; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
x1_010.tick();
@ -223,9 +227,13 @@ void DivPlatformX1_010::acquire(short** buf, size_t len) {
for (int i=0; i<16; i++) {
int vo=(x1_010.voice_out(i,0)+x1_010.voice_out(i,1))<<2;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(vo,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(vo,-32768,32767));
}
}
for (int i=0; i<16; i++) {
oscBuf[i]->end(len);
}
}
u8 DivPlatformX1_010::read_byte(u32 address) {
@ -965,7 +973,7 @@ void DivPlatformX1_010::setFlags(const DivConfig& flags) {
stereo=flags.getBool("stereo",false);
isBanked=flags.getBool("isBanked",false);
for (int i=0; i<16; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
}

View file

@ -169,6 +169,10 @@ void DivPlatformYM2203::acquire_combo(short** buf, size_t len) {
thread_local int os;
thread_local short ignored[2];
for (int i=0; i<7; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
// AY -> OPN
ay->runDAC();
@ -236,13 +240,17 @@ void DivPlatformYM2203::acquire_combo(short** buf, size_t len) {
buf[0][h]=os;
for (int i=0; i<3; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fm_nuked.ch_out[i]<<1,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(fm_nuked.ch_out[i]<<1,-32768,32767));
}
for (int i=(3+isCSM); i<(6+isCSM); i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=fmout.data[i-(2+isCSM)]<<1;
oscBuf[i]->putSample(h,fmout.data[i-(2+isCSM)]<<1);
}
}
for (int i=0; i<7; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformYM2203::acquire_ymfm(short** buf, size_t len) {
@ -255,6 +263,10 @@ void DivPlatformYM2203::acquire_ymfm(short** buf, size_t len) {
fmChan[i]=fme->debug_channel(i);
}
for (int i=0; i<7; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
// AY -> OPN
ay->runDAC();
@ -294,13 +306,17 @@ void DivPlatformYM2203::acquire_ymfm(short** buf, size_t len) {
for (int i=0; i<3; i++) {
int out=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1))<<1;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(out,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(out,-32768,32767));
}
for (int i=(3+isCSM); i<(6+isCSM); i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=fmout.data[i-(2+isCSM)]<<1;
oscBuf[i]->putSample(h,fmout.data[i-(2+isCSM)]<<1);
}
}
for (int i=0; i<7; i++) {
oscBuf[i]->end(len);
}
}
static const unsigned char subCycleMap[6]={
@ -310,6 +326,10 @@ static const unsigned char subCycleMap[6]={
void DivPlatformYM2203::acquire_lle(short** buf, size_t len) {
thread_local int fmOut[6];
for (int i=0; i<7; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
bool have0=false;
bool have1=false;
@ -444,11 +464,11 @@ void DivPlatformYM2203::acquire_lle(short** buf, size_t len) {
for (int i=0; i<3; i++) {
if (fmOut[i]<-32768) fmOut[i]=-32768;
if (fmOut[i]>32767) fmOut[i]=32767;
oscBuf[i]->data[oscBuf[i]->needle++]=fmOut[i];
oscBuf[i]->putSample(h,fmOut[i]);
}
// SSG
for (int i=0; i<3; i++) {
oscBuf[i+3]->data[oscBuf[i+3]->needle++]=fm_lle.o_analog_ch[i]*32767;
oscBuf[i+3]->putSample(h,fm_lle.o_analog_ch[i]*32767);
}
// DAC
@ -461,6 +481,10 @@ void DivPlatformYM2203::acquire_lle(short** buf, size_t len) {
buf[0][h]=outL;
}
for (int i=0; i<7; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformYM2203::fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len) {
@ -1386,7 +1410,7 @@ void DivPlatformYM2203::setFlags(const DivConfig& flags) {
rate=fm->sample_rate(chipClock);
}
for (int i=0; i<7; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
immWrite(0x2d,0xff);
immWrite(prescale,0xff);

View file

@ -320,6 +320,10 @@ void DivPlatformYM2608::acquire_combo(short** buf, size_t len) {
adpcmAChan[i]=aae->debug_channel(i);
}
for (int i=0; i<17; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
// AY -> OPN
ay->runDAC();
@ -406,19 +410,23 @@ void DivPlatformYM2608::acquire_combo(short** buf, size_t len) {
for (int i=0; i<(psgChanOffs-isCSM); i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fm_nuked.ch_out[i]<<1,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(fm_nuked.ch_out[i]<<1,-32768,32767));
}
ssge->get_last_out(ssgOut);
for (int i=psgChanOffs; i<adpcmAChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=ssgOut.data[i-psgChanOffs]<<1;
oscBuf[i]->putSample(h,ssgOut.data[i-psgChanOffs]<<1);
}
for (int i=adpcmAChanOffs; i<adpcmBChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(adpcmAChan[i-adpcmAChanOffs]->get_last_out(0)+adpcmAChan[i-adpcmAChanOffs]->get_last_out(1))>>1;
oscBuf[i]->putSample(h,(adpcmAChan[i-adpcmAChanOffs]->get_last_out(0)+adpcmAChan[i-adpcmAChanOffs]->get_last_out(1))>>1);
}
oscBuf[adpcmBChanOffs]->data[oscBuf[adpcmBChanOffs]->needle++]=(abe->get_last_out(0)+abe->get_last_out(1))>>1;
oscBuf[adpcmBChanOffs]->putSample(h,(abe->get_last_out(0)+abe->get_last_out(1))>>1);
}
for (int i=0; i<17; i++) {
oscBuf[i]->end(len);
}
}
@ -439,6 +447,10 @@ void DivPlatformYM2608::acquire_ymfm(short** buf, size_t len) {
adpcmAChan[i]=aae->debug_channel(i);
}
for (int i=0; i<17; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
// AY -> OPN
ay->runDAC();
@ -482,19 +494,23 @@ void DivPlatformYM2608::acquire_ymfm(short** buf, size_t len) {
for (int i=0; i<6; i++) {
int out=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1))<<1;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(out,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(out,-32768,32767));
}
ssge->get_last_out(ssgOut);
for (int i=(6+isCSM); i<(9+isCSM); i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=ssgOut.data[i-6-isCSM]<<1;
oscBuf[i]->putSample(h,ssgOut.data[i-6-isCSM]<<1);
}
for (int i=(9+isCSM); i<(15+isCSM); i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(adpcmAChan[i-9-isCSM]->get_last_out(0)+adpcmAChan[i-9]->get_last_out(1))>>1;
oscBuf[i]->putSample(h,(adpcmAChan[i-9-isCSM]->get_last_out(0)+adpcmAChan[i-9]->get_last_out(1))>>1);
}
oscBuf[15+isCSM]->data[oscBuf[15+isCSM]->needle++]=(abe->get_last_out(0)+abe->get_last_out(1))>>1;
oscBuf[15+isCSM]->putSample(h,(abe->get_last_out(0)+abe->get_last_out(1))>>1);
}
for (int i=0; i<17; i++) {
oscBuf[i]->end(len);
}
}
@ -505,6 +521,10 @@ static const unsigned char subCycleMap[6]={
void DivPlatformYM2608::acquire_lle(short** buf, size_t len) {
thread_local int fmOut[6];
for (int i=0; i<17; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
bool have0=false;
bool have1=false;
@ -656,20 +676,20 @@ void DivPlatformYM2608::acquire_lle(short** buf, size_t len) {
for (int i=0; i<6; i++) {
if (fmOut[i]<-32768) fmOut[i]=-32768;
if (fmOut[i]>32767) fmOut[i]=32767;
oscBuf[i]->data[oscBuf[i]->needle++]=fmOut[i];
oscBuf[i]->putSample(h,fmOut[i]);
}
// SSG
for (int i=0; i<3; i++) {
oscBuf[i+6]->data[oscBuf[i+6]->needle++]=fm_lle.o_analog_ch[i]*32767;
oscBuf[i+6]->putSample(h,fm_lle.o_analog_ch[i]*32767);
}
// RSS
for (int i=0; i<6; i++) {
if (rssOut[i]<-32768) rssOut[i]=-32768;
if (rssOut[i]>32767) rssOut[i]=32767;
oscBuf[9+i]->data[oscBuf[9+i]->needle++]=rssOut[i];
oscBuf[9+i]->putSample(h,rssOut[i]);
}
// ADPCM
oscBuf[15]->data[oscBuf[15]->needle++]=fm_lle.ac_ad_output;
oscBuf[15]->putSample(h,fm_lle.ac_ad_output);
// DAC
int accm1=(short)dacOut[1];
@ -686,6 +706,10 @@ void DivPlatformYM2608::acquire_lle(short** buf, size_t len) {
buf[0][h]=outL;
buf[1][h]=outR;
}
for (int i=0; i<17; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformYM2608::fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len) {
@ -2018,7 +2042,7 @@ void DivPlatformYM2608::setFlags(const DivConfig& flags) {
rate=fm->sample_rate(chipClock);
}
for (int i=0; i<17; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
immWrite(0x2d,0xff);
immWrite(prescale,0xff);

View file

@ -256,6 +256,10 @@ void DivPlatformYM2610::acquire_combo(short** buf, size_t len) {
adpcmAChan[i]=aae->debug_channel(i);
}
for (int i=0; i<17; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
// AY -> OPN
ay->runDAC();
@ -338,19 +342,23 @@ void DivPlatformYM2610::acquire_combo(short** buf, size_t len) {
for (int i=0; i<(psgChanOffs-isCSM); i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fm_nuked.ch_out[bchOffs[i]]<<1,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(fm_nuked.ch_out[bchOffs[i]]<<1,-32768,32767));
}
ssge->get_last_out(ssgOut);
for (int i=psgChanOffs; i<adpcmAChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=ssgOut.data[i-psgChanOffs]<<1;
oscBuf[i]->putSample(h,ssgOut.data[i-psgChanOffs]<<1);
}
for (int i=adpcmAChanOffs; i<adpcmBChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(adpcmAChan[i-adpcmAChanOffs]->get_last_out(0)+adpcmAChan[i-adpcmAChanOffs]->get_last_out(1))>>1;
oscBuf[i]->putSample(h,(adpcmAChan[i-adpcmAChanOffs]->get_last_out(0)+adpcmAChan[i-adpcmAChanOffs]->get_last_out(1))>>1);
}
oscBuf[adpcmBChanOffs]->data[oscBuf[adpcmBChanOffs]->needle++]=(abe->get_last_out(0)+abe->get_last_out(1))>>1;
oscBuf[adpcmBChanOffs]->putSample(h,(abe->get_last_out(0)+abe->get_last_out(1))>>1);
}
for (int i=0; i<17; i++) {
oscBuf[i]->end(len);
}
}
@ -373,6 +381,10 @@ void DivPlatformYM2610::acquire_ymfm(short** buf, size_t len) {
adpcmAChan[i]=aae->debug_channel(i);
}
for (int i=0; i<17; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
// AY -> OPN
ay->runDAC();
@ -416,19 +428,23 @@ void DivPlatformYM2610::acquire_ymfm(short** buf, size_t len) {
for (int i=0; i<(psgChanOffs-isCSM); i++) {
int out=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1))<<1;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(out,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(out,-32768,32767));
}
ssge->get_last_out(ssgOut);
for (int i=psgChanOffs; i<adpcmAChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=ssgOut.data[i-psgChanOffs]<<1;
oscBuf[i]->putSample(h,ssgOut.data[i-psgChanOffs]<<1);
}
for (int i=adpcmAChanOffs; i<adpcmBChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(adpcmAChan[i-adpcmAChanOffs]->get_last_out(0)+adpcmAChan[i-adpcmAChanOffs]->get_last_out(1))>>1;
oscBuf[i]->putSample(h,(adpcmAChan[i-adpcmAChanOffs]->get_last_out(0)+adpcmAChan[i-adpcmAChanOffs]->get_last_out(1))>>1);
}
oscBuf[adpcmBChanOffs]->data[oscBuf[adpcmBChanOffs]->needle++]=(abe->get_last_out(0)+abe->get_last_out(1))>>1;
oscBuf[adpcmBChanOffs]->putSample(h,(abe->get_last_out(0)+abe->get_last_out(1))>>1);
}
for (int i=0; i<17; i++) {
oscBuf[i]->end(len);
}
}
@ -439,6 +455,10 @@ static const unsigned char subCycleMap[6]={
void DivPlatformYM2610::acquire_lle(short** buf, size_t len) {
thread_local int fmOut[6];
for (int i=0; i<17; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
bool have0=false;
bool have1=false;
@ -588,20 +608,20 @@ void DivPlatformYM2610::acquire_lle(short** buf, size_t len) {
for (int i=0; i<4; i++) {
if (fmOut[i]<-32768) fmOut[i]=-32768;
if (fmOut[i]>32767) fmOut[i]=32767;
oscBuf[i]->data[oscBuf[i]->needle++]=fmOut[i];
oscBuf[i]->putSample(h,fmOut[i]);
}
// SSG
for (int i=0; i<3; i++) {
oscBuf[i+4]->data[oscBuf[i+4]->needle++]=fm_lle.o_analog_ch[i]*32767;
oscBuf[i+4]->putSample(h,fm_lle.o_analog_ch[i]*32767);
}
// RSS
for (int i=0; i<6; i++) {
if (rssOut[i]<-32768) rssOut[i]=-32768;
if (rssOut[i]>32767) rssOut[i]=32767;
oscBuf[7+i]->data[oscBuf[7+i]->needle++]=rssOut[i];
oscBuf[7+i]->putSample(h,rssOut[i]);
}
// ADPCM
oscBuf[13]->data[oscBuf[13]->needle++]=fm_lle.ac_ad_output;
oscBuf[13]->putSample(h,fm_lle.ac_ad_output);
// DAC
int accm1=(short)dacOut[1];
@ -618,6 +638,10 @@ void DivPlatformYM2610::acquire_lle(short** buf, size_t len) {
buf[0][h]=outL;
buf[1][h]=outR;
}
for (int i=0; i<17; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformYM2610::tick(bool sysTick) {

View file

@ -320,6 +320,10 @@ void DivPlatformYM2610B::acquire_combo(short** buf, size_t len) {
adpcmAChan[i]=aae->debug_channel(i);
}
for (int i=0; i<17; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
// AY -> OPN
ay->runDAC();
@ -406,19 +410,23 @@ void DivPlatformYM2610B::acquire_combo(short** buf, size_t len) {
for (int i=0; i<(psgChanOffs-isCSM); i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(fm_nuked.ch_out[i]<<1,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(fm_nuked.ch_out[i]<<1,-32768,32767));
}
ssge->get_last_out(ssgOut);
for (int i=psgChanOffs; i<adpcmAChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=ssgOut.data[i-psgChanOffs]<<1;
oscBuf[i]->putSample(h,ssgOut.data[i-psgChanOffs]<<1);
}
for (int i=adpcmAChanOffs; i<adpcmBChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(adpcmAChan[i-adpcmAChanOffs]->get_last_out(0)+adpcmAChan[i-adpcmAChanOffs]->get_last_out(1))>>1;
oscBuf[i]->putSample(h,(adpcmAChan[i-adpcmAChanOffs]->get_last_out(0)+adpcmAChan[i-adpcmAChanOffs]->get_last_out(1))>>1);
}
oscBuf[adpcmBChanOffs]->data[oscBuf[adpcmBChanOffs]->needle++]=(abe->get_last_out(0)+abe->get_last_out(1))>>1;
oscBuf[adpcmBChanOffs]->putSample(h,(abe->get_last_out(0)+abe->get_last_out(1))>>1);
}
for (int i=0; i<17; i++) {
oscBuf[i]->end(len);
}
}
@ -439,6 +447,10 @@ void DivPlatformYM2610B::acquire_ymfm(short** buf, size_t len) {
adpcmAChan[i]=aae->debug_channel(i);
}
for (int i=0; i<17; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
// AY -> OPN
ay->runDAC();
@ -482,19 +494,23 @@ void DivPlatformYM2610B::acquire_ymfm(short** buf, size_t len) {
for (int i=0; i<(psgChanOffs-isCSM); i++) {
int out=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1))<<1;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(out,-32768,32767);
oscBuf[i]->putSample(h,CLAMP(out,-32768,32767));
}
ssge->get_last_out(ssgOut);
for (int i=psgChanOffs; i<adpcmAChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=ssgOut.data[i-psgChanOffs]<<1;
oscBuf[i]->putSample(h,ssgOut.data[i-psgChanOffs]<<1);
}
for (int i=adpcmAChanOffs; i<adpcmBChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(adpcmAChan[i-adpcmAChanOffs]->get_last_out(0)+adpcmAChan[i-adpcmAChanOffs]->get_last_out(1))>>1;
oscBuf[i]->putSample(h,(adpcmAChan[i-adpcmAChanOffs]->get_last_out(0)+adpcmAChan[i-adpcmAChanOffs]->get_last_out(1))>>1);
}
oscBuf[adpcmBChanOffs]->data[oscBuf[adpcmBChanOffs]->needle++]=(abe->get_last_out(0)+abe->get_last_out(1))>>1;
oscBuf[adpcmBChanOffs]->putSample(h,(abe->get_last_out(0)+abe->get_last_out(1))>>1);
}
for (int i=0; i<17; i++) {
oscBuf[i]->end(len);
}
}
@ -507,6 +523,10 @@ void DivPlatformYM2610B::acquire_lle(short** buf, size_t len) {
fm_lle.ym2610b=1;
for (int i=0; i<17; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
bool have0=false;
bool have1=false;
@ -656,20 +676,20 @@ void DivPlatformYM2610B::acquire_lle(short** buf, size_t len) {
for (int i=0; i<6; i++) {
if (fmOut[i]<-32768) fmOut[i]=-32768;
if (fmOut[i]>32767) fmOut[i]=32767;
oscBuf[i]->data[oscBuf[i]->needle++]=fmOut[i];
oscBuf[i]->putSample(h,fmOut[i]);
}
// SSG
for (int i=0; i<3; i++) {
oscBuf[i+6]->data[oscBuf[i+6]->needle++]=fm_lle.o_analog_ch[i]*32767;
oscBuf[i+6]->putSample(h,fm_lle.o_analog_ch[i]*32767);
}
// RSS
for (int i=0; i<6; i++) {
if (rssOut[i]<-32768) rssOut[i]=-32768;
if (rssOut[i]>32767) rssOut[i]=32767;
oscBuf[9+i]->data[oscBuf[9+i]->needle++]=rssOut[i];
oscBuf[9+i]->putSample(h,rssOut[i]);
}
// ADPCM
oscBuf[15]->data[oscBuf[15]->needle++]=fm_lle.ac_ad_output;
oscBuf[15]->putSample(h,fm_lle.ac_ad_output);
// DAC
int accm1=(short)dacOut[1];
@ -686,6 +706,10 @@ void DivPlatformYM2610B::acquire_lle(short** buf, size_t len) {
buf[0][h]=outL;
buf[1][h]=outR;
}
for (int i=0; i<17; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformYM2610B::tick(bool sysTick) {

View file

@ -323,7 +323,7 @@ class DivPlatformYM2610Base: public DivPlatformOPN {
rate=fm->sample_rate(chipClock);
}
for (int i=0; i<17; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
}

View file

@ -59,15 +59,22 @@ const char** DivPlatformYMZ280B::getRegisterSheet() {
return regCheatSheetYMZ280B;
}
// not this crap again... I hate while loops!
void DivPlatformYMZ280B::acquire(short** buf, size_t len) {
short why[16][256];
short *bufPtrs[16]={
why[0],why[1],why[2],why[3],why[4],why[5],why[6],why[7],
why[8],why[9],why[10],why[11],why[12],why[13],why[14],why[15]
};
for (int i=0; i<8; i++) {
oscBuf[i]->begin(len);
}
size_t lenCopy=len;
size_t pos=0;
while (len > 0) {
size_t blockLen = MIN(len, 256);
while (lenCopy > 0) {
size_t blockLen = MIN(lenCopy, 256);
ymz280b.sound_stream_update(bufPtrs, blockLen);
for (size_t i=0; i<blockLen; i++) {
int dataL=0;
@ -75,13 +82,17 @@ void DivPlatformYMZ280B::acquire(short** buf, size_t len) {
for (int j=0; j<8; j++) {
dataL+=why[j*2][i];
dataR+=why[j*2+1][i];
oscBuf[j]->data[oscBuf[j]->needle++]=(short)(((int)why[j*2][i]+why[j*2+1][i])/4);
oscBuf[j]->putSample(pos,(short)(((int)why[j*2][i]+why[j*2+1][i])/4));
}
buf[0][pos]=(short)(dataL/8);
buf[1][pos]=(short)(dataR/8);
pos++;
}
len-=blockLen;
lenCopy-=blockLen;
}
for (int i=0; i<8; i++) {
oscBuf[i]->end(len);
}
}
@ -531,7 +542,7 @@ void DivPlatformYMZ280B::setFlags(const DivConfig& flags) {
break;
}
for (int i=0; i<8; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
}

View file

@ -28,6 +28,10 @@ const char** DivPlatformZXBeeper::getRegisterSheet() {
}
void DivPlatformZXBeeper::acquire(short** buf, size_t len) {
for (int i=0; i<1; i++) {
oscBuf[i]->begin(len);
}
bool o=false;
for (size_t h=0; h<len; h++) {
// clock here
@ -47,7 +51,7 @@ void DivPlatformZXBeeper::acquire(short** buf, size_t len) {
}
o=sampleOut;
buf[0][h]=o?16384:0;
oscBuf[0]->data[oscBuf[0]->needle++]=o?16384:-16384;
oscBuf[0]->putSample(h,o?16384:-16384);
continue;
}
@ -65,7 +69,11 @@ void DivPlatformZXBeeper::acquire(short** buf, size_t len) {
if (++curChan>=6) curChan=0;
buf[0][h]=o?16384:0;
oscBuf[0]->data[oscBuf[0]->needle++]=o?16384:-16384;
oscBuf[0]->putSample(h,o?16384:-16384);
}
for (int i=0; i<1; i++) {
oscBuf[i]->end(len);
}
}
@ -304,7 +312,7 @@ void DivPlatformZXBeeper::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock/4;
for (int i=0; i<6; i++) {
oscBuf[i]->rate=rate;
oscBuf[i]->setRate(rate);
}
}

View file

@ -30,6 +30,10 @@ const char** DivPlatformZXBeeperQuadTone::getRegisterSheet() {
}
void DivPlatformZXBeeperQuadTone::acquire(short** buf, size_t len) {
for (int i=0; i<5; i++) {
oscBuf[i]->begin(len);
}
for (size_t h=0; h<len; h++) {
bool sampleActive=false;
if (curSample>=0 && curSample<parent->song.sampleLen) {
@ -51,12 +55,12 @@ void DivPlatformZXBeeperQuadTone::acquire(short** buf, size_t len) {
if (sampleActive) {
buf[0][h]=chan[4].out?32767:0;
if (outputClock==0) {
oscBuf[0]->data[oscBuf[0]->needle++]=0;
oscBuf[1]->data[oscBuf[1]->needle++]=0;
oscBuf[2]->data[oscBuf[2]->needle++]=0;
oscBuf[3]->data[oscBuf[3]->needle++]=0;
oscBuf[0]->putSample(h,0);
oscBuf[1]->putSample(h,0);
oscBuf[2]->putSample(h,0);
oscBuf[3]->putSample(h,0);
}
oscBuf[4]->data[oscBuf[4]->needle++]=buf[0][h];
oscBuf[4]->putSample(h,buf[0][h]);
} else {
int ch=outputClock/2;
int b=ch*4;
@ -72,7 +76,7 @@ void DivPlatformZXBeeperQuadTone::acquire(short** buf, size_t len) {
} else {
oscOut=16383;
}
oscBuf[ch]->data[oscBuf[ch]->needle++]=oscOut;
oscBuf[ch]->putSample(h,oscOut);
}
if (!isMuted[ch]) o=chan[ch].out&0x10;
if (noHiss) {
@ -85,10 +89,14 @@ void DivPlatformZXBeeperQuadTone::acquire(short** buf, size_t len) {
buf[0][h]=o?32767:0;
}
chan[ch].out<<=1;
oscBuf[4]->data[oscBuf[4]->needle++]=0;
oscBuf[4]->putSample(h,0);
}
outputClock=(outputClock+1)&7;
}
for (int i=0; i<5; i++) {
oscBuf[i]->end(len);
}
}
void DivPlatformZXBeeperQuadTone::tick(bool sysTick) {
@ -385,10 +393,9 @@ void DivPlatformZXBeeperQuadTone::setFlags(const DivConfig& flags) {
CHECK_CUSTOM_CLOCK;
rate=chipClock/40;
noHiss=flags.getBool("noHiss",false);
for (int i=0; i<4; i++) {
oscBuf[i]->rate=rate/8;
for (int i=0; i<5; i++) {
oscBuf[i]->setRate(rate);
}
oscBuf[4]->rate=rate;
}
void DivPlatformZXBeeperQuadTone::poke(unsigned int addr, unsigned short val) {