update the acquireDirect API
size_t offset is no more - it is always 0
This commit is contained in:
parent
bc9dd4c2e7
commit
68a550a419
|
@ -653,10 +653,9 @@ class DivDispatch {
|
||||||
/**
|
/**
|
||||||
* fill a buffer with sound data (direct access to blip_buf).
|
* fill a buffer with sound data (direct access to blip_buf).
|
||||||
* @param bb pointers to blip_buf instances.
|
* @param bb pointers to blip_buf instances.
|
||||||
* @param the offset to the first sample (use this when calling blip_add_delta).
|
|
||||||
* @param len the amount of samples to fill.
|
* @param len the amount of samples to fill.
|
||||||
*/
|
*/
|
||||||
virtual void acquireDirect(blip_buffer_t** bb, size_t off, size_t len);
|
virtual void acquireDirect(blip_buffer_t** bb, size_t len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* post-process a rendered sound buffer.
|
* post-process a rendered sound buffer.
|
||||||
|
|
|
@ -152,11 +152,11 @@ void DivDispatchContainer::grow(size_t size) {
|
||||||
} \
|
} \
|
||||||
if (mustClear) clear(); \
|
if (mustClear) clear(); \
|
||||||
|
|
||||||
void DivDispatchContainer::acquire(size_t offset, size_t count) {
|
void DivDispatchContainer::acquire(size_t count) {
|
||||||
CHECK_MISSING_BUFS;
|
CHECK_MISSING_BUFS;
|
||||||
|
|
||||||
if (dispatch->hasAcquireDirect()) {
|
if (dispatch->hasAcquireDirect()) {
|
||||||
dispatch->acquireDirect(bb,offset,count);
|
dispatch->acquireDirect(bb,count);
|
||||||
} else {
|
} else {
|
||||||
for (int i=0; i<DIV_MAX_OUTPUTS; i++) {
|
for (int i=0; i<DIV_MAX_OUTPUTS; i++) {
|
||||||
if (i>=outs) {
|
if (i>=outs) {
|
||||||
|
@ -165,7 +165,7 @@ void DivDispatchContainer::acquire(size_t offset, size_t count) {
|
||||||
if (bbIn[i]==NULL) {
|
if (bbIn[i]==NULL) {
|
||||||
bbInMapped[i]=NULL;
|
bbInMapped[i]=NULL;
|
||||||
} else {
|
} else {
|
||||||
bbInMapped[i]=&bbIn[i][offset];
|
bbInMapped[i]=bbIn[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,7 +261,7 @@ struct DivDispatchContainer {
|
||||||
void setRates(double gotRate);
|
void setRates(double gotRate);
|
||||||
void setQuality(bool lowQual, bool dcHiPass);
|
void setQuality(bool lowQual, bool dcHiPass);
|
||||||
void grow(size_t size);
|
void grow(size_t size);
|
||||||
void acquire(size_t offset, size_t count);
|
void acquire(size_t count);
|
||||||
void flush(size_t offset, size_t count);
|
void flush(size_t offset, size_t count);
|
||||||
void fillBuf(size_t runtotal, size_t offset, size_t size);
|
void fillBuf(size_t runtotal, size_t offset, size_t size);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
void DivDispatch::acquire(short** buf, size_t len) {
|
void DivDispatch::acquire(short** buf, size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivDispatch::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) {
|
void DivDispatch::acquireDirect(blip_buffer_t** bb, size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivDispatch::fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len) {
|
void DivDispatch::fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len) {
|
||||||
|
|
|
@ -82,14 +82,13 @@ const char** DivPlatformAmiga::getRegisterSheet() {
|
||||||
void DivPlatformAmiga::acquire(short** buf, size_t len) {
|
void DivPlatformAmiga::acquire(short** buf, size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformAmiga::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) {
|
void DivPlatformAmiga::acquireDirect(blip_buffer_t** bb, size_t len) {
|
||||||
thread_local int outL, outR, output;
|
thread_local int outL, outR, output;
|
||||||
|
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<4; i++) {
|
||||||
oscBuf[i]->begin(len);
|
oscBuf[i]->begin(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t pos=off;
|
|
||||||
int runCount=1;
|
int runCount=1;
|
||||||
for (size_t h=0; h<len; h++) {
|
for (size_t h=0; h<len; h++) {
|
||||||
// skip heuristic
|
// skip heuristic
|
||||||
|
@ -119,7 +118,6 @@ void DivPlatformAmiga::acquireDirect(blip_buffer_t** bb, size_t off, size_t len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (runCount>0) {
|
if (runCount>0) {
|
||||||
pos+=runCount-1;
|
|
||||||
h+=runCount-1;
|
h+=runCount-1;
|
||||||
} else {
|
} else {
|
||||||
runCount=1;
|
runCount=1;
|
||||||
|
@ -234,15 +232,13 @@ void DivPlatformAmiga::acquireDirect(blip_buffer_t** bb, size_t off, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outL!=oldOut[0]) {
|
if (outL!=oldOut[0]) {
|
||||||
blip_add_delta(bb[0],pos,outL-oldOut[0]);
|
blip_add_delta(bb[0],h,outL-oldOut[0]);
|
||||||
oldOut[0]=outL;
|
oldOut[0]=outL;
|
||||||
}
|
}
|
||||||
if (outR!=oldOut[1]) {
|
if (outR!=oldOut[1]) {
|
||||||
blip_add_delta(bb[1],pos,outR-oldOut[1]);
|
blip_add_delta(bb[1],h,outR-oldOut[1]);
|
||||||
oldOut[1]=outR;
|
oldOut[1]=outR;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<4; i++) {
|
||||||
|
|
|
@ -139,7 +139,7 @@ class DivPlatformAmiga: public DivDispatch {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void acquire(short** buf, size_t len);
|
void acquire(short** buf, size_t len);
|
||||||
void acquireDirect(blip_buffer_t** bb, size_t off, size_t len);
|
void acquireDirect(blip_buffer_t** bb, size_t len);
|
||||||
void postProcess(short* buf, int outIndex, size_t len, int sampleRate);
|
void postProcess(short* buf, int outIndex, size_t len, int sampleRate);
|
||||||
int dispatch(DivCommand c);
|
int dispatch(DivCommand c);
|
||||||
void* getChanState(int chan);
|
void* getChanState(int chan);
|
||||||
|
|
|
@ -66,13 +66,12 @@ void DivPlatformESFM::acquire(short** buf, size_t len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformESFM::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) {
|
void DivPlatformESFM::acquireDirect(blip_buffer_t** bb, size_t len) {
|
||||||
thread_local short o[2];
|
thread_local short o[2];
|
||||||
unsigned int sharedNeedlePos=oscBuf[0]->needle;
|
unsigned int sharedNeedlePos=oscBuf[0]->needle;
|
||||||
for (int i=0; i<18; i++) {
|
for (int i=0; i<18; i++) {
|
||||||
oscBuf[i]->begin(len);
|
oscBuf[i]->begin(len);
|
||||||
}
|
}
|
||||||
size_t pos=off;
|
|
||||||
for (size_t h=0; h<len; h++) {
|
for (size_t h=0; h<len; h++) {
|
||||||
if (!writes.empty()) {
|
if (!writes.empty()) {
|
||||||
QueuedWrite& w=writes.front();
|
QueuedWrite& w=writes.front();
|
||||||
|
@ -91,15 +90,13 @@ void DivPlatformESFM::acquireDirect(blip_buffer_t** bb, size_t off, size_t len)
|
||||||
sharedNeedlePos+=oscBuf[0]->rateMul;
|
sharedNeedlePos+=oscBuf[0]->rateMul;
|
||||||
|
|
||||||
if (o[0]!=oldOut[0]) {
|
if (o[0]!=oldOut[0]) {
|
||||||
blip_add_delta(bb[0],pos,oldOut[0]-o[0]);
|
blip_add_delta(bb[0],h,oldOut[0]-o[0]);
|
||||||
oldOut[0]=o[0];
|
oldOut[0]=o[0];
|
||||||
}
|
}
|
||||||
if (o[1]!=oldOut[1]) {
|
if (o[1]!=oldOut[1]) {
|
||||||
blip_add_delta(bb[1],pos,oldOut[1]-o[1]);
|
blip_add_delta(bb[1],h,oldOut[1]-o[1]);
|
||||||
oldOut[1]=o[1];
|
oldOut[1]=o[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
pos++;
|
|
||||||
}
|
}
|
||||||
for (int i=0; i<18; i++) {
|
for (int i=0; i<18; i++) {
|
||||||
oscBuf[i]->end(len);
|
oscBuf[i]->end(len);
|
||||||
|
|
|
@ -181,7 +181,7 @@ class DivPlatformESFM: public DivDispatch {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void acquire(short** buf, size_t len);
|
void acquire(short** buf, size_t len);
|
||||||
void acquireDirect(blip_buffer_t** bb, size_t off, size_t len);
|
void acquireDirect(blip_buffer_t** bb, size_t len);
|
||||||
int dispatch(DivCommand c);
|
int dispatch(DivCommand c);
|
||||||
void* getChanState(int chan);
|
void* getChanState(int chan);
|
||||||
DivMacroInt* getChanMacroInt(int ch);
|
DivMacroInt* getChanMacroInt(int ch);
|
||||||
|
|
|
@ -77,7 +77,7 @@ void DivPlatformGA20::acquire(short** buf, size_t len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformGA20::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) {
|
void DivPlatformGA20::acquireDirect(blip_buffer_t** bb, size_t len) {
|
||||||
thread_local short ga20Buf[4];
|
thread_local short ga20Buf[4];
|
||||||
|
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<4; i++) {
|
||||||
|
@ -109,7 +109,7 @@ void DivPlatformGA20::acquireDirect(blip_buffer_t** bb, size_t off, size_t len)
|
||||||
h+=advance;
|
h+=advance;
|
||||||
const int out=(signed int)(ga20Buf[0]+ga20Buf[1]+ga20Buf[2]+ga20Buf[3])>>2;
|
const int out=(signed int)(ga20Buf[0]+ga20Buf[1]+ga20Buf[2]+ga20Buf[3])>>2;
|
||||||
if (out!=oldOut) {
|
if (out!=oldOut) {
|
||||||
blip_add_delta(bb[0],off+h,out-oldOut);
|
blip_add_delta(bb[0],h,out-oldOut);
|
||||||
oldOut=out;
|
oldOut=out;
|
||||||
}
|
}
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<4; i++) {
|
||||||
|
|
|
@ -74,7 +74,7 @@ class DivPlatformGA20: public DivDispatch, public iremga20_intf {
|
||||||
void chWrite(unsigned char ch, unsigned int addr, unsigned char val);
|
void chWrite(unsigned char ch, unsigned int addr, unsigned char val);
|
||||||
public:
|
public:
|
||||||
virtual u8 read_byte(u32 address) override;
|
virtual u8 read_byte(u32 address) override;
|
||||||
virtual void acquireDirect(blip_buffer_t** bb, size_t off, size_t len) override;
|
virtual void acquireDirect(blip_buffer_t** bb, size_t len) override;
|
||||||
virtual void acquire(short** buf, size_t len) override;
|
virtual void acquire(short** buf, size_t len) override;
|
||||||
virtual int dispatch(DivCommand c) override;
|
virtual int dispatch(DivCommand c) override;
|
||||||
virtual void* getChanState(int chan) override;
|
virtual void* getChanState(int chan) override;
|
||||||
|
|
|
@ -57,7 +57,7 @@ const char** DivPlatformPCE::getRegisterSheet() {
|
||||||
void DivPlatformPCE::acquire(short** buf, size_t len) {
|
void DivPlatformPCE::acquire(short** buf, size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformPCE::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) {
|
void DivPlatformPCE::acquireDirect(blip_buffer_t** bb, size_t len) {
|
||||||
for (int i=0; i<6; i++) {
|
for (int i=0; i<6; i++) {
|
||||||
oscBuf[i]->begin(len);
|
oscBuf[i]->begin(len);
|
||||||
pce->channel[i].oscBuf=oscBuf[i];
|
pce->channel[i].oscBuf=oscBuf[i];
|
||||||
|
@ -66,7 +66,7 @@ void DivPlatformPCE::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) {
|
||||||
pce->bb[0]=bb[0];
|
pce->bb[0]=bb[0];
|
||||||
pce->bb[1]=bb[1];
|
pce->bb[1]=bb[1];
|
||||||
|
|
||||||
size_t pos=off;
|
size_t pos=0;
|
||||||
pce->ResetTS(pos);
|
pce->ResetTS(pos);
|
||||||
|
|
||||||
while (!writes.empty()) {
|
while (!writes.empty()) {
|
||||||
|
|
|
@ -79,7 +79,7 @@ class DivPlatformPCE: public DivDispatch {
|
||||||
friend void putDispatchChan(void*,int,int);
|
friend void putDispatchChan(void*,int,int);
|
||||||
public:
|
public:
|
||||||
void acquire(short** buf, size_t len);
|
void acquire(short** buf, size_t len);
|
||||||
void acquireDirect(blip_buffer_t** bb, size_t off, size_t len);
|
void acquireDirect(blip_buffer_t** bb, size_t len);
|
||||||
int dispatch(DivCommand c);
|
int dispatch(DivCommand c);
|
||||||
void* getChanState(int chan);
|
void* getChanState(int chan);
|
||||||
DivMacroInt* getChanMacroInt(int ch);
|
DivMacroInt* getChanMacroInt(int ch);
|
||||||
|
|
|
@ -192,7 +192,7 @@ const char** DivPlatformPCSpeaker::getRegisterSheet() {
|
||||||
return regCheatSheetPCSpeaker;
|
return regCheatSheetPCSpeaker;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformPCSpeaker::acquire_unfilt(blip_buffer_t** bb, size_t off, size_t len) {
|
void DivPlatformPCSpeaker::acquire_unfilt(blip_buffer_t** bb, size_t len) {
|
||||||
int out=0;
|
int out=0;
|
||||||
int freq1=freq+1;
|
int freq1=freq+1;
|
||||||
int timeToNextToggle=0;
|
int timeToNextToggle=0;
|
||||||
|
@ -210,12 +210,11 @@ void DivPlatformPCSpeaker::acquire_unfilt(blip_buffer_t** bb, size_t off, size_t
|
||||||
timeToNextToggle=pos;
|
timeToNextToggle=pos;
|
||||||
}
|
}
|
||||||
out=(posToggle && !isMuted[0])?32767:0;
|
out=(posToggle && !isMuted[0])?32767:0;
|
||||||
blip_add_delta(bb[0],off,out-oldOut);
|
blip_add_delta(bb[0],0,out-oldOut);
|
||||||
oscBuf->putSample(0,out);
|
oscBuf->putSample(0,out);
|
||||||
oldOut=out;
|
oldOut=out;
|
||||||
if (freq>=1) {
|
if (freq>=1) {
|
||||||
size_t boff=off;
|
size_t boff=0;
|
||||||
size_t oscOff=0;
|
|
||||||
size_t i=len;
|
size_t i=len;
|
||||||
while (true) {
|
while (true) {
|
||||||
if ((int)i<timeToNextToggle) {
|
if ((int)i<timeToNextToggle) {
|
||||||
|
@ -224,7 +223,6 @@ void DivPlatformPCSpeaker::acquire_unfilt(blip_buffer_t** bb, size_t off, size_t
|
||||||
}
|
}
|
||||||
i-=timeToNextToggle;
|
i-=timeToNextToggle;
|
||||||
boff+=timeToNextToggle;
|
boff+=timeToNextToggle;
|
||||||
oscOff+=timeToNextToggle;
|
|
||||||
pos-=timeToNextToggle;
|
pos-=timeToNextToggle;
|
||||||
if (pos<=0) {
|
if (pos<=0) {
|
||||||
pos=freq1;
|
pos=freq1;
|
||||||
|
@ -238,13 +236,13 @@ void DivPlatformPCSpeaker::acquire_unfilt(blip_buffer_t** bb, size_t off, size_t
|
||||||
}
|
}
|
||||||
out=(posToggle && !isMuted[0])?32767:0;
|
out=(posToggle && !isMuted[0])?32767:0;
|
||||||
blip_add_delta(bb[0],boff,out-oldOut);
|
blip_add_delta(bb[0],boff,out-oldOut);
|
||||||
oscBuf->putSample(oscOff,out);
|
oscBuf->putSample(boff,out);
|
||||||
oldOut=out;
|
oldOut=out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
out=0;
|
out=0;
|
||||||
blip_add_delta(bb[0],off,out-oldOut);
|
blip_add_delta(bb[0],0,out-oldOut);
|
||||||
oscBuf->putSample(0,out);
|
oscBuf->putSample(0,out);
|
||||||
oldOut=out;
|
oldOut=out;
|
||||||
}
|
}
|
||||||
|
@ -333,7 +331,7 @@ void DivPlatformPCSpeaker::beepFreq(int freq, int delay) {
|
||||||
realOutCond.notify_one();
|
realOutCond.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformPCSpeaker::acquire_real(blip_buffer_t** bb, size_t off, size_t len) {
|
void DivPlatformPCSpeaker::acquire_real(blip_buffer_t** bb, size_t len) {
|
||||||
//int out=0;
|
//int out=0;
|
||||||
if (lastOn!=on || lastFreq!=freq) {
|
if (lastOn!=on || lastFreq!=freq) {
|
||||||
lastOn=on;
|
lastOn=on;
|
||||||
|
@ -372,13 +370,13 @@ void DivPlatformPCSpeaker::acquire(short** buf, size_t len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformPCSpeaker::acquireDirect(blip_buffer_t** bb, size_t off, size_t len) {
|
void DivPlatformPCSpeaker::acquireDirect(blip_buffer_t** bb, size_t len) {
|
||||||
switch (speakerType) {
|
switch (speakerType) {
|
||||||
case 0:
|
case 0:
|
||||||
acquire_unfilt(bb,off,len);
|
acquire_unfilt(bb,len);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
acquire_real(bb,off,len);
|
acquire_real(bb,len);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,14 +67,14 @@ class DivPlatformPCSpeaker: public DivDispatch {
|
||||||
|
|
||||||
void beepFreq(int freq, int delay=0);
|
void beepFreq(int freq, int delay=0);
|
||||||
|
|
||||||
void acquire_unfilt(blip_buffer_t** bb, size_t off, size_t len);
|
void acquire_unfilt(blip_buffer_t** bb, size_t len);
|
||||||
void acquire_cone(short** buf, size_t len);
|
void acquire_cone(short** buf, size_t len);
|
||||||
void acquire_piezo(short** buf, size_t len);
|
void acquire_piezo(short** buf, size_t len);
|
||||||
void acquire_real(blip_buffer_t** bb, size_t off, size_t len);
|
void acquire_real(blip_buffer_t** bb, size_t len);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void pcSpeakerThread();
|
void pcSpeakerThread();
|
||||||
void acquireDirect(blip_buffer_t** bb, size_t off, size_t len);
|
void acquireDirect(blip_buffer_t** bb, size_t len);
|
||||||
void acquire(short** buf, size_t len);
|
void acquire(short** buf, size_t len);
|
||||||
int dispatch(DivCommand c);
|
int dispatch(DivCommand c);
|
||||||
void* getChanState(int chan);
|
void* getChanState(int chan);
|
||||||
|
|
|
@ -2510,7 +2510,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
||||||
logD("growing dispatch %p bbIn to %d",(void*)dc,total+256);
|
logD("growing dispatch %p bbIn to %d",(void*)dc,total+256);
|
||||||
dc->grow(total+256);
|
dc->grow(total+256);
|
||||||
}
|
}
|
||||||
dc->acquire(0,total);
|
dc->acquire(total);
|
||||||
dc->fillBuf(total,dc->runPos,dc->cycles);
|
dc->fillBuf(total,dc->runPos,dc->cycles);
|
||||||
dc->runPos+=dc->cycles;
|
dc->runPos+=dc->cycles;
|
||||||
},&disCont[i]);
|
},&disCont[i]);
|
||||||
|
@ -2544,7 +2544,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
||||||
logD("growing dispatch %p bbIn to %d",(void*)dc,total+256);
|
logD("growing dispatch %p bbIn to %d",(void*)dc,total+256);
|
||||||
dc->grow(total+256);
|
dc->grow(total+256);
|
||||||
}
|
}
|
||||||
dc->acquire(0,total);
|
dc->acquire(total);
|
||||||
dc->fillBuf(total,dc->runPos,dc->cycles);
|
dc->fillBuf(total,dc->runPos,dc->cycles);
|
||||||
},&disCont[i]);
|
},&disCont[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue