add a metronome
This commit is contained in:
parent
943e4e374f
commit
530a9bafc7
|
@ -2044,6 +2044,15 @@ void DivEngine::setView(DivStatusView which) {
|
|||
view=which;
|
||||
}
|
||||
|
||||
bool DivEngine::getMetronome() {
|
||||
return metronome;
|
||||
}
|
||||
|
||||
void DivEngine::setMetronome(bool enable) {
|
||||
metronome=enable;
|
||||
metroAmp=0;
|
||||
}
|
||||
|
||||
void DivEngine::setConsoleMode(bool enable) {
|
||||
consoleMode=enable;
|
||||
}
|
||||
|
|
|
@ -106,6 +106,7 @@ class DivEngine {
|
|||
bool consoleMode;
|
||||
bool extValuePresent;
|
||||
bool repeatPattern;
|
||||
bool metronome;
|
||||
int ticks, cycles, curRow, curOrder, remainingLoops, nextSpeed, clockDrift;
|
||||
int changeOrd, changePos, totalTicks, totalCmds, lastCmds, cmdsPerSecond, globalPitch;
|
||||
unsigned char extValue;
|
||||
|
@ -136,6 +137,10 @@ class DivEngine {
|
|||
int temp[3], prevSample[3];
|
||||
short* bbIn[3];
|
||||
short* bbOut[3];
|
||||
unsigned char* metroTick;
|
||||
size_t metroTickLen;
|
||||
int metroPeriod, metroPos;
|
||||
float metroAmp;
|
||||
|
||||
size_t totalProcessed;
|
||||
|
||||
|
@ -357,6 +362,12 @@ class DivEngine {
|
|||
// set the console mode.
|
||||
void setConsoleMode(bool enable);
|
||||
|
||||
// get metronome
|
||||
bool getMetronome();
|
||||
|
||||
// set metronome
|
||||
void setMetronome(bool enable);
|
||||
|
||||
// public render samples
|
||||
void renderSamplesP();
|
||||
|
||||
|
@ -390,6 +401,7 @@ class DivEngine {
|
|||
consoleMode(false),
|
||||
extValuePresent(false),
|
||||
repeatPattern(false),
|
||||
metronome(false),
|
||||
ticks(0),
|
||||
cycles(0),
|
||||
curRow(0),
|
||||
|
@ -411,6 +423,11 @@ class DivEngine {
|
|||
bbInLen(0),
|
||||
temp{0,0},
|
||||
prevSample{0,0},
|
||||
metroTick(NULL),
|
||||
metroTickLen(0),
|
||||
metroPeriod(0),
|
||||
metroPos(0),
|
||||
metroAmp(0.0f),
|
||||
totalProcessed(0),
|
||||
jediTable(NULL),
|
||||
adpcmMem(NULL) {}
|
||||
|
|
|
@ -882,6 +882,14 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
bbInLen=runtotal+256;
|
||||
}
|
||||
|
||||
if (metroTickLen<size) {
|
||||
if (metroTick!=NULL) delete[] metroTick;
|
||||
metroTick=new unsigned char[size];
|
||||
metroTickLen=size;
|
||||
}
|
||||
|
||||
memset(metroTick,0,size);
|
||||
|
||||
size_t runLeft=runtotal;
|
||||
size_t runPos=0;
|
||||
totalProcessed=0;
|
||||
|
@ -895,6 +903,14 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
runLeft-=cycles;
|
||||
dispatch->acquire(bbIn[0],bbIn[1],runPos,cycles);
|
||||
runPos+=cycles;
|
||||
unsigned int realPos=(runPos*size)/runtotal;
|
||||
if (realPos>=size) realPos=size-1;
|
||||
if (song.hilightA>0) {
|
||||
if ((curRow%song.hilightA)==0 && ticks==1) metroTick[realPos]=1;
|
||||
}
|
||||
if (song.hilightB>0) {
|
||||
if ((curRow%song.hilightB)==0 && ticks==1) metroTick[realPos]=2;
|
||||
}
|
||||
if (nextTick()) {
|
||||
if (remainingLoops>0) {
|
||||
remainingLoops--;
|
||||
|
@ -947,5 +963,24 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
out[1][i]+=(float)bbOut[0][i]/16384.0;
|
||||
}
|
||||
}
|
||||
|
||||
if (metronome) for (size_t i=0; i<size; i++) {
|
||||
if (metroTick[i]) {
|
||||
if (metroTick[i]==2) {
|
||||
metroPeriod=30;
|
||||
} else {
|
||||
metroPeriod=40;
|
||||
}
|
||||
metroPos=metroPeriod;
|
||||
metroAmp=0.5f;
|
||||
}
|
||||
out[0][i]+=(metroPos>(metroPeriod>>1))*metroAmp;
|
||||
out[1][i]+=(metroPos>(metroPeriod>>1))*metroAmp;
|
||||
metroAmp-=0.0002f;
|
||||
if (metroAmp<0.0f) metroAmp=0.0f;
|
||||
if (--metroPos<=0) {
|
||||
metroPos=metroPeriod;
|
||||
}
|
||||
}
|
||||
isBusy.unlock();
|
||||
}
|
||||
|
|
|
@ -273,6 +273,11 @@ void FurnaceGUI::drawEditControls() {
|
|||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox("Edit",&edit);
|
||||
ImGui::SameLine();
|
||||
bool metro=e->getMetronome();
|
||||
if (ImGui::Checkbox("Metronome",&metro)) {
|
||||
e->setMetronome(metro);
|
||||
}
|
||||
|
||||
ImGui::Text("Follow");
|
||||
ImGui::SameLine();
|
||||
|
|
Loading…
Reference in New Issue