Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable filter cutoff, resonance, and real-time parameter control #98

Merged
merged 2 commits into from
Apr 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Synth_Dexed.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ INCLUDE += -I $(CMSIS_DSP_INCLUDE_DIR)
INCLUDE += -I $(CMSIS_DSP_PRIVATE_INCLUDE_DIR)
INCLUDE += -I $(CMSIS_DSP_COMPUTELIB_INCLUDE_DIR)

DEFINE += -DUSE_FX

ifeq ($(strip $(AARCH)),64)
DEFINE += -DARM_MATH_NEON
DEFINE += -DHAVE_NEON
Expand Down
36 changes: 36 additions & 0 deletions src/minidexed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
m_nVolume[i] = 100;
m_nPan[i] = 64;
m_nMasterTune[i] = 0;
m_nCutoff[i] = 99;
m_nResonance[i] = 0;
m_nMIDIChannel[i] = CMIDIDevice::Disabled;

m_nNoteLimitLow[i] = 0;
Expand Down Expand Up @@ -181,6 +183,8 @@ bool CMiniDexed::Initialize (void)
SetVolume (m_PerformanceConfig.GetVolume (nTG), nTG);
SetPan (m_PerformanceConfig.GetPan (nTG), nTG);
SetMasterTune (m_PerformanceConfig.GetDetune (nTG), nTG);
SetCutoff (m_PerformanceConfig.GetCutoff (nTG), nTG);
SetResonance (m_PerformanceConfig.GetResonance (nTG), nTG);

m_nNoteLimitLow[nTG] = m_PerformanceConfig.GetNoteLimitLow (nTG);
m_nNoteLimitHigh[nTG] = m_PerformanceConfig.GetNoteLimitHigh (nTG);
Expand Down Expand Up @@ -402,6 +406,32 @@ void CMiniDexed::SetMasterTune (int nMasterTune, unsigned nTG)
m_UI.ParameterChanged ();
}

void CMiniDexed::SetCutoff (int nCutoff, unsigned nTG)
{
nCutoff = constrain (nCutoff, 0, 99);

assert (nTG < CConfig::ToneGenerators);
m_nCutoff[nTG] = nCutoff;

assert (m_pTG[nTG]);
m_pTG[nTG]->setFilterCutoff (mapfloat (nCutoff, 0, 99, 0.0f, 1.0f));

m_UI.ParameterChanged ();
}

void CMiniDexed::SetResonance (int nResonance, unsigned nTG)
{
nResonance = constrain (nResonance, 0, 99);

assert (nTG < CConfig::ToneGenerators);
m_nResonance[nTG] = nResonance;

assert (m_pTG[nTG]);
m_pTG[nTG]->setFilterResonance (mapfloat (nResonance, 0, 99, 0.0f, 1.0f));

m_UI.ParameterChanged ();
}

void CMiniDexed::SetMIDIChannel (uint8_t uchChannel, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
Expand Down Expand Up @@ -600,6 +630,8 @@ void CMiniDexed::SetTGParameter (TTGParameter Parameter, int nValue, unsigned nT
case TGParameterVolume: SetVolume (nValue, nTG); break;
case TGParameterPan: SetPan (nValue, nTG); break;
case TGParameterMasterTune: SetMasterTune (nValue, nTG); break;
case TGParameterCutoff: SetCutoff (nValue, nTG); break;
case TGParameterResonance: SetResonance (nValue, nTG); break;

case TGParameterMIDIChannel:
assert (0 <= nValue && nValue <= 255);
Expand All @@ -625,6 +657,8 @@ int CMiniDexed::GetTGParameter (TTGParameter Parameter, unsigned nTG)
case TGParameterVolume: return m_nVolume[nTG];
case TGParameterPan: return m_nPan[nTG];
case TGParameterMasterTune: return m_nMasterTune[nTG];
case TGParameterCutoff: return m_nCutoff[nTG];
case TGParameterResonance: return m_nResonance[nTG];
case TGParameterMIDIChannel: return m_nMIDIChannel[nTG];
case TGParameterReverbSend: return m_nReverbSend[nTG];

Expand Down Expand Up @@ -845,6 +879,8 @@ bool CMiniDexed::SavePerformance (void)
m_PerformanceConfig.SetVolume (m_nVolume[nTG], nTG);
m_PerformanceConfig.SetPan (m_nPan[nTG], nTG);
m_PerformanceConfig.SetDetune (m_nMasterTune[nTG], nTG);
m_PerformanceConfig.SetCutoff (m_nCutoff[nTG], nTG);
m_PerformanceConfig.SetResonance (m_nResonance[nTG], nTG);

m_PerformanceConfig.SetNoteLimitLow (m_nNoteLimitLow[nTG], nTG);
m_PerformanceConfig.SetNoteLimitHigh (m_nNoteLimitHigh[nTG], nTG);
Expand Down
6 changes: 6 additions & 0 deletions src/minidexed.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class CMiniDexed
void SetVolume (unsigned nVolume, unsigned nTG);
void SetPan (unsigned nPan, unsigned nTG); // 0 .. 127
void SetMasterTune (int nMasterTune, unsigned nTG); // -99 .. 99
void SetCutoff (int nCutoff, unsigned nTG); // 0 .. 99
void SetResonance (int nResonance, unsigned nTG); // 0 .. 99
void SetMIDIChannel (uint8_t uchChannel, unsigned nTG);

void keyup (int16_t pitch, unsigned nTG);
Expand Down Expand Up @@ -103,6 +105,8 @@ class CMiniDexed
TGParameterVolume,
TGParameterPan,
TGParameterMasterTune,
TGParameterCutoff,
TGParameterResonance,
TGParameterMIDIChannel,
TGParameterReverbSend,
TGParameterUnknown
Expand Down Expand Up @@ -148,6 +152,8 @@ class CMiniDexed
unsigned m_nVolume[CConfig::ToneGenerators];
unsigned m_nPan[CConfig::ToneGenerators];
int m_nMasterTune[CConfig::ToneGenerators];
int m_nCutoff[CConfig::ToneGenerators];
int m_nResonance[CConfig::ToneGenerators];
unsigned m_nMIDIChannel[CConfig::ToneGenerators];

unsigned m_nNoteLimitLow[CConfig::ToneGenerators];
Expand Down
18 changes: 18 additions & 0 deletions src/performance.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#Volume#=100 # 0 .. 127
#Pan#=64 # 0 .. 127
#Detune#=0 # -99 .. 99
#Cutoff#=99 # 0 .. 99
#Resonance#=0 # 0 .. 99
#NoteLimitLow#=0 # 0 .. 127, C-2 .. G8
#NoteLimitHigh#=127 # 0 .. 127, C-2 .. G8
#NoteShift#=0 # -24 .. 24
Expand All @@ -21,6 +23,8 @@ MIDIChannel1=255
Volume1=100
Pan1=0
Detune1=-11
Cutoff1=99
Resonance1=0
NoteLimitLow1=0
NoteLimitHigh1=127
NoteShift1=0
Expand All @@ -33,6 +37,8 @@ MIDIChannel2=255
Volume2=100
Pan2=127
Detune2=11
Cutoff2=99
Resonance2=0
NoteLimitLow2=0
NoteLimitHigh2=127
NoteShift2=0
Expand All @@ -45,6 +51,8 @@ MIDIChannel3=255
Volume3=100
Pan3=48
Detune3=-7
Cutoff3=99
Resonance3=0
NoteLimitLow3=0
NoteLimitHigh3=127
NoteShift3=0
Expand All @@ -57,6 +65,8 @@ MIDIChannel4=255
Volume4=100
Pan4=80
Detune4=7
Cutoff4=99
Resonance4=0
NoteLimitLow4=0
NoteLimitHigh4=127
NoteShift4=0
Expand All @@ -69,6 +79,8 @@ MIDIChannel5=0
Volume5=100
Pan5=64
Detune5=0
Cutoff5=99
Resonance5=0
NoteLimitLow5=0
NoteLimitHigh5=127
NoteShift5=0
Expand All @@ -81,6 +93,8 @@ MIDIChannel6=0
Volume6=100
Pan6=64
Detune6=0
Cutoff6=99
Resonance6=0
NoteLimitLow6=0
NoteLimitHigh6=127
NoteShift6=0
Expand All @@ -93,6 +107,8 @@ MIDIChannel7=0
Volume7=100
Pan7=64
Detune7=0
Cutoff7=99
Resonance7=0
NoteLimitLow7=0
NoteLimitHigh7=127
NoteShift7=0
Expand All @@ -105,6 +121,8 @@ MIDIChannel8=0
Volume8=100
Pan8=64
Detune8=0
Cutoff8=99
Resonance8=0
NoteLimitLow8=0
NoteLimitHigh8=127
NoteShift8=0
Expand Down
36 changes: 36 additions & 0 deletions src/performanceconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ bool CPerformanceConfig::Load (void)
PropertyName.Format ("Detune%u", nTG+1);
m_nDetune[nTG] = m_Properties.GetSignedNumber (PropertyName, 0);

PropertyName.Format ("Cutoff%u", nTG+1);
m_nCutoff[nTG] = m_Properties.GetNumber (PropertyName, 99);

PropertyName.Format ("Resonance%u", nTG+1);
m_nResonance[nTG] = m_Properties.GetNumber (PropertyName, 0);

PropertyName.Format ("NoteLimitLow%u", nTG+1);
m_nNoteLimitLow[nTG] = m_Properties.GetNumber (PropertyName, 0);

Expand Down Expand Up @@ -146,6 +152,12 @@ bool CPerformanceConfig::Save (void)
PropertyName.Format ("Detune%u", nTG+1);
m_Properties.SetSignedNumber (PropertyName, m_nDetune[nTG]);

PropertyName.Format ("Cutoff%u", nTG+1);
m_Properties.SetNumber (PropertyName, m_nCutoff[nTG]);

PropertyName.Format ("Resonance%u", nTG+1);
m_Properties.SetNumber (PropertyName, m_nResonance[nTG]);

PropertyName.Format ("NoteLimitLow%u", nTG+1);
m_Properties.SetNumber (PropertyName, m_nNoteLimitLow[nTG]);

Expand Down Expand Up @@ -208,6 +220,18 @@ int CPerformanceConfig::GetDetune (unsigned nTG) const
return m_nDetune[nTG];
}

unsigned CPerformanceConfig::GetCutoff (unsigned nTG) const
{
assert (nTG < CConfig::ToneGenerators);
return m_nCutoff[nTG];
}

unsigned CPerformanceConfig::GetResonance (unsigned nTG) const
{
assert (nTG < CConfig::ToneGenerators);
return m_nResonance[nTG];
}

unsigned CPerformanceConfig::GetNoteLimitLow (unsigned nTG) const
{
assert (nTG < CConfig::ToneGenerators);
Expand Down Expand Up @@ -268,6 +292,18 @@ void CPerformanceConfig::SetDetune (int nValue, unsigned nTG)
m_nDetune[nTG] = nValue;
}

void CPerformanceConfig::SetCutoff (unsigned nValue, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
m_nCutoff[nTG] = nValue;
}

void CPerformanceConfig::SetResonance (unsigned nValue, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
m_nResonance[nTG] = nValue;
}

void CPerformanceConfig::SetNoteLimitLow (unsigned nValue, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
Expand Down
6 changes: 6 additions & 0 deletions src/performanceconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class CPerformanceConfig // Performance configuration
unsigned GetVolume (unsigned nTG) const; // 0 .. 127
unsigned GetPan (unsigned nTG) const; // 0 .. 127
int GetDetune (unsigned nTG) const; // -99 .. 99
unsigned GetCutoff (unsigned nTG) const; // 0 .. 99
unsigned GetResonance (unsigned nTG) const; // 0 .. 99
unsigned GetNoteLimitLow (unsigned nTG) const; // 0 .. 127
unsigned GetNoteLimitHigh (unsigned nTG) const; // 0 .. 127
int GetNoteShift (unsigned nTG) const; // -24 .. 24
Expand All @@ -55,6 +57,8 @@ class CPerformanceConfig // Performance configuration
void SetVolume (unsigned nValue, unsigned nTG);
void SetPan (unsigned nValue, unsigned nTG);
void SetDetune (int nValue, unsigned nTG);
void SetCutoff (unsigned nValue, unsigned nTG);
void SetResonance (unsigned nValue, unsigned nTG);
void SetNoteLimitLow (unsigned nValue, unsigned nTG);
void SetNoteLimitHigh (unsigned nValue, unsigned nTG);
void SetNoteShift (int nValue, unsigned nTG);
Expand Down Expand Up @@ -88,6 +92,8 @@ class CPerformanceConfig // Performance configuration
unsigned m_nVolume[CConfig::ToneGenerators];
unsigned m_nPan[CConfig::ToneGenerators];
int m_nDetune[CConfig::ToneGenerators];
unsigned m_nCutoff[CConfig::ToneGenerators];
unsigned m_nResonance[CConfig::ToneGenerators];
unsigned m_nNoteLimitLow[CConfig::ToneGenerators];
unsigned m_nNoteLimitHigh[CConfig::ToneGenerators];
int m_nNoteShift[CConfig::ToneGenerators];
Expand Down
4 changes: 4 additions & 0 deletions src/uimenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const CUIMenu::TMenuItem CUIMenu::s_TGMenu[] =
#endif
{"Reverb-Send", EditTGParameter, 0, CMiniDexed::TGParameterReverbSend},
{"Detune", EditTGParameter, 0, CMiniDexed::TGParameterMasterTune},
{"Cutoff", EditTGParameter, 0, CMiniDexed::TGParameterCutoff},
{"Resonance", EditTGParameter, 0, CMiniDexed::TGParameterResonance},
{"Channel", EditTGParameter, 0, CMiniDexed::TGParameterMIDIChannel},
{"Edit Voice", MenuHandler, s_EditVoiceMenu},
{0}
Expand Down Expand Up @@ -179,6 +181,8 @@ const CUIMenu::TParameter CUIMenu::s_TGParameter[CMiniDexed::TGParameterUnknown]
{0, 127, 8, ToVolume}, // TGParameterVolume
{0, 127, 8, ToPan}, // TGParameterPan
{-99, 99, 1}, // TGParameterMasterTune
{0, 99, 1}, // TGParameterCutoff
{0, 99, 1}, // TGParameterResonance
{0, CMIDIDevice::ChannelUnknown-1, 1, ToMIDIChannel}, // TGParameterMIDIChannel
{0, 99, 1} // TGParameterReverbSend
};
Expand Down