diff --git a/Synth_Dexed b/Synth_Dexed index 8c677ceb4..a02b5c0bf 160000 --- a/Synth_Dexed +++ b/Synth_Dexed @@ -1 +1 @@ -Subproject commit 8c677ceb4b3fb73f8643e30ff6cf4158dc8b9e53 +Subproject commit a02b5c0bf2da132f49a923f9c69796220a8ea93f diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 257ef55ce..256b8558f 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -60,6 +60,7 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt, m_GetChunkTimer ("GetChunk", 1000000U * pConfig->GetChunkSize ()/2 / pConfig->GetSampleRate ()), m_bProfileEnabled (m_pConfig->GetProfileEnabled ()), + m_Limiter {pConfig->GetSampleRate(), pConfig->GetSampleRate()}, m_pNet(nullptr), m_pNetDevice(nullptr), m_WLAN(nullptr), @@ -116,6 +117,13 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt, m_nReverbSend[i] = 0; + m_bCompressorEnable[i] = 1; + m_nCompressorPreGain[i] = 0; + m_nCompressorAttack[i] = 5; + m_nCompressorRelease[i] = 200; + m_nCompressorThresh[i] = -20; + m_nCompressorRatio[i] = 5; + // Active the required number of active TGs if (iGetPerformanceSelectChannel()); @@ -1004,14 +1018,6 @@ void CMiniDexed::SetParameter (TParameter Parameter, int nValue) switch (Parameter) { - case ParameterCompressorEnable: - for (unsigned nTG = 0; nTG < m_nToneGenerators; nTG++) - { - assert (m_pTG[nTG]); - m_pTG[nTG]->setCompressor (!!nValue); - } - break; - case ParameterReverbEnable: nValue=constrain((int)nValue,0,1); m_ReverbSpinLock.Acquire (); @@ -1069,6 +1075,56 @@ void CMiniDexed::SetParameter (TParameter Parameter, int nValue) BankSelectPerformance(nValue); break; + case ParameterLimiterEnable: + break; + + case ParameterLimiterPreGain: + nValue=constrain(nValue,-20,20); + m_LimiterSpinLock.Acquire (); + for (int i=0; i<2; ++i) + m_Limiter[i].setPreGain_dB(nValue); + m_LimiterSpinLock.Release (); + break; + + case ParameterLimiterAttack: + nValue=constrain(nValue,0,1000); + m_LimiterSpinLock.Acquire (); + for (int i=0; i<2; ++i) + m_Limiter[i].setAttack_sec(nValue / 1000.0f, m_pConfig->GetSampleRate()); + m_LimiterSpinLock.Release (); + break; + + case ParameterLimiterRelease: + nValue=constrain(nValue,0,1000); + m_LimiterSpinLock.Acquire (); + for (int i=0; i<2; ++i) + m_Limiter[i].setRelease_sec(nValue / 1000.0f, m_pConfig->GetSampleRate()); + m_LimiterSpinLock.Release (); + break; + + case ParameterLimiterThresh: + nValue=constrain(nValue,-60,0); + m_LimiterSpinLock.Acquire (); + for (int i=0; i<2; ++i) + m_Limiter[i].setThresh_dBFS(nValue); + m_LimiterSpinLock.Release (); + break; + + case ParameterLimiterRatio: + nValue=constrain(nValue,1,20); + m_LimiterSpinLock.Acquire (); + for (int i=0; i<2; ++i) + m_Limiter[i].setCompressionRatio(nValue); + m_LimiterSpinLock.Release (); + break; + + case ParameterLimiterHPFilterEnable: + m_LimiterSpinLock.Acquire (); + for (int i=0; i<2; ++i) + m_Limiter[i].enableHPFilter(nValue); + m_LimiterSpinLock.Release (); + break; + default: assert (0); break; @@ -1132,6 +1188,13 @@ void CMiniDexed::SetTGParameter (TTGParameter Parameter, int nValue, unsigned nT case TGParameterReverbSend: SetReverbSend (nValue, nTG); break; + case TGParameterCompressorEnable: SetCompressorEnable (nValue, nTG); break; + case TGParameterCompressorPreGain: SetCompressorPreGain (nValue, nTG); break; + case TGParameterCompressorAttack: SetCompressorAttack (nValue, nTG); break; + case TGParameterCompressorRelease: SetCompressorRelease (nValue, nTG); break; + case TGParameterCompressorThresh: SetCompressorThresh (nValue, nTG); break; + case TGParameterCompressorRatio: SetCompressorRatio (nValue, nTG); break; + default: assert (0); break; @@ -1182,7 +1245,13 @@ int CMiniDexed::GetTGParameter (TTGParameter Parameter, unsigned nTG) case TGParameterATAmplitude: return getModController(3, 2, nTG); case TGParameterATEGBias: return getModController(3, 3, nTG); - + case TGParameterCompressorEnable: return m_bCompressorEnable[nTG]; + case TGParameterCompressorPreGain: return m_nCompressorPreGain[nTG]; + case TGParameterCompressorAttack: return m_nCompressorAttack[nTG]; + case TGParameterCompressorRelease: return m_nCompressorRelease[nTG]; + case TGParameterCompressorThresh: return m_nCompressorThresh[nTG]; + case TGParameterCompressorRatio: return m_nCompressorRatio[nTG]; + default: assert (0); return 0; @@ -1434,6 +1503,14 @@ void CMiniDexed::ProcessSound (void) } // END adding reverb + if (m_nParameter[ParameterLimiterEnable]) + { + m_LimiterSpinLock.Acquire (); + m_Limiter[0].doCompression (SampleBuffer[0], nFrames); + m_Limiter[1].doCompression (SampleBuffer[1], nFrames); + m_LimiterSpinLock.Release (); + } + // swap stereo channels if needed prior to writing back out if (m_bChannelsSwapped) { @@ -1547,9 +1624,15 @@ bool CMiniDexed::DoSavePerformance (void) m_PerformanceConfig.SetAftertouchTarget (m_nAftertouchTarget[nTG], nTG); m_PerformanceConfig.SetReverbSend (m_nReverbSend[nTG], nTG); + + m_PerformanceConfig.SetCompressorEnable (m_bCompressorEnable[nTG], nTG); + m_PerformanceConfig.SetCompressorPreGain (m_nCompressorPreGain[nTG], nTG); + m_PerformanceConfig.SetCompressorAttack (m_nCompressorAttack[nTG], nTG); + m_PerformanceConfig.SetCompressorRelease (m_nCompressorRelease[nTG], nTG); + m_PerformanceConfig.SetCompressorThresh (m_nCompressorThresh[nTG], nTG); + m_PerformanceConfig.SetCompressorRatio (m_nCompressorRatio[nTG], nTG); } - m_PerformanceConfig.SetCompressorEnable (!!m_nParameter[ParameterCompressorEnable]); m_PerformanceConfig.SetReverbEnable (!!m_nParameter[ParameterReverbEnable]); m_PerformanceConfig.SetReverbSize (m_nParameter[ParameterReverbSize]); m_PerformanceConfig.SetReverbHighDamp (m_nParameter[ParameterReverbHighDamp]); @@ -1558,6 +1641,14 @@ bool CMiniDexed::DoSavePerformance (void) m_PerformanceConfig.SetReverbDiffusion (m_nParameter[ParameterReverbDiffusion]); m_PerformanceConfig.SetReverbLevel (m_nParameter[ParameterReverbLevel]); + m_PerformanceConfig.SetLimiterEnable (m_nParameter[ParameterLimiterEnable]); + m_PerformanceConfig.SetLimiterPreGain (m_nParameter[ParameterLimiterPreGain]); + m_PerformanceConfig.SetLimiterAttack (m_nParameter[ParameterLimiterAttack]); + m_PerformanceConfig.SetLimiterRelease (m_nParameter[ParameterLimiterRelease]); + m_PerformanceConfig.SetLimiterThresh (m_nParameter[ParameterLimiterThresh]); + m_PerformanceConfig.SetLimiterRatio (m_nParameter[ParameterLimiterRatio]); + m_PerformanceConfig.SetLimiterHPFilterEnable (m_nParameter[ParameterLimiterHPFilterEnable]); + if(m_bSaveAsDeault) { m_PerformanceConfig.SetNewPerformanceBank(0); @@ -1567,6 +1658,77 @@ bool CMiniDexed::DoSavePerformance (void) return m_PerformanceConfig.Save (); } +void CMiniDexed::SetCompressorEnable(bool compressor, unsigned nTG) +{ + assert (nTG < CConfig::AllToneGenerators); + if (nTG >= m_nToneGenerators) return; // Not an active TG + + assert (m_pTG[nTG]); + m_bCompressorEnable[nTG] = compressor; + m_pTG[nTG]->setCompressor (compressor); + m_UI.ParameterChanged (); +} + +void CMiniDexed::SetCompressorPreGain (int preGain, unsigned nTG) +{ + preGain = constrain (preGain, -20, 20); + assert (nTG < CConfig::AllToneGenerators); + if (nTG >= m_nToneGenerators) return; // Not an active TG + + assert (m_pTG[nTG]); + m_nCompressorPreGain[nTG] = preGain; + m_pTG[nTG]->setCompressorPreGain_dB (preGain); + m_UI.ParameterChanged (); +} + +void CMiniDexed::SetCompressorAttack (unsigned attack, unsigned nTG) +{ + attack = constrain (attack, 0u, 1000u); + assert (nTG < CConfig::AllToneGenerators); + if (nTG >= m_nToneGenerators) return; // Not an active TG + + assert (m_pTG[nTG]); + m_nCompressorAttack[nTG] = attack; + m_pTG[nTG]->setCompressorAttack_sec (attack / 1000.0); + m_UI.ParameterChanged (); +} + +void CMiniDexed::SetCompressorRelease (unsigned release, unsigned nTG) +{ + release = constrain (release, 0u, 1000u); + assert (nTG < CConfig::AllToneGenerators); + if (nTG >= m_nToneGenerators) return; // Not an active TG + + assert (m_pTG[nTG]); + m_nCompressorRelease[nTG] = release; + m_pTG[nTG]->setCompressorRelease_sec (release / 1000.0); + m_UI.ParameterChanged (); +} + +void CMiniDexed::SetCompressorThresh (int thresh, unsigned nTG) +{ + thresh = constrain (thresh, -60, 0); + assert (nTG < CConfig::AllToneGenerators); + if (nTG >= m_nToneGenerators) return; // Not an active TG + + assert (m_pTG[nTG]); + m_nCompressorThresh[nTG] = thresh; + m_pTG[nTG]->setCompressorThresh_dBFS (thresh); + m_UI.ParameterChanged (); +} + +void CMiniDexed::SetCompressorRatio (unsigned ratio, unsigned nTG) +{ + ratio = constrain (ratio, 1u, 20u); + assert (nTG < CConfig::AllToneGenerators); + if (nTG >= m_nToneGenerators) return; // Not an active TG + + assert (m_pTG[nTG]); + m_nCompressorRatio[nTG] = ratio; + m_pTG[nTG]->setCompressionRatio (ratio); + m_UI.ParameterChanged (); +} + void CMiniDexed::setMonoMode(uint8_t mono, uint8_t nTG) { assert (nTG < CConfig::AllToneGenerators); @@ -2037,12 +2199,16 @@ void CMiniDexed::LoadPerformanceParameters(void) setBreathControllerTarget (m_PerformanceConfig.GetBreathControlTarget (nTG), nTG); setAftertouchRange (m_PerformanceConfig.GetAftertouchRange (nTG), nTG); setAftertouchTarget (m_PerformanceConfig.GetAftertouchTarget (nTG), nTG); - - + + SetCompressorEnable (m_PerformanceConfig.GetCompressorEnable (nTG), nTG); + SetCompressorPreGain (m_PerformanceConfig.GetCompressorPreGain (nTG), nTG); + SetCompressorAttack (m_PerformanceConfig.GetCompressorAttack (nTG), nTG);; + SetCompressorRelease (m_PerformanceConfig.GetCompressorRelease (nTG), nTG); + SetCompressorThresh (m_PerformanceConfig.GetCompressorThresh (nTG), nTG); + SetCompressorRatio (m_PerformanceConfig.GetCompressorRatio (nTG), nTG); } // Effects - SetParameter (ParameterCompressorEnable, m_PerformanceConfig.GetCompressorEnable () ? 1 : 0); SetParameter (ParameterReverbEnable, m_PerformanceConfig.GetReverbEnable () ? 1 : 0); SetParameter (ParameterReverbSize, m_PerformanceConfig.GetReverbSize ()); SetParameter (ParameterReverbHighDamp, m_PerformanceConfig.GetReverbHighDamp ()); @@ -2051,6 +2217,14 @@ void CMiniDexed::LoadPerformanceParameters(void) SetParameter (ParameterReverbDiffusion, m_PerformanceConfig.GetReverbDiffusion ()); SetParameter (ParameterReverbLevel, m_PerformanceConfig.GetReverbLevel ()); + SetParameter (ParameterLimiterEnable, m_PerformanceConfig.GetLimiterEnable ()); + SetParameter (ParameterLimiterPreGain, m_PerformanceConfig.GetLimiterPreGain ()); + SetParameter (ParameterLimiterAttack, m_PerformanceConfig.GetLimiterAttack ()); + SetParameter (ParameterLimiterRelease, m_PerformanceConfig.GetLimiterRelease ()); + SetParameter (ParameterLimiterThresh, m_PerformanceConfig.GetLimiterThresh ()); + SetParameter (ParameterLimiterRatio, m_PerformanceConfig.GetLimiterRatio ()); + SetParameter (ParameterLimiterHPFilterEnable, m_PerformanceConfig.GetLimiterHPFilterEnable ()); + m_UI.DisplayChanged (); } diff --git a/src/minidexed.h b/src/minidexed.h index 225f1620c..863bf8f20 100644 --- a/src/minidexed.h +++ b/src/minidexed.h @@ -50,6 +50,7 @@ #include "effect_platervbstereo.h" #include "udpmididevice.h" #include "net/ftpdaemon.h" +#include "../Synth_Dexed/src/compressor.h" class CMiniDexed #ifdef ARM_ALLOW_MULTI_CORE @@ -106,6 +107,13 @@ class CMiniDexed void SetReverbSend (unsigned nReverbSend, unsigned nTG); // 0 .. 127 + void SetCompressorEnable (bool compressor, unsigned nTG); // 0 .. 1 (default 1) + void SetCompressorPreGain (int preGain, unsigned nTG); // -20 .. 20 dB (default 0) + void SetCompressorAttack (unsigned attack, unsigned nTG); // 0 .. 1000 ms (default 5) + void SetCompressorRelease (unsigned release, unsigned nTG); // 0 .. 1000 ms (default 200) + void SetCompressorThresh (int thresh, unsigned nTG); // -60 .. 0 dBFS (default -20) + void SetCompressorRatio (unsigned ratio, unsigned nTG); // 1 .. 20 (default 5) + void setMonoMode(uint8_t mono, uint8_t nTG); void setPitchbendRange(uint8_t range, uint8_t nTG); void setPitchbendStep(uint8_t step, uint8_t nTG); @@ -158,7 +166,6 @@ class CMiniDexed // Must match the order in CUIMenu::TParameter enum TParameter { - ParameterCompressorEnable, ParameterReverbEnable, ParameterReverbSize, ParameterReverbHighDamp, @@ -168,6 +175,13 @@ class CMiniDexed ParameterReverbLevel, ParameterPerformanceSelectChannel, ParameterPerformanceBank, + ParameterLimiterEnable, + ParameterLimiterPreGain, + ParameterLimiterAttack, + ParameterLimiterRelease, + ParameterLimiterThresh, + ParameterLimiterRatio, + ParameterLimiterHPFilterEnable, ParameterUnknown }; @@ -220,6 +234,13 @@ class CMiniDexed TGParameterATPitch, TGParameterATAmplitude, TGParameterATEGBias, + + TGParameterCompressorEnable, + TGParameterCompressorPreGain, + TGParameterCompressorAttack, + TGParameterCompressorRelease, + TGParameterCompressorThresh, + TGParameterCompressorRatio, TGParameterUnknown }; @@ -304,6 +325,13 @@ class CMiniDexed int m_nNoteShift[CConfig::AllToneGenerators]; unsigned m_nReverbSend[CConfig::AllToneGenerators]; + + bool m_bCompressorEnable[CConfig::AllToneGenerators]; + int m_nCompressorPreGain[CConfig::AllToneGenerators]; + unsigned m_nCompressorAttack[CConfig::AllToneGenerators]; + unsigned m_nCompressorRelease[CConfig::AllToneGenerators]; + int m_nCompressorThresh[CConfig::AllToneGenerators]; + unsigned m_nCompressorRatio[CConfig::AllToneGenerators]; uint8_t m_nRawVoiceData[156]; @@ -340,6 +368,9 @@ class CMiniDexed CSpinLock m_ReverbSpinLock; + Compressor m_Limiter[2]; + CSpinLock m_LimiterSpinLock; + // Network CNetSubSystem* m_pNet; CNetDevice* m_pNetDevice; diff --git a/src/performanceconfig.cpp b/src/performanceconfig.cpp index dfff8a9cc..c2a332d11 100644 --- a/src/performanceconfig.cpp +++ b/src/performanceconfig.cpp @@ -208,10 +208,26 @@ bool CPerformanceConfig::Load (void) PropertyName.Format ("AftertouchTarget%u", nTG+1); m_nAftertouchTarget[nTG] = m_Properties.GetNumber (PropertyName, 0); + + PropertyName.Format ("CompressorEnable%u", nTG+1); + m_bCompressorEnable[nTG] = m_Properties.GetNumber (PropertyName, 1); - } + PropertyName.Format ("CompressorPreGain%u", nTG+1); + m_nCompressorPreGain[nTG] = m_Properties.GetSignedNumber (PropertyName, 0); + + PropertyName.Format ("CompressorAttack%u", nTG+1); + m_nCompressorAttack[nTG] = m_Properties.GetNumber (PropertyName, 5); + + PropertyName.Format ("CompressorRelease%u", nTG+1); + m_nCompressorRelease[nTG] = m_Properties.GetNumber (PropertyName, 200); - m_bCompressorEnable = m_Properties.GetNumber ("CompressorEnable", 1) != 0; + PropertyName.Format ("CompressorThresh%u", nTG+1); + m_nCompressorThresh[nTG] = m_Properties.GetSignedNumber (PropertyName, -20); + + PropertyName.Format ("CompressorRatio%u", nTG+1); + m_nCompressorRatio[nTG] = m_Properties.GetNumber (PropertyName, 5); + + } m_bReverbEnable = m_Properties.GetNumber ("ReverbEnable", 1) != 0; m_nReverbSize = m_Properties.GetNumber ("ReverbSize", 70); @@ -221,6 +237,23 @@ bool CPerformanceConfig::Load (void) m_nReverbDiffusion = m_Properties.GetNumber ("ReverbDiffusion", 65); m_nReverbLevel = m_Properties.GetNumber ("ReverbLevel", 99); + m_bLimiterEnable = m_Properties.GetNumber ("LimiterEnable", 1); + m_nLimiterPreGain = m_Properties.GetSignedNumber ("LimiterPreGain", 0); + m_nLimiterAttack = m_Properties.GetNumber ("LimiterAttack", 5); + m_nLimiterRelease = m_Properties.GetNumber ("LimiterRelease", 5); + m_nLimiterThresh = m_Properties.GetSignedNumber ("LimiterThresh", -3); + m_nLimiterRatio = m_Properties.GetNumber ("LimiterRatio", 20); + m_bLimiterHPFilterEnable = m_Properties.GetNumber ("LimiterHPFilterEnable", 0); + + // Compatibility + if (m_Properties.IsSet ("CompressorEnable") && m_Properties.GetNumber ("CompressorEnable", 1) == 0) + { + for (unsigned nTG = 0; nTG < CConfig::AllToneGenerators; nTG++) + { + m_bCompressorEnable[nTG] = 0; + } + } + return bResult; } @@ -327,9 +360,25 @@ bool CPerformanceConfig::Save (void) PropertyName.Format ("AftertouchTarget%u", nTG+1); m_Properties.SetNumber (PropertyName, m_nAftertouchTarget[nTG]); - } + PropertyName.Format ("CompressorEnable%u", nTG+1); + m_Properties.SetNumber (PropertyName, m_bCompressorEnable[nTG]); + + PropertyName.Format ("CompressorPreGain%u", nTG+1); + m_Properties.SetSignedNumber (PropertyName, m_nCompressorPreGain[nTG]); - m_Properties.SetNumber ("CompressorEnable", m_bCompressorEnable ? 1 : 0); + PropertyName.Format ("CompressorAttack%u", nTG+1); + m_Properties.SetNumber (PropertyName, m_nCompressorAttack[nTG]); + + PropertyName.Format ("CompressorRelease%u", nTG+1); + m_Properties.SetNumber (PropertyName, m_nCompressorRelease[nTG]); + + PropertyName.Format ("CompressorThresh%u", nTG+1); + m_Properties.SetSignedNumber (PropertyName, m_nCompressorThresh[nTG]); + + PropertyName.Format ("CompressorRatio%u", nTG+1); + m_Properties.SetNumber (PropertyName, m_nCompressorRatio[nTG]); + + } m_Properties.SetNumber ("ReverbEnable", m_bReverbEnable ? 1 : 0); m_Properties.SetNumber ("ReverbSize", m_nReverbSize); @@ -339,6 +388,14 @@ bool CPerformanceConfig::Save (void) m_Properties.SetNumber ("ReverbDiffusion", m_nReverbDiffusion); m_Properties.SetNumber ("ReverbLevel", m_nReverbLevel); + m_Properties.SetNumber ("LimiterEnable", m_bLimiterEnable); + m_Properties.SetSignedNumber ("LimiterPreGain", m_nLimiterPreGain); + m_Properties.SetNumber ("LimiterAttack", m_nLimiterAttack); + m_Properties.SetNumber ("LimiterRelease", m_nLimiterRelease); + m_Properties.SetSignedNumber ("LimiterThresh", m_nLimiterThresh); + m_Properties.SetNumber ("LimiterRatio", m_nLimiterRatio); + m_Properties.SetNumber ("LimiterHPFilterEnable", m_bLimiterHPFilterEnable); + return m_Properties.Save (); } @@ -486,11 +543,6 @@ void CPerformanceConfig::SetReverbSend (unsigned nValue, unsigned nTG) m_nReverbSend[nTG] = nValue; } -bool CPerformanceConfig::GetCompressorEnable (void) const -{ - return m_bCompressorEnable; -} - bool CPerformanceConfig::GetReverbEnable (void) const { return m_bReverbEnable; @@ -526,11 +578,6 @@ unsigned CPerformanceConfig::GetReverbLevel (void) const return m_nReverbLevel; } -void CPerformanceConfig::SetCompressorEnable (bool bValue) -{ - m_bCompressorEnable = bValue; -} - void CPerformanceConfig::SetReverbEnable (bool bValue) { m_bReverbEnable = bValue; @@ -565,6 +612,77 @@ void CPerformanceConfig::SetReverbLevel (unsigned nValue) { m_nReverbLevel = nValue; } + +bool CPerformanceConfig::GetLimiterEnable () const +{ + return m_bLimiterEnable; +} + +int CPerformanceConfig::GetLimiterPreGain () const +{ + return m_nLimiterPreGain; +} + +unsigned CPerformanceConfig::GetLimiterAttack () const +{ + return m_nLimiterAttack; +} + +unsigned CPerformanceConfig::GetLimiterRelease () const +{ + return m_nLimiterRelease; +} + +int CPerformanceConfig::GetLimiterThresh () const +{ + return m_nLimiterThresh; +} + +unsigned CPerformanceConfig::GetLimiterRatio () const +{ + return m_nLimiterRatio; +} + +bool CPerformanceConfig::GetLimiterHPFilterEnable () const +{ + return m_bLimiterHPFilterEnable; +} + +void CPerformanceConfig::SetLimiterEnable (bool nValue) +{ + m_bLimiterEnable = nValue; +} + +void CPerformanceConfig::SetLimiterPreGain (int nValue) +{ + m_nLimiterPreGain= nValue; +} + +void CPerformanceConfig::SetLimiterAttack (unsigned nValue) +{ + m_nLimiterAttack = nValue; +} + +void CPerformanceConfig::SetLimiterRelease (unsigned nValue) +{ + m_nLimiterRelease = nValue; +} + +void CPerformanceConfig::SetLimiterThresh (int nValue) +{ + m_nLimiterThresh = nValue; +} + +void CPerformanceConfig::SetLimiterRatio (unsigned nValue) +{ + m_nLimiterRatio = nValue; +} + +void CPerformanceConfig::SetLimiterHPFilterEnable (bool nValue) +{ + m_bLimiterHPFilterEnable = nValue; +} + // Pitch bender and portamento: void CPerformanceConfig::SetPitchBendRange (unsigned nValue, unsigned nTG) { @@ -737,6 +855,79 @@ unsigned CPerformanceConfig::GetAftertouchTarget (unsigned nTG) const return m_nAftertouchTarget[nTG]; } +void CPerformanceConfig::SetCompressorEnable (bool bValue, unsigned nTG) +{ + assert (nTG < CConfig::AllToneGenerators); + m_bCompressorEnable[nTG] = bValue; +} + +bool CPerformanceConfig::GetCompressorEnable (unsigned nTG) const +{ + assert (nTG < CConfig::AllToneGenerators); + return m_bCompressorEnable[nTG]; +} + +void CPerformanceConfig::SetCompressorPreGain (int nValue, unsigned nTG) +{ + assert (nTG < CConfig::AllToneGenerators); + m_nCompressorPreGain[nTG] = nValue; +} + +int CPerformanceConfig::GetCompressorPreGain (unsigned nTG) const +{ + assert (nTG < CConfig::AllToneGenerators); + return m_nCompressorPreGain[nTG]; +} + +void CPerformanceConfig::SetCompressorAttack (unsigned nValue, unsigned nTG) +{ + assert (nTG < CConfig::AllToneGenerators); + m_nCompressorAttack[nTG] = nValue; +} + +unsigned CPerformanceConfig::GetCompressorAttack (unsigned nTG) const +{ + assert (nTG < CConfig::AllToneGenerators); + return m_nCompressorAttack[nTG]; +} + +void CPerformanceConfig::SetCompressorRelease (unsigned nValue, unsigned nTG) +{ + assert (nTG < CConfig::AllToneGenerators); + m_nCompressorRelease[nTG] = nValue; +} + +unsigned CPerformanceConfig::GetCompressorRelease (unsigned nTG) const +{ + assert (nTG < CConfig::AllToneGenerators); + return m_nCompressorRelease[nTG]; +} + +void CPerformanceConfig::SetCompressorThresh (int nValue, unsigned nTG) +{ + assert (nTG < CConfig::AllToneGenerators); + m_nCompressorThresh[nTG] = nValue; +} + +int CPerformanceConfig::GetCompressorThresh (unsigned nTG) const +{ + assert (nTG < CConfig::AllToneGenerators); + return m_nCompressorThresh[nTG]; +} + +void CPerformanceConfig::SetCompressorRatio (unsigned nValue, unsigned nTG) +{ + assert (nTG < CConfig::AllToneGenerators); + m_nCompressorRatio[nTG] = nValue; +} + +unsigned CPerformanceConfig::GetCompressorRatio (unsigned nTG) const +{ + assert (nTG < CConfig::AllToneGenerators); + return m_nCompressorRatio[nTG]; +} + + void CPerformanceConfig::SetVoiceDataToTxt (const uint8_t *pData, unsigned nTG) { assert (nTG < CConfig::AllToneGenerators); diff --git a/src/performanceconfig.h b/src/performanceconfig.h index 916a2eec0..18f9de25d 100644 --- a/src/performanceconfig.h +++ b/src/performanceconfig.h @@ -71,6 +71,13 @@ class CPerformanceConfig // Performance configuration unsigned GetAftertouchRange (unsigned nTG) const; // 0 .. 99 unsigned GetAftertouchTarget (unsigned nTG) const; // 0 .. 7 + bool GetCompressorEnable (unsigned nTG) const; // 0 .. 1 + int GetCompressorPreGain (unsigned nTG) const; + unsigned GetCompressorAttack (unsigned nTG) const; + unsigned GetCompressorRelease (unsigned nTG) const; + int GetCompressorThresh (unsigned nTG) const; + unsigned GetCompressorRatio (unsigned nTG) const; + void SetBankNumber (unsigned nValue, unsigned nTG); void SetVoiceNumber (unsigned nValue, unsigned nTG); void SetMIDIChannel (unsigned nValue, unsigned nTG); @@ -101,8 +108,14 @@ class CPerformanceConfig // Performance configuration void SetAftertouchRange (unsigned nValue, unsigned nTG); void SetAftertouchTarget (unsigned nValue, unsigned nTG); + void SetCompressorEnable (bool nValue, unsigned nTG); + void SetCompressorPreGain (int nValue, unsigned nTG); + void SetCompressorAttack (unsigned nValue, unsigned nTG); + void SetCompressorRelease (unsigned nValue, unsigned nTG); + void SetCompressorThresh (int nValue, unsigned nTG); + void SetCompressorRatio (unsigned nValue, unsigned nTG); + // Effects - bool GetCompressorEnable (void) const; bool GetReverbEnable (void) const; unsigned GetReverbSize (void) const; // 0 .. 99 unsigned GetReverbHighDamp (void) const; // 0 .. 99 @@ -111,7 +124,6 @@ class CPerformanceConfig // Performance configuration unsigned GetReverbDiffusion (void) const; // 0 .. 99 unsigned GetReverbLevel (void) const; // 0 .. 99 - void SetCompressorEnable (bool bValue); void SetReverbEnable (bool bValue); void SetReverbSize (unsigned nValue); void SetReverbHighDamp (unsigned nValue); @@ -120,6 +132,22 @@ class CPerformanceConfig // Performance configuration void SetReverbDiffusion (unsigned nValue); void SetReverbLevel (unsigned nValue); + bool GetLimiterEnable () const; + int GetLimiterPreGain () const; + unsigned GetLimiterAttack () const; + unsigned GetLimiterRelease () const; + int GetLimiterThresh () const; + unsigned GetLimiterRatio () const; + bool GetLimiterHPFilterEnable () const; + + void SetLimiterEnable (bool nValue); + void SetLimiterPreGain (int nValue); + void SetLimiterAttack (unsigned nValue); + void SetLimiterRelease (unsigned nValue); + void SetLimiterThresh (int nValue); + void SetLimiterRatio (unsigned nValue); + void SetLimiterHPFilterEnable (bool nValue); + bool VoiceDataFilled(unsigned nTG); bool ListPerformances(); //std::string m_DirName; @@ -181,7 +209,14 @@ class CPerformanceConfig // Performance configuration unsigned m_nBreathControlRange[CConfig::AllToneGenerators]; unsigned m_nBreathControlTarget[CConfig::AllToneGenerators]; unsigned m_nAftertouchRange[CConfig::AllToneGenerators]; - unsigned m_nAftertouchTarget[CConfig::AllToneGenerators]; + unsigned m_nAftertouchTarget[CConfig::AllToneGenerators]; + + bool m_bCompressorEnable[CConfig::AllToneGenerators]; + int m_nCompressorPreGain[CConfig::AllToneGenerators]; + unsigned m_nCompressorAttack[CConfig::AllToneGenerators]; + unsigned m_nCompressorRelease[CConfig::AllToneGenerators]; + int m_nCompressorThresh[CConfig::AllToneGenerators]; + unsigned m_nCompressorRatio[CConfig::AllToneGenerators]; unsigned m_nLastPerformance; unsigned m_nActualPerformance = 0; @@ -196,7 +231,6 @@ class CPerformanceConfig // Performance configuration std::string NewPerformanceName=""; - bool m_bCompressorEnable; bool m_bReverbEnable; unsigned m_nReverbSize; unsigned m_nReverbHighDamp; @@ -204,6 +238,14 @@ class CPerformanceConfig // Performance configuration unsigned m_nReverbLowPass; unsigned m_nReverbDiffusion; unsigned m_nReverbLevel; + + bool m_bLimiterEnable; + int m_nLimiterPreGain; + unsigned m_nLimiterAttack; + unsigned m_nLimiterRelease; + int m_nLimiterThresh; + unsigned m_nLimiterRatio; + bool m_bLimiterHPFilterEnable; }; #endif diff --git a/src/uimenu.cpp b/src/uimenu.cpp index e8342c8ab..794e39d09 100644 --- a/src/uimenu.cpp +++ b/src/uimenu.cpp @@ -63,7 +63,9 @@ const CUIMenu::TMenuItem CUIMenu::s_MainMenu[] = {"TG16", MenuHandler, s_TGMenu, 15}, #endif #endif +#ifdef ARM_ALLOW_MULTI_CORE {"Effects", MenuHandler, s_EffectsMenu}, +#endif {"Master Volume", EditMasterVolume, 0, 0}, {"Performance", MenuHandler, s_PerformanceMenu}, {0} @@ -86,15 +88,27 @@ const CUIMenu::TMenuItem CUIMenu::s_TGMenu[] = {"Poly/Mono", EditTGParameter, 0, CMiniDexed::TGParameterMonoMode}, {"Modulation", MenuHandler, s_ModulationMenu}, {"Channel", EditTGParameter, 0, CMiniDexed::TGParameterMIDIChannel}, + {"Compressor", MenuHandler, s_EditCompressorMenu}, {"Edit Voice", MenuHandler, s_EditVoiceMenu}, {0} }; +const CUIMenu::TMenuItem CUIMenu::s_EditCompressorMenu[] = +{ + {"Enable", EditTGParameter2, 0, CMiniDexed::TGParameterCompressorEnable}, + {"Pre Gain", EditTGParameter2, 0, CMiniDexed::TGParameterCompressorPreGain}, + {"Attack", EditTGParameter2, 0, CMiniDexed::TGParameterCompressorAttack}, + {"Release", EditTGParameter2, 0, CMiniDexed::TGParameterCompressorRelease}, + {"Threshold", EditTGParameter2, 0, CMiniDexed::TGParameterCompressorThresh}, + {"Ratio", EditTGParameter2, 0, CMiniDexed::TGParameterCompressorRatio}, + {0} +}; + const CUIMenu::TMenuItem CUIMenu::s_EffectsMenu[] = { - {"Compress", EditGlobalParameter, 0, CMiniDexed::ParameterCompressorEnable}, #ifdef ARM_ALLOW_MULTI_CORE {"Reverb", MenuHandler, s_ReverbMenu}, + {"Limiter", MenuHandler, s_LimiterMenu}, #endif {0} }; @@ -146,6 +160,18 @@ const CUIMenu::TMenuItem CUIMenu::s_ReverbMenu[] = {0} }; +const CUIMenu::TMenuItem CUIMenu::s_LimiterMenu[] = +{ + {"Enable", EditGlobalParameter, 0, CMiniDexed::ParameterLimiterEnable}, + {"Pre Gain", EditGlobalParameter, 0, CMiniDexed::ParameterLimiterPreGain}, + {"Attack", EditGlobalParameter, 0, CMiniDexed::ParameterLimiterAttack}, + {"Release", EditGlobalParameter, 0, CMiniDexed::ParameterLimiterRelease}, + {"Threshold", EditGlobalParameter, 0, CMiniDexed::ParameterLimiterThresh}, + {"Ratio", EditGlobalParameter, 0, CMiniDexed::ParameterLimiterRatio}, + {"HPFilter", EditGlobalParameter, 0, CMiniDexed::ParameterLimiterHPFilterEnable}, + {0} +}; + #endif // inserting menu items before "OP1" affect OPShortcutHandler() @@ -218,7 +244,6 @@ const CUIMenu::TMenuItem CUIMenu::s_SaveMenu[] = // must match CMiniDexed::TParameter const CUIMenu::TParameter CUIMenu::s_GlobalParameter[CMiniDexed::ParameterUnknown] = { - {0, 1, 1, ToOnOff}, // ParameterCompessorEnable {0, 1, 1, ToOnOff}, // ParameterReverbEnable {0, 99, 1}, // ParameterReverbSize {0, 99, 1}, // ParameterReverbHighDamp @@ -227,7 +252,14 @@ const CUIMenu::TParameter CUIMenu::s_GlobalParameter[CMiniDexed::ParameterUnknow {0, 99, 1}, // ParameterReverbDiffusion {0, 99, 1}, // ParameterReverbLevel {0, CMIDIDevice::ChannelUnknown-1, 1, ToMIDIChannel}, // ParameterPerformanceSelectChannel - {0, NUM_PERFORMANCE_BANKS, 1} // ParameterPerformanceBank + {0, NUM_PERFORMANCE_BANKS, 1}, // ParameterPerformanceBank + {0, 1, 1, ToOnOff}, // ParameterLimiterEnable + {-20, 20, 1, TodB}, // ParameterLimiterPreGain + {0, 1000, 5, ToMillisec}, // ParameterLimiterAttack + {0, 1000, 5, ToMillisec}, // ParameterLimiterRelease + {-60, 0, 1, TodBFS}, // ParameterLimiterThresh + {1, 20, 1, ToRatio}, // ParameterLimiterRatio + {0, 1, 1, ToOnOff}, // ParameterLimiterHPFilterEnable }; // must match CMiniDexed::TTGParameter @@ -265,7 +297,13 @@ const CUIMenu::TParameter CUIMenu::s_TGParameter[CMiniDexed::TGParameterUnknown] {0, 99, 1}, //AT Range {0, 1, 1, ToOnOff}, //AT Pitch {0, 1, 1, ToOnOff}, //AT Amp - {0, 1, 1, ToOnOff} //AT EGBias + {0, 1, 1, ToOnOff}, //AT EGBias + {0, 1, 1, ToOnOff}, // TGParameterCompressorEnable + {-20, 20, 1, TodB}, // TGParameterCompressorPreGain + {0, 1000, 5, ToMillisec}, // TGParameterCompressorAttack + {0, 1000, 5, ToMillisec}, // TGParameterCompressorRelease + {-60, 0, 1, TodBFS}, // TGParameterCompressorThresh + {1, 20, 1, ToRatio}, // TGParameterCompressorRatio }; // must match DexedVoiceParameters in Synth_Dexed @@ -1239,6 +1277,26 @@ string CUIMenu::ToPolyMono (int nValue) } } +std::string CUIMenu::TodB (int nValue) +{ + return std::to_string (nValue) + " dB"; +} + +std::string CUIMenu::TodBFS (int nValue) +{ + return std::to_string (nValue) + " dBFS"; +} + +std::string CUIMenu::ToMillisec (int nValue) +{ + return std::to_string (nValue) + " ms"; +} + +std::string CUIMenu::ToRatio (int nValue) +{ + return std::to_string (nValue) + ":1"; +} + void CUIMenu::TGShortcutHandler (TMenuEvent Event) { assert (m_nCurrentMenuDepth >= 2); diff --git a/src/uimenu.h b/src/uimenu.h index 6c72f36c6..f8abb9127 100644 --- a/src/uimenu.h +++ b/src/uimenu.h @@ -118,6 +118,10 @@ class CUIMenu static std::string ToPortaMode (int nValue); static std::string ToPortaGlissando (int nValue); static std::string ToPolyMono (int nValue); + static std::string TodB (int nValue); + static std::string TodBFS (int nValue); + static std::string ToMillisec (int nValue); + static std::string ToRatio (int nValue); void TGShortcutHandler (TMenuEvent Event); void OPShortcutHandler (TMenuEvent Event); @@ -156,6 +160,8 @@ class CUIMenu static const TMenuItem s_TGMenu[]; static const TMenuItem s_EffectsMenu[]; static const TMenuItem s_ReverbMenu[]; + static const TMenuItem s_LimiterMenu[]; + static const TMenuItem s_EditCompressorMenu[]; static const TMenuItem s_EditVoiceMenu[]; static const TMenuItem s_OperatorMenu[]; static const TMenuItem s_SaveMenu[]; diff --git a/submod.sh b/submod.sh index 28d467bba..5c5580e90 100755 --- a/submod.sh +++ b/submod.sh @@ -18,6 +18,6 @@ cd - #cd - # Use fixed master branch of Synth_Dexed -cd Synth_Dexed/ -git checkout -f 3c683fc801 -cd - +#cd Synth_Dexed/ +#git checkout -f a02b5c0bf2da132f49a923f9c69796220a8ea93f +#cd -