PC speaker: prepare for acquireDirect

This commit is contained in:
tildearrow 2025-02-25 18:53:02 -05:00
parent 231819da2e
commit 4b1e883d1b
3 changed files with 57 additions and 37 deletions

View file

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

View file

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