make patchbay effective on samplepreview/metronome
This commit is contained in:
parent
9d327cacd8
commit
01f6e8f963
|
@ -4436,6 +4436,9 @@ bool DivEngine::init() {
|
||||||
samp_bbIn=new short[32768];
|
samp_bbIn=new short[32768];
|
||||||
samp_bbInLen=32768;
|
samp_bbInLen=32768;
|
||||||
|
|
||||||
|
metroBuf=new float[8192];
|
||||||
|
metroBufLen=8192;
|
||||||
|
|
||||||
blip_set_rates(samp_bb,44100,got.rate);
|
blip_set_rates(samp_bb,44100,got.rate);
|
||||||
|
|
||||||
for (int i=0; i<64; i++) {
|
for (int i=0; i<64; i++) {
|
||||||
|
@ -4480,6 +4483,11 @@ bool DivEngine::quit() {
|
||||||
for (int i=0; i<DIV_MAX_OUTPUTS; i++) {
|
for (int i=0; i<DIV_MAX_OUTPUTS; i++) {
|
||||||
if (oscBuf[i]!=NULL) delete[] oscBuf[i];
|
if (oscBuf[i]!=NULL) delete[] oscBuf[i];
|
||||||
}
|
}
|
||||||
|
if (metroBuf!=NULL) {
|
||||||
|
delete[] metroBuf;
|
||||||
|
metroBuf=NULL;
|
||||||
|
metroBufLen=0;
|
||||||
|
}
|
||||||
if (yrw801ROM!=NULL) delete[] yrw801ROM;
|
if (yrw801ROM!=NULL) delete[] yrw801ROM;
|
||||||
if (tg100ROM!=NULL) delete[] tg100ROM;
|
if (tg100ROM!=NULL) delete[] tg100ROM;
|
||||||
if (mu5ROM!=NULL) delete[] mu5ROM;
|
if (mu5ROM!=NULL) delete[] mu5ROM;
|
||||||
|
|
|
@ -427,6 +427,8 @@ class DivEngine {
|
||||||
short* samp_bbOut;
|
short* samp_bbOut;
|
||||||
unsigned char* metroTick;
|
unsigned char* metroTick;
|
||||||
size_t metroTickLen;
|
size_t metroTickLen;
|
||||||
|
float* metroBuf;
|
||||||
|
size_t metroBufLen;
|
||||||
float metroFreq, metroPos;
|
float metroFreq, metroPos;
|
||||||
float metroAmp;
|
float metroAmp;
|
||||||
float metroVol;
|
float metroVol;
|
||||||
|
@ -1129,6 +1131,8 @@ class DivEngine {
|
||||||
samp_bbOut(NULL),
|
samp_bbOut(NULL),
|
||||||
metroTick(NULL),
|
metroTick(NULL),
|
||||||
metroTickLen(0),
|
metroTickLen(0),
|
||||||
|
metroBuf(NULL),
|
||||||
|
metroBufLen(0),
|
||||||
metroFreq(0),
|
metroFreq(0),
|
||||||
metroPos(0),
|
metroPos(0),
|
||||||
metroAmp(0.0f),
|
metroAmp(0.0f),
|
||||||
|
|
|
@ -1453,7 +1453,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
||||||
}
|
}
|
||||||
|
|
||||||
// process audio
|
// process audio
|
||||||
if (out!=NULL && ((sPreview.sample>=0 && sPreview.sample<(int)song.sample.size()) || (sPreview.wave>=0 && sPreview.wave<(int)song.wave.size()))) {
|
if ((sPreview.sample>=0 && sPreview.sample<(int)song.sample.size()) || (sPreview.wave>=0 && sPreview.wave<(int)song.wave.size())) {
|
||||||
unsigned int samp_bbOff=0;
|
unsigned int samp_bbOff=0;
|
||||||
unsigned int prevAvail=blip_samples_avail(samp_bb);
|
unsigned int prevAvail=blip_samples_avail(samp_bb);
|
||||||
if (prevAvail>size) prevAvail=size;
|
if (prevAvail>size) prevAvail=size;
|
||||||
|
@ -1590,28 +1590,11 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
||||||
|
|
||||||
blip_end_frame(samp_bb,prevtotal);
|
blip_end_frame(samp_bb,prevtotal);
|
||||||
blip_read_samples(samp_bb,samp_bbOut+samp_bbOff,size-samp_bbOff,0);
|
blip_read_samples(samp_bb,samp_bbOut+samp_bbOff,size-samp_bbOff,0);
|
||||||
for (size_t i=0; i<size; i++) {
|
} else {
|
||||||
for (int j=0; j<outChans; j++) {
|
memset(samp_bbOut,0,size*sizeof(short));
|
||||||
out[j][i]+=(float)samp_bbOut[i]/32768.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!playing) {
|
|
||||||
if (out!=NULL) {
|
|
||||||
for (unsigned int i=0; i<size; i++) {
|
|
||||||
for (int j=0; j<outChans; j++) {
|
|
||||||
if (oscBuf[j]==NULL) continue;
|
|
||||||
oscBuf[j][oscWritePos]=out[j][i];
|
|
||||||
}
|
|
||||||
if (++oscWritePos>=32768) oscWritePos=0;
|
|
||||||
}
|
|
||||||
oscSize=size;
|
|
||||||
}
|
|
||||||
isBusy.unlock();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (playing && !halted) {
|
||||||
// logic starts here
|
// logic starts here
|
||||||
for (int i=0; i<song.systemLen; i++) {
|
for (int i=0; i<song.systemLen; i++) {
|
||||||
// TODO: we may have a problem here
|
// TODO: we may have a problem here
|
||||||
|
@ -1698,11 +1681,6 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (out==NULL || halted) {
|
|
||||||
isBusy.unlock();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//logD("attempts: %d",attempts);
|
//logD("attempts: %d",attempts);
|
||||||
if (attempts>=(int)size) {
|
if (attempts>=(int)size) {
|
||||||
logE("hang detected! stopping! at %d seconds %d micro",totalSeconds,totalTicks);
|
logE("hang detected! stopping! at %d seconds %d micro",totalSeconds,totalTicks);
|
||||||
|
@ -1719,6 +1697,38 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
||||||
}
|
}
|
||||||
disCont[i].fillBuf(disCont[i].runtotal,disCont[i].lastAvail,size-disCont[i].lastAvail);
|
disCont[i].fillBuf(disCont[i].runtotal,disCont[i].lastAvail,size-disCont[i].lastAvail);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (metroBufLen<size || metroBuf==NULL) {
|
||||||
|
if (metroBuf!=NULL) delete[] metroBuf;
|
||||||
|
metroBuf=new float[size];
|
||||||
|
metroBufLen=size;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(metroBuf,0,metroBufLen*sizeof(float));
|
||||||
|
|
||||||
|
if (playing && !halted && metronome) {
|
||||||
|
for (size_t i=0; i<size; i++) {
|
||||||
|
if (metroTick[i]) {
|
||||||
|
if (metroTick[i]==2) {
|
||||||
|
metroFreq=1400/got.rate;
|
||||||
|
} else {
|
||||||
|
metroFreq=1050/got.rate;
|
||||||
|
}
|
||||||
|
metroPos=0;
|
||||||
|
metroAmp=0.7f;
|
||||||
|
}
|
||||||
|
if (metroAmp>0.0f) {
|
||||||
|
for (int j=0; j<outChans; j++) {
|
||||||
|
metroBuf[i]=(sin(metroPos*2*M_PI))*metroAmp*metroVol;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
metroAmp-=0.0003f;
|
||||||
|
if (metroAmp<0.0f) metroAmp=0.0f;
|
||||||
|
metroPos+=metroFreq;
|
||||||
|
while (metroPos>=1) metroPos--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// resolve patchbay
|
// resolve patchbay
|
||||||
for (unsigned int i: song.patchbay) {
|
for (unsigned int i: song.patchbay) {
|
||||||
|
@ -1738,7 +1748,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
||||||
if (destSubPort>=outChans) continue;
|
if (destSubPort>=outChans) continue;
|
||||||
|
|
||||||
// chip outputs
|
// chip outputs
|
||||||
if (srcPortSet<song.systemLen) {
|
if (srcPortSet<song.systemLen && playing && !halted) {
|
||||||
if (srcSubPort<disCont[srcPortSet].dispatch->getOutputCount()) {
|
if (srcSubPort<disCont[srcPortSet].dispatch->getOutputCount()) {
|
||||||
float vol=song.systemVol[srcPortSet]*disCont[srcPortSet].dispatch->getPostAmp()*song.masterVol;
|
float vol=song.systemVol[srcPortSet]*disCont[srcPortSet].dispatch->getPostAmp()*song.masterVol;
|
||||||
|
|
||||||
|
@ -1761,6 +1771,16 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
||||||
out[destSubPort][j]+=((float)disCont[srcPortSet].bbOut[srcSubPort][j]/32768.0)*vol;
|
out[destSubPort][j]+=((float)disCont[srcPortSet].bbOut[srcSubPort][j]/32768.0)*vol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (srcPortSet==0xffd) {
|
||||||
|
// sample preview
|
||||||
|
for (size_t j=0; j<size; j++) {
|
||||||
|
out[destSubPort][j]+=samp_bbOut[j]/32768.0;
|
||||||
|
}
|
||||||
|
} else if (srcPortSet==0xffe && playing && !halted) {
|
||||||
|
// metronome
|
||||||
|
for (size_t j=0; j<size; j++) {
|
||||||
|
out[destSubPort][j]+=metroBuf[j];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nothing/invalid
|
// nothing/invalid
|
||||||
|
@ -1769,27 +1789,6 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
||||||
// nothing/invalid
|
// nothing/invalid
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metronome) for (size_t i=0; i<size; i++) {
|
|
||||||
if (metroTick[i]) {
|
|
||||||
if (metroTick[i]==2) {
|
|
||||||
metroFreq=1400/got.rate;
|
|
||||||
} else {
|
|
||||||
metroFreq=1050/got.rate;
|
|
||||||
}
|
|
||||||
metroPos=0;
|
|
||||||
metroAmp=0.7f;
|
|
||||||
}
|
|
||||||
if (metroAmp>0.0f) {
|
|
||||||
for (int j=0; j<outChans; j++) {
|
|
||||||
out[j][i]+=(sin(metroPos*2*M_PI))*metroAmp*metroVol;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
metroAmp-=0.0003f;
|
|
||||||
if (metroAmp<0.0f) metroAmp=0.0f;
|
|
||||||
metroPos+=metroFreq;
|
|
||||||
while (metroPos>=1) metroPos--;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int i=0; i<size; i++) {
|
for (unsigned int i=0; i<size; i++) {
|
||||||
for (int j=0; j<outChans; j++) {
|
for (int j=0; j<outChans; j++) {
|
||||||
if (oscBuf[j]==NULL) continue;
|
if (oscBuf[j]==NULL) continue;
|
||||||
|
|
Loading…
Reference in a new issue