Compare commits
3 Commits
2ca5856800
...
c99899a002
Author | SHA1 | Date |
---|---|---|
tildearrow | c99899a002 | |
tildearrow | 55eeb241cf | |
tildearrow | ad7b4f61b5 |
|
@ -454,10 +454,11 @@ void DivEngine::registerSystems() {
|
||||||
{0x18, {DIV_CMD_FM_EXTCH, "18xx: Toggle extended channel 3 mode"}},
|
{0x18, {DIV_CMD_FM_EXTCH, "18xx: Toggle extended channel 3 mode"}},
|
||||||
});
|
});
|
||||||
|
|
||||||
EffectHandlerMap fmOPN2EffectHandlerMap={
|
EffectHandlerMap fmOPN2EffectHandlerMap(fmEffectHandlerMap);
|
||||||
|
fmOPN2EffectHandlerMap.insert({
|
||||||
{0x17, {DIV_CMD_SAMPLE_MODE, "17xx: Toggle PCM mode (LEGACY)"}},
|
{0x17, {DIV_CMD_SAMPLE_MODE, "17xx: Toggle PCM mode (LEGACY)"}},
|
||||||
{0xdf, {DIV_CMD_SAMPLE_DIR, "DFxx: Set sample playback direction (0: normal; 1: reverse)"}},
|
{0xdf, {DIV_CMD_SAMPLE_DIR, "DFxx: Set sample playback direction (0: normal; 1: reverse)"}},
|
||||||
};
|
});
|
||||||
|
|
||||||
EffectHandlerMap fmOPLDrumsEffectHandlerMap(fmEffectHandlerMap);
|
EffectHandlerMap fmOPLDrumsEffectHandlerMap(fmEffectHandlerMap);
|
||||||
fmOPLDrumsEffectHandlerMap.insert({
|
fmOPLDrumsEffectHandlerMap.insert({
|
||||||
|
|
|
@ -363,10 +363,11 @@ void FurnaceGUI::drawChanOsc() {
|
||||||
std::vector<int> oscChans;
|
std::vector<int> oscChans;
|
||||||
int chans=e->getTotalChannelCount();
|
int chans=e->getTotalChannelCount();
|
||||||
ImGuiWindow* window=ImGui::GetCurrentWindow();
|
ImGuiWindow* window=ImGui::GetCurrentWindow();
|
||||||
ImVec2 waveform[512];
|
|
||||||
|
|
||||||
ImGuiStyle& style=ImGui::GetStyle();
|
ImGuiStyle& style=ImGui::GetStyle();
|
||||||
|
ImVec2 waveform[1024];
|
||||||
|
|
||||||
|
// fill buffers
|
||||||
for (int i=0; i<chans; i++) {
|
for (int i=0; i<chans; i++) {
|
||||||
DivDispatchOscBuffer* buf=e->getOscBuffer(i);
|
DivDispatchOscBuffer* buf=e->getOscBuffer(i);
|
||||||
if (buf!=NULL && e->curSubSong->chanShow[i]) {
|
if (buf!=NULL && e->curSubSong->chanShow[i]) {
|
||||||
|
@ -376,6 +377,140 @@ void FurnaceGUI::drawChanOsc() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// process
|
||||||
|
for (size_t i=0; i<oscBufs.size(); i++) {
|
||||||
|
DivDispatchOscBuffer* buf=oscBufs[i];
|
||||||
|
ChanOscStatus* fft=oscFFTs[i];
|
||||||
|
int ch=oscChans[i];
|
||||||
|
|
||||||
|
if (buf!=NULL) {
|
||||||
|
// prepare
|
||||||
|
if (centerSettingReset) {
|
||||||
|
buf->readNeedle=buf->needle;
|
||||||
|
}
|
||||||
|
|
||||||
|
int displaySize=(float)(buf->rate)*(chanOscWindowSize/1000.0f);
|
||||||
|
|
||||||
|
// check FFT status existence
|
||||||
|
if (!fft->ready) {
|
||||||
|
logD("creating FFT plan for channel %d",ch);
|
||||||
|
fft->inBuf=(double*)fftw_malloc(FURNACE_FFT_SIZE*sizeof(double));
|
||||||
|
fft->outBuf=(fftw_complex*)fftw_malloc(FURNACE_FFT_SIZE*sizeof(fftw_complex));
|
||||||
|
fft->corrBuf=(double*)fftw_malloc(FURNACE_FFT_SIZE*sizeof(double));
|
||||||
|
fft->plan=fftw_plan_dft_r2c_1d(FURNACE_FFT_SIZE,fft->inBuf,fft->outBuf,FFTW_ESTIMATE);
|
||||||
|
fft->planI=fftw_plan_dft_c2r_1d(FURNACE_FFT_SIZE,fft->outBuf,fft->corrBuf,FFTW_ESTIMATE);
|
||||||
|
if (fft->plan==NULL) {
|
||||||
|
logE("failed to create plan!");
|
||||||
|
} else if (fft->planI==NULL) {
|
||||||
|
logE("failed to create inverse plan!");
|
||||||
|
} else if (fft->inBuf==NULL || fft->outBuf==NULL || fft->corrBuf==NULL) {
|
||||||
|
logE("failed to create FFT buffers");
|
||||||
|
} else {
|
||||||
|
fft->ready=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fft->ready && e->isRunning()) {
|
||||||
|
// the STRATEGY
|
||||||
|
// 1. FFT of windowed signal
|
||||||
|
// 2. inverse FFT of auto-correlation
|
||||||
|
// 3. find size of one period
|
||||||
|
// 4. DFT of the fundamental of ONE PERIOD
|
||||||
|
// 5. now we can get phase information
|
||||||
|
//
|
||||||
|
// I have a feeling this could be simplified to two FFTs or even one...
|
||||||
|
// if you know how, please tell me
|
||||||
|
|
||||||
|
// initialization
|
||||||
|
double phase=0.0;
|
||||||
|
fft->loudEnough=false;
|
||||||
|
fft->needle=buf->needle;
|
||||||
|
|
||||||
|
// first FFT
|
||||||
|
for (int j=0; j<FURNACE_FFT_SIZE; j++) {
|
||||||
|
fft->inBuf[j]=(double)buf->data[(unsigned short)(fft->needle-displaySize*2+((j*displaySize*2)/(FURNACE_FFT_SIZE)))]/32768.0;
|
||||||
|
if (fft->inBuf[j]>0.001 || fft->inBuf[j]<-0.001) fft->loudEnough=true;
|
||||||
|
fft->inBuf[j]*=0.55-0.45*cos(M_PI*(double)j/(double)(FURNACE_FFT_SIZE>>1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// only proceed if not quiet
|
||||||
|
if (fft->loudEnough) {
|
||||||
|
fftw_execute(fft->plan);
|
||||||
|
|
||||||
|
// auto-correlation and second FFT
|
||||||
|
for (int j=0; j<FURNACE_FFT_SIZE; j++) {
|
||||||
|
fft->outBuf[j][0]/=FURNACE_FFT_SIZE;
|
||||||
|
fft->outBuf[j][1]/=FURNACE_FFT_SIZE;
|
||||||
|
fft->outBuf[j][0]=fft->outBuf[j][0]*fft->outBuf[j][0]+fft->outBuf[j][1]*fft->outBuf[j][1];
|
||||||
|
fft->outBuf[j][1]=0;
|
||||||
|
}
|
||||||
|
fft->outBuf[0][0]=0;
|
||||||
|
fft->outBuf[0][1]=0;
|
||||||
|
fft->outBuf[1][0]=0;
|
||||||
|
fft->outBuf[1][1]=0;
|
||||||
|
fftw_execute(fft->planI);
|
||||||
|
|
||||||
|
// window
|
||||||
|
for (int j=0; j<(FURNACE_FFT_SIZE>>1); j++) {
|
||||||
|
fft->corrBuf[j]*=1.0-((double)j/(double)(FURNACE_FFT_SIZE<<1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// find size of period
|
||||||
|
double waveLenCandL=DBL_MAX;
|
||||||
|
double waveLenCandH=DBL_MIN;
|
||||||
|
fft->waveLen=FURNACE_FFT_SIZE-1;
|
||||||
|
fft->waveLenBottom=0;
|
||||||
|
fft->waveLenTop=0;
|
||||||
|
|
||||||
|
// find lowest point
|
||||||
|
for (int j=(FURNACE_FFT_SIZE>>2); j>2; j--) {
|
||||||
|
if (fft->corrBuf[j]<waveLenCandL) {
|
||||||
|
waveLenCandL=fft->corrBuf[j];
|
||||||
|
fft->waveLenBottom=j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find highest point
|
||||||
|
for (int j=(FURNACE_FFT_SIZE>>1)-1; j>fft->waveLenBottom; j--) {
|
||||||
|
if (fft->corrBuf[j]>waveLenCandH) {
|
||||||
|
waveLenCandH=fft->corrBuf[j];
|
||||||
|
fft->waveLen=j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fft->waveLenTop=fft->waveLen;
|
||||||
|
|
||||||
|
// did we find the period size?
|
||||||
|
if (fft->waveLen<(FURNACE_FFT_SIZE-32)) {
|
||||||
|
// we got pitch
|
||||||
|
chanOscPitch[ch]=pow(1.0-(fft->waveLen/(double)(FURNACE_FFT_SIZE>>1)),4.0);
|
||||||
|
|
||||||
|
fft->waveLen*=(double)displaySize*2.0/(double)FURNACE_FFT_SIZE;
|
||||||
|
|
||||||
|
// DFT of one period (x_1)
|
||||||
|
double dft[2];
|
||||||
|
dft[0]=0.0;
|
||||||
|
dft[1]=0.0;
|
||||||
|
for (int j=fft->needle-1-(displaySize>>1)-(int)fft->waveLen, k=0; k<fft->waveLen; j++, k++) {
|
||||||
|
double one=((double)buf->data[j&0xffff]/32768.0);
|
||||||
|
double two=(double)k*(-2.0*M_PI)/fft->waveLen;
|
||||||
|
dft[0]+=one*cos(two);
|
||||||
|
dft[1]+=one*sin(two);
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate and lock into phase
|
||||||
|
phase=(0.5+(atan2(dft[1],dft[0])/(2.0*M_PI)));
|
||||||
|
|
||||||
|
if (chanOscWaveCorr) {
|
||||||
|
fft->needle-=phase*fft->waveLen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fft->needle-=displaySize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 0: none
|
// 0: none
|
||||||
// 1: sqrt(chans)
|
// 1: sqrt(chans)
|
||||||
// 2: sqrt(chans+1)
|
// 2: sqrt(chans+1)
|
||||||
|
@ -396,6 +531,7 @@ void FurnaceGUI::drawChanOsc() {
|
||||||
|
|
||||||
int rows=(oscBufs.size()+(chanOscCols-1))/chanOscCols;
|
int rows=(oscBufs.size()+(chanOscCols-1))/chanOscCols;
|
||||||
|
|
||||||
|
// render
|
||||||
for (size_t i=0; i<oscBufs.size(); i++) {
|
for (size_t i=0; i<oscBufs.size(); i++) {
|
||||||
if (i%chanOscCols==0) ImGui::TableNextRow();
|
if (i%chanOscCols==0) ImGui::TableNextRow();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
@ -409,31 +545,6 @@ void FurnaceGUI::drawChanOsc() {
|
||||||
ImVec2 size=ImGui::GetContentRegionAvail();
|
ImVec2 size=ImGui::GetContentRegionAvail();
|
||||||
size.y=availY/rows;
|
size.y=availY/rows;
|
||||||
|
|
||||||
if (centerSettingReset) {
|
|
||||||
buf->readNeedle=buf->needle;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check FFT status existence
|
|
||||||
if (fft->plan==NULL) {
|
|
||||||
logD("creating FFT plan for channel %d",ch);
|
|
||||||
fft->inBuf=(double*)fftw_malloc(FURNACE_FFT_SIZE*sizeof(double));
|
|
||||||
fft->outBuf=(fftw_complex*)fftw_malloc(FURNACE_FFT_SIZE*sizeof(fftw_complex));
|
|
||||||
fft->corrBuf=(double*)fftw_malloc(FURNACE_FFT_SIZE*sizeof(double));
|
|
||||||
fft->plan=fftw_plan_dft_r2c_1d(FURNACE_FFT_SIZE,fft->inBuf,fft->outBuf,FFTW_ESTIMATE);
|
|
||||||
fft->planI=fftw_plan_dft_c2r_1d(FURNACE_FFT_SIZE,fft->outBuf,fft->corrBuf,FFTW_ESTIMATE);
|
|
||||||
if (fft->plan==NULL) {
|
|
||||||
logE("failed to create plan!");
|
|
||||||
}
|
|
||||||
if (fft->planI==NULL) {
|
|
||||||
logE("failed to create inverse plan!");
|
|
||||||
}
|
|
||||||
if (fft->inBuf==NULL || fft->outBuf==NULL || fft->corrBuf==NULL) {
|
|
||||||
logE("failed to create FFT buffers");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int displaySize=(float)(buf->rate)*(chanOscWindowSize/1000.0f);
|
|
||||||
|
|
||||||
ImVec2 minArea=window->DC.CursorPos;
|
ImVec2 minArea=window->DC.CursorPos;
|
||||||
ImVec2 maxArea=ImVec2(
|
ImVec2 maxArea=ImVec2(
|
||||||
minArea.x+size.x,
|
minArea.x+size.x,
|
||||||
|
@ -448,7 +559,7 @@ void FurnaceGUI::drawChanOsc() {
|
||||||
|
|
||||||
int precision=inRect.Max.x-inRect.Min.x;
|
int precision=inRect.Max.x-inRect.Min.x;
|
||||||
if (precision<1) precision=1;
|
if (precision<1) precision=1;
|
||||||
if (precision>512) precision=512;
|
if (precision>1024) precision=1024;
|
||||||
|
|
||||||
ImGui::ItemSize(size,style.FramePadding.y);
|
ImGui::ItemSize(size,style.FramePadding.y);
|
||||||
if (ImGui::ItemAdd(rect,ImGui::GetID("chOscDisplay"))) {
|
if (ImGui::ItemAdd(rect,ImGui::GetID("chOscDisplay"))) {
|
||||||
|
@ -458,154 +569,61 @@ void FurnaceGUI::drawChanOsc() {
|
||||||
waveform[j]=ImLerp(inRect.Min,inRect.Max,ImVec2(x,0.5f));
|
waveform[j]=ImLerp(inRect.Min,inRect.Max,ImVec2(x,0.5f));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// the STRATEGY
|
int displaySize=(float)(buf->rate)*(chanOscWindowSize/1000.0f);
|
||||||
// 1. FFT of windowed signal
|
|
||||||
// 2. inverse FFT of auto-correlation
|
|
||||||
// 3. find size of one period
|
|
||||||
// 4. DFT of the fundamental of ONE PERIOD
|
|
||||||
// 5. now we can get phase information
|
|
||||||
//
|
|
||||||
// I have a feeling this could be simplified to two FFTs or even one...
|
|
||||||
// if you know how, please tell me
|
|
||||||
|
|
||||||
// initialization
|
|
||||||
double phase=0.0;
|
|
||||||
float minLevel=1.0f;
|
float minLevel=1.0f;
|
||||||
float maxLevel=-1.0f;
|
float maxLevel=-1.0f;
|
||||||
float dcOff=0.0f;
|
float dcOff=0.0f;
|
||||||
unsigned short needlePos=buf->needle;
|
|
||||||
bool loudEnough=false;
|
|
||||||
|
|
||||||
// first FFT
|
|
||||||
for (int j=0; j<FURNACE_FFT_SIZE; j++) {
|
|
||||||
fft->inBuf[j]=(double)buf->data[(unsigned short)(needlePos-displaySize*2+((j*displaySize*2)/(FURNACE_FFT_SIZE)))]/32768.0;
|
|
||||||
if (fft->inBuf[j]>0.001 || fft->inBuf[j]<-0.001) loudEnough=true;
|
|
||||||
fft->inBuf[j]*=0.55-0.45*cos(M_PI*(double)j/(double)(FURNACE_FFT_SIZE>>1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// only proceed if not quiet
|
|
||||||
if (loudEnough) {
|
|
||||||
fftw_execute(fft->plan);
|
|
||||||
|
|
||||||
// auto-correlation and second FFT
|
|
||||||
for (int j=0; j<FURNACE_FFT_SIZE; j++) {
|
|
||||||
fft->outBuf[j][0]/=FURNACE_FFT_SIZE;
|
|
||||||
fft->outBuf[j][1]/=FURNACE_FFT_SIZE;
|
|
||||||
fft->outBuf[j][0]=fft->outBuf[j][0]*fft->outBuf[j][0]+fft->outBuf[j][1]*fft->outBuf[j][1];
|
|
||||||
fft->outBuf[j][1]=0;
|
|
||||||
}
|
|
||||||
fft->outBuf[0][0]=0;
|
|
||||||
fft->outBuf[0][1]=0;
|
|
||||||
fft->outBuf[1][0]=0;
|
|
||||||
fft->outBuf[1][1]=0;
|
|
||||||
fftw_execute(fft->planI);
|
|
||||||
|
|
||||||
// window
|
|
||||||
for (int j=0; j<(FURNACE_FFT_SIZE>>1); j++) {
|
|
||||||
fft->corrBuf[j]*=1.0-((double)j/(double)(FURNACE_FFT_SIZE<<1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// find size of period
|
|
||||||
double waveLen=FURNACE_FFT_SIZE-1;
|
|
||||||
double waveLenCandL=DBL_MAX;
|
|
||||||
double waveLenCandH=DBL_MIN;
|
|
||||||
int waveLenBottom=0;
|
|
||||||
int waveLenTop=0;
|
|
||||||
|
|
||||||
// find lowest point
|
|
||||||
for (int j=(FURNACE_FFT_SIZE>>2); j>2; j--) {
|
|
||||||
if (fft->corrBuf[j]<waveLenCandL) {
|
|
||||||
waveLenCandL=fft->corrBuf[j];
|
|
||||||
waveLenBottom=j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// find highest point
|
|
||||||
for (int j=(FURNACE_FFT_SIZE>>1)-1; j>waveLenBottom; j--) {
|
|
||||||
if (fft->corrBuf[j]>waveLenCandH) {
|
|
||||||
waveLenCandH=fft->corrBuf[j];
|
|
||||||
waveLen=j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
waveLenTop=waveLen;
|
|
||||||
|
|
||||||
// did we find the period size?
|
|
||||||
if (waveLen<(FURNACE_FFT_SIZE-32)) {
|
|
||||||
// we got pitch
|
|
||||||
chanOscPitch[ch]=pow(1.0-(waveLen/(double)(FURNACE_FFT_SIZE>>1)),4.0);
|
|
||||||
|
|
||||||
waveLen*=(double)displaySize*2.0/(double)FURNACE_FFT_SIZE;
|
|
||||||
|
|
||||||
// DFT of one period (x_1)
|
|
||||||
double dft[2];
|
|
||||||
dft[0]=0.0;
|
|
||||||
dft[1]=0.0;
|
|
||||||
for (int j=needlePos-1-(displaySize>>1)-(int)waveLen, k=0; k<waveLen; j++, k++) {
|
|
||||||
double one=((double)buf->data[j&0xffff]/32768.0);
|
|
||||||
double two=(double)k*(-2.0*M_PI)/waveLen;
|
|
||||||
dft[0]+=one*cos(two);
|
|
||||||
dft[1]+=one*sin(two);
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate and lock into phase
|
|
||||||
phase=(0.5+(atan2(dft[1],dft[0])/(2.0*M_PI)));
|
|
||||||
|
|
||||||
if (chanOscWaveCorr) {
|
|
||||||
needlePos-=phase*waveLen;
|
|
||||||
//needlePos-=(2*waveLen-fmod(displaySize,waveLen*2))*0.5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (debugFFT) {
|
||||||
// FFT debug code!
|
// FFT debug code!
|
||||||
if (debugFFT) {
|
double maxavg=0.0;
|
||||||
double maxavg=0.0;
|
for (unsigned short j=0; j<(FURNACE_FFT_SIZE>>1); j++) {
|
||||||
for (unsigned short j=0; j<(FURNACE_FFT_SIZE>>1); j++) {
|
if (fabs(fft->corrBuf[j]>maxavg)) {
|
||||||
if (fabs(fft->corrBuf[j]>maxavg)) {
|
maxavg=fabs(fft->corrBuf[j]);
|
||||||
maxavg=fabs(fft->corrBuf[j]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (maxavg>0.0000001) maxavg=0.5/maxavg;
|
}
|
||||||
|
if (maxavg>0.0000001) maxavg=0.5/maxavg;
|
||||||
|
|
||||||
for (unsigned short j=0; j<precision; j++) {
|
for (unsigned short j=0; j<precision; j++) {
|
||||||
float x=(float)j/(float)precision;
|
float x=(float)j/(float)precision;
|
||||||
float y=fft->corrBuf[(j*FURNACE_FFT_SIZE)/precision]*maxavg;
|
float y;
|
||||||
if (j>=precision/2) {
|
if (j>=precision/2) {
|
||||||
y=fft->inBuf[((j-(precision/2))*FURNACE_FFT_SIZE*2)/(precision)];
|
y=fft->inBuf[((j-(precision/2))*FURNACE_FFT_SIZE*2)/(precision)];
|
||||||
}
|
} else {
|
||||||
|
y=fft->corrBuf[(j*FURNACE_FFT_SIZE)/precision]*maxavg;
|
||||||
waveform[j]=ImLerp(inRect.Min,inRect.Max,ImVec2(x,0.5f-y));
|
|
||||||
}
|
}
|
||||||
String cPhase=fmt::sprintf("\n%.1f (b: %d t: %d)",waveLen,waveLenBottom,waveLenTop);
|
waveform[j]=ImLerp(inRect.Min,inRect.Max,ImVec2(x,0.5f-y));
|
||||||
|
}
|
||||||
|
if (fft->loudEnough) {
|
||||||
|
String cPhase=fmt::sprintf("\n%.1f (b: %d t: %d)",fft->waveLen,fft->waveLenBottom,fft->waveLenTop);
|
||||||
dl->AddText(inRect.Min,0xffffffff,cPhase.c_str());
|
dl->AddText(inRect.Min,0xffffffff,cPhase.c_str());
|
||||||
|
|
||||||
dl->AddLine(
|
dl->AddLine(
|
||||||
ImLerp(inRect.Min,inRect.Max,ImVec2((double)waveLenBottom/(double)FURNACE_FFT_SIZE,0.0)),
|
ImLerp(inRect.Min,inRect.Max,ImVec2((double)fft->waveLenBottom/(double)FURNACE_FFT_SIZE,0.0)),
|
||||||
ImLerp(inRect.Min,inRect.Max,ImVec2((double)waveLenBottom/(double)FURNACE_FFT_SIZE,1.0)),
|
ImLerp(inRect.Min,inRect.Max,ImVec2((double)fft->waveLenBottom/(double)FURNACE_FFT_SIZE,1.0)),
|
||||||
0xffffff00
|
0xffffff00
|
||||||
);
|
);
|
||||||
dl->AddLine(
|
dl->AddLine(
|
||||||
ImLerp(inRect.Min,inRect.Max,ImVec2((double)waveLenTop/(double)FURNACE_FFT_SIZE,0.0)),
|
ImLerp(inRect.Min,inRect.Max,ImVec2((double)fft->waveLenTop/(double)FURNACE_FFT_SIZE,0.0)),
|
||||||
ImLerp(inRect.Min,inRect.Max,ImVec2((double)waveLenTop/(double)FURNACE_FFT_SIZE,1.0)),
|
ImLerp(inRect.Min,inRect.Max,ImVec2((double)fft->waveLenTop/(double)FURNACE_FFT_SIZE,1.0)),
|
||||||
0xff00ff00
|
0xff00ff00
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
if (debugFFT) {
|
||||||
|
dl->AddText(inRect.Min,0xffffffff,"\nquiet");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (debugFFT) {
|
|
||||||
dl->AddText(inRect.Min,0xffffffff,"\nquiet");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!debugFFT || !loudEnough) {
|
|
||||||
needlePos-=displaySize;
|
|
||||||
for (unsigned short j=0; j<precision; j++) {
|
for (unsigned short j=0; j<precision; j++) {
|
||||||
float y=(float)buf->data[(unsigned short)(needlePos+(j*displaySize/precision))]/32768.0f;
|
float y=(float)buf->data[(unsigned short)(fft->needle+(j*displaySize/precision))]/32768.0f;
|
||||||
if (minLevel>y) minLevel=y;
|
if (minLevel>y) minLevel=y;
|
||||||
if (maxLevel<y) maxLevel=y;
|
if (maxLevel<y) maxLevel=y;
|
||||||
}
|
}
|
||||||
dcOff=(minLevel+maxLevel)*0.5f;
|
dcOff=(minLevel+maxLevel)*0.5f;
|
||||||
for (unsigned short j=0; j<precision; j++) {
|
for (unsigned short j=0; j<precision; j++) {
|
||||||
float x=(float)j/(float)precision;
|
float x=(float)j/(float)precision;
|
||||||
float y=(float)buf->data[(unsigned short)(needlePos+(j*displaySize/precision))]/32768.0f;
|
float y=(float)buf->data[(unsigned short)(fft->needle+(j*displaySize/precision))]/32768.0f;
|
||||||
y-=dcOff;
|
y-=dcOff;
|
||||||
if (y<-0.5f) y=-0.5f;
|
if (y<-0.5f) y=-0.5f;
|
||||||
if (y>0.5f) y=0.5f;
|
if (y>0.5f) y=0.5f;
|
||||||
|
|
|
@ -2056,20 +2056,28 @@ class FurnaceGUI {
|
||||||
unsigned short lastCorrPos[DIV_MAX_CHANS];
|
unsigned short lastCorrPos[DIV_MAX_CHANS];
|
||||||
struct ChanOscStatus {
|
struct ChanOscStatus {
|
||||||
double* inBuf;
|
double* inBuf;
|
||||||
size_t inBufPos;
|
|
||||||
double inBufPosFrac;
|
|
||||||
unsigned short needle;
|
|
||||||
fftw_complex* outBuf;
|
fftw_complex* outBuf;
|
||||||
double* corrBuf;
|
double* corrBuf;
|
||||||
|
size_t inBufPos;
|
||||||
|
double inBufPosFrac;
|
||||||
|
double waveLen;
|
||||||
|
int waveLenBottom, waveLenTop;
|
||||||
|
unsigned short needle;
|
||||||
|
bool ready, loudEnough;
|
||||||
fftw_plan plan;
|
fftw_plan plan;
|
||||||
fftw_plan planI;
|
fftw_plan planI;
|
||||||
ChanOscStatus():
|
ChanOscStatus():
|
||||||
inBuf(NULL),
|
inBuf(NULL),
|
||||||
inBufPos(0),
|
|
||||||
inBufPosFrac(0.0f),
|
|
||||||
needle(0),
|
|
||||||
outBuf(NULL),
|
outBuf(NULL),
|
||||||
corrBuf(NULL),
|
corrBuf(NULL),
|
||||||
|
inBufPos(0),
|
||||||
|
inBufPosFrac(0.0f),
|
||||||
|
waveLen(0.0),
|
||||||
|
waveLenBottom(0),
|
||||||
|
waveLenTop(0),
|
||||||
|
needle(0),
|
||||||
|
ready(false),
|
||||||
|
loudEnough(false),
|
||||||
plan(NULL),
|
plan(NULL),
|
||||||
planI(NULL) {}
|
planI(NULL) {}
|
||||||
} chanOscChan[DIV_MAX_CHANS];
|
} chanOscChan[DIV_MAX_CHANS];
|
||||||
|
|
Loading…
Reference in New Issue