PC speaker: prepare for acquireDirect
This commit is contained in:
parent
231819da2e
commit
4b1e883d1b
|
|
@ -155,18 +155,22 @@ void DivDispatchContainer::grow(size_t size) {
|
|||
void DivDispatchContainer::acquire(size_t offset, size_t count) {
|
||||
CHECK_MISSING_BUFS;
|
||||
|
||||
for (int i=0; i<DIV_MAX_OUTPUTS; i++) {
|
||||
if (i>=outs) {
|
||||
bbInMapped[i]=NULL;
|
||||
} else {
|
||||
if (bbIn[i]==NULL) {
|
||||
if (dispatch->hasAcquireDirect()) {
|
||||
dispatch->acquireDirect(bb,offset,count);
|
||||
} else {
|
||||
for (int i=0; i<DIV_MAX_OUTPUTS; i++) {
|
||||
if (i>=outs) {
|
||||
bbInMapped[i]=NULL;
|
||||
} else {
|
||||
bbInMapped[i]=&bbIn[i][offset];
|
||||
if (bbIn[i]==NULL) {
|
||||
bbInMapped[i]=NULL;
|
||||
} else {
|
||||
bbInMapped[i]=&bbIn[i][offset];
|
||||
}
|
||||
}
|
||||
}
|
||||
dispatch->acquire(bbInMapped,count);
|
||||
}
|
||||
dispatch->acquire(bbInMapped,count);
|
||||
}
|
||||
|
||||
void DivDispatchContainer::flush(size_t count) {
|
||||
|
|
@ -181,35 +185,37 @@ void DivDispatchContainer::flush(size_t count) {
|
|||
void DivDispatchContainer::fillBuf(size_t runtotal, size_t offset, size_t size) {
|
||||
CHECK_MISSING_BUFS;
|
||||
|
||||
if (dcOffCompensation && runtotal>0) {
|
||||
dcOffCompensation=false;
|
||||
if (hiPass) {
|
||||
if (!dispatch->hasAcquireDirect()) {
|
||||
if (dcOffCompensation && runtotal>0) {
|
||||
dcOffCompensation=false;
|
||||
if (hiPass) {
|
||||
for (int i=0; i<outs; i++) {
|
||||
if (bbIn[i]==NULL) continue;
|
||||
prevSample[i]=bbIn[i][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lowQuality) {
|
||||
for (int i=0; i<outs; i++) {
|
||||
if (bbIn[i]==NULL) continue;
|
||||
prevSample[i]=bbIn[i][0];
|
||||
if (bb[i]==NULL) continue;
|
||||
for (size_t j=0; j<runtotal; j++) {
|
||||
if (bbIn[i][j]==temp[i]) continue;
|
||||
temp[i]=bbIn[i][j];
|
||||
blip_add_delta_fast(bb[i],j,temp[i]-prevSample[i]);
|
||||
prevSample[i]=temp[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lowQuality) {
|
||||
for (int i=0; i<outs; i++) {
|
||||
if (bbIn[i]==NULL) continue;
|
||||
if (bb[i]==NULL) continue;
|
||||
for (size_t j=0; j<runtotal; j++) {
|
||||
if (bbIn[i][j]==temp[i]) continue;
|
||||
temp[i]=bbIn[i][j];
|
||||
blip_add_delta_fast(bb[i],j,temp[i]-prevSample[i]);
|
||||
prevSample[i]=temp[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i=0; i<outs; i++) {
|
||||
if (bbIn[i]==NULL) continue;
|
||||
if (bb[i]==NULL) continue;
|
||||
for (size_t j=0; j<runtotal; j++) {
|
||||
if (bbIn[i][j]==temp[i]) continue;
|
||||
temp[i]=bbIn[i][j];
|
||||
blip_add_delta(bb[i],j,temp[i]-prevSample[i]);
|
||||
prevSample[i]=temp[i];
|
||||
} else {
|
||||
for (int i=0; i<outs; i++) {
|
||||
if (bbIn[i]==NULL) continue;
|
||||
if (bb[i]==NULL) continue;
|
||||
for (size_t j=0; j<runtotal; j++) {
|
||||
if (bbIn[i][j]==temp[i]) continue;
|
||||
temp[i]=bbIn[i][j];
|
||||
blip_add_delta(bb[i],j,temp[i]-prevSample[i]);
|
||||
prevSample[i]=temp[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,13 +293,15 @@ void DivPlatformPCSpeaker::beepFreq(int freq, int delay) {
|
|||
realOutCond.notify_one();
|
||||
}
|
||||
|
||||
void DivPlatformPCSpeaker::acquire_real(short** buf, size_t len) {
|
||||
void DivPlatformPCSpeaker::acquire_real(blip_buffer_t** bb, size_t off, size_t len) {
|
||||
int out=0;
|
||||
if (lastOn!=on || lastFreq!=freq) {
|
||||
lastOn=on;
|
||||
lastFreq=freq;
|
||||
beepFreq((on && !isMuted[0])?freq:0,parent->getBufferPos());
|
||||
}
|
||||
// TODO: direct chanOsc API!
|
||||
/*
|
||||
for (size_t i=0; i<len; i++) {
|
||||
if (on) {
|
||||
pos-=PCSPKR_DIVIDER;
|
||||
|
|
@ -316,8 +318,9 @@ void DivPlatformPCSpeaker::acquire_real(short** buf, size_t len) {
|
|||
} else {
|
||||
oscBuf->data[oscBuf->needle++]=0;
|
||||
}
|
||||
buf[0][i]=0;
|
||||
//buf[0][i]=0;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void DivPlatformPCSpeaker::acquire(short** buf, size_t len) {
|
||||
|
|
@ -331,8 +334,13 @@ void DivPlatformPCSpeaker::acquire(short** buf, size_t len) {
|
|||
case 2:
|
||||
acquire_piezo(buf,len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DivPlatformPCSpeaker::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) {
|
||||
switch (speakerType) {
|
||||
case 3:
|
||||
acquire_real(buf,len);
|
||||
acquire_real(bb,off,len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -598,6 +606,10 @@ bool DivPlatformPCSpeaker::keyOffAffectsArp(int ch) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool DivPlatformPCSpeaker::hasAcquireDirect() {
|
||||
return (speakerType==0 || speakerType==3);
|
||||
}
|
||||
|
||||
void DivPlatformPCSpeaker::setFlags(const DivConfig& flags) {
|
||||
switch (flags.getInt("clockSel",0)) {
|
||||
case 1: // PC-98
|
||||
|
|
|
|||
|
|
@ -70,10 +70,11 @@ class DivPlatformPCSpeaker: public DivDispatch {
|
|||
void acquire_unfilt(short** buf, size_t len);
|
||||
void acquire_cone(short** buf, size_t len);
|
||||
void acquire_piezo(short** buf, size_t len);
|
||||
void acquire_real(short** buf, size_t len);
|
||||
void acquire_real(blip_buffer_t** bb, size_t off, size_t len);
|
||||
|
||||
public:
|
||||
void pcSpeakerThread();
|
||||
void acquireDirect(blip_buffer_t** bb, size_t off, size_t len);
|
||||
void acquire(short** buf, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
|
|
@ -86,6 +87,7 @@ class DivPlatformPCSpeaker: public DivDispatch {
|
|||
void tick(bool sysTick=true);
|
||||
void muteChannel(int ch, bool mute);
|
||||
bool keyOffAffectsArp(int ch);
|
||||
bool hasAcquireDirect();
|
||||
void setFlags(const DivConfig& flags);
|
||||
void notifyInsDeletion(void* ins);
|
||||
void notifyPlaybackStop();
|
||||
|
|
|
|||
Loading…
Reference in a new issue