mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-24 05:25:12 +00:00
GUI: wave generator, part 6
FM now with feedback!
This commit is contained in:
parent
0c8cde9f85
commit
9a3c81d90a
3 changed files with 34 additions and 9 deletions
|
@ -5235,9 +5235,15 @@ FurnaceGUI::FurnaceGUI():
|
||||||
|
|
||||||
memset(waveGenAmp,0,sizeof(float)*16);
|
memset(waveGenAmp,0,sizeof(float)*16);
|
||||||
memset(waveGenPhase,0,sizeof(float)*16);
|
memset(waveGenPhase,0,sizeof(float)*16);
|
||||||
memset(waveGenTL,0,sizeof(float)*4);
|
waveGenTL[0]=0.0f;
|
||||||
memset(waveGenMult,0,sizeof(int)*4);
|
waveGenTL[1]=0.0f;
|
||||||
memset(waveGenFB,0,sizeof(float)*4);
|
waveGenTL[2]=0.0f;
|
||||||
|
waveGenTL[3]=1.0f;
|
||||||
|
waveGenMult[0]=1;
|
||||||
|
waveGenMult[1]=1;
|
||||||
|
waveGenMult[2]=1;
|
||||||
|
waveGenMult[3]=1;
|
||||||
|
memset(waveGenFB,0,sizeof(int)*4);
|
||||||
memset(waveGenFMCon1,0,sizeof(bool)*4);
|
memset(waveGenFMCon1,0,sizeof(bool)*4);
|
||||||
memset(waveGenFMCon2,0,sizeof(bool)*3);
|
memset(waveGenFMCon2,0,sizeof(bool)*3);
|
||||||
memset(waveGenFMCon3,0,sizeof(bool)*2);
|
memset(waveGenFMCon3,0,sizeof(bool)*2);
|
||||||
|
|
|
@ -1566,7 +1566,7 @@ class FurnaceGUI {
|
||||||
float waveGenPhase[16];
|
float waveGenPhase[16];
|
||||||
float waveGenTL[4];
|
float waveGenTL[4];
|
||||||
int waveGenMult[4];
|
int waveGenMult[4];
|
||||||
float waveGenFB[4];
|
int waveGenFB[4];
|
||||||
bool waveGenFMCon1[4];
|
bool waveGenFMCon1[4];
|
||||||
bool waveGenFMCon2[3];
|
bool waveGenFMCon2[3];
|
||||||
bool waveGenFMCon3[2];
|
bool waveGenFMCon3[2];
|
||||||
|
|
|
@ -61,12 +61,31 @@ void FurnaceGUI::doGenerateWave() {
|
||||||
if (wave->len<2) return;
|
if (wave->len<2) return;
|
||||||
|
|
||||||
if (waveGenFM) {
|
if (waveGenFM) {
|
||||||
|
float s0fb0=0;
|
||||||
|
float s0fb1=0;
|
||||||
|
float s1fb0=0;
|
||||||
|
float s1fb1=0;
|
||||||
|
float s2fb0=0;
|
||||||
|
float s2fb1=0;
|
||||||
|
float s3fb0=0;
|
||||||
|
float s3fb1=0;
|
||||||
for (int i=0; i<wave->len; i++) {
|
for (int i=0; i<wave->len; i++) {
|
||||||
float pos=(float)i/(float)wave->len;
|
float pos=(float)i/(float)wave->len;
|
||||||
float s0=sin(pos*multFactors[waveGenMult[0]])*waveGenTL[0];
|
float s0=sin((pos+(waveGenFB[0]?((s0fb0+s0fb1)*pow(2.0f,waveGenFB[0]-8)):0.0f))*multFactors[waveGenMult[0]])*waveGenTL[0];
|
||||||
float s1=sin((pos+(waveGenFMCon1[0]?s0:0.0f))*multFactors[waveGenMult[1]])*waveGenTL[1];
|
s0fb0=s0fb1;
|
||||||
float s2=sin((pos+(waveGenFMCon1[1]?s0:0.0f)+(waveGenFMCon2[0]?s1:0.0f))*multFactors[waveGenMult[2]])*waveGenTL[2];
|
s0fb1=s0;
|
||||||
float s3=sin((pos+(waveGenFMCon1[2]?s0:0.0f)+(waveGenFMCon2[1]?s1:0.0f)+(waveGenFMCon3[0]?s2:0.0f))*multFactors[waveGenMult[3]])*waveGenTL[3];
|
|
||||||
|
float s1=sin((pos+(waveGenFB[1]?((s1fb0+s1fb1)*pow(2.0f,waveGenFB[1]-8)):0.0f)+(waveGenFMCon1[0]?s0:0.0f))*multFactors[waveGenMult[1]])*waveGenTL[1];
|
||||||
|
s1fb0=s1fb1;
|
||||||
|
s1fb1=s1;
|
||||||
|
|
||||||
|
float s2=sin((pos+(waveGenFB[2]?((s2fb0+s2fb1)*pow(2.0f,waveGenFB[2]-8)):0.0f)+(waveGenFMCon1[1]?s0:0.0f)+(waveGenFMCon2[0]?s1:0.0f))*multFactors[waveGenMult[2]])*waveGenTL[2];
|
||||||
|
s2fb0=s2fb1;
|
||||||
|
s2fb1=s2;
|
||||||
|
|
||||||
|
float s3=sin((pos+(waveGenFB[3]?((s3fb0+s3fb1)*pow(2.0f,waveGenFB[3]-8)):0.0f)+(waveGenFMCon1[2]?s0:0.0f)+(waveGenFMCon2[1]?s1:0.0f)+(waveGenFMCon3[0]?s2:0.0f))*multFactors[waveGenMult[3]])*waveGenTL[3];
|
||||||
|
s3fb0=s3fb1;
|
||||||
|
s3fb1=s3;
|
||||||
|
|
||||||
if (waveGenFMCon1[3]) finalResult[i]+=s0;
|
if (waveGenFMCon1[3]) finalResult[i]+=s0;
|
||||||
if (waveGenFMCon2[2]) finalResult[i]+=s1;
|
if (waveGenFMCon2[2]) finalResult[i]+=s1;
|
||||||
|
@ -394,7 +413,7 @@ void FurnaceGUI::drawWaveEdit() {
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||||
ImGui::PushID(i);
|
ImGui::PushID(i);
|
||||||
if (CWSliderFloat("##WGFB",&waveGenFB[i],0.0f,7.0f)) {
|
if (CWSliderInt("##WGFB",&waveGenFB[i],0,7)) {
|
||||||
doGenerateWave();
|
doGenerateWave();
|
||||||
}
|
}
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
|
|
Loading…
Reference in a new issue