Skip to content

Commit fb47bdc

Browse files
committed
add compressor parameters
1 parent b17c4c3 commit fb47bdc

File tree

6 files changed

+240
-5
lines changed

6 files changed

+240
-5
lines changed

src/minidexed.cpp

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
117117
m_nReverbSend[i] = 0;
118118

119119
m_bCompressorEnable[i] = 1;
120+
m_nCompressorPreGain[i] = 0;
121+
m_nCompressorAttack[i] = 5;
122+
m_nCompressorRelease[i] = 200;
123+
m_nCompressorThresh[i] = -20;
124+
m_nCompressorRatio[i] = 5;
120125

121126
// Active the required number of active TGs
122127
if (i<m_nToneGenerators)
@@ -1125,6 +1130,11 @@ void CMiniDexed::SetTGParameter (TTGParameter Parameter, int nValue, unsigned nT
11251130
case TGParameterReverbSend: SetReverbSend (nValue, nTG); break;
11261131

11271132
case TGParameterCompressorEnable: SetCompressorEnable (nValue, nTG); break;
1133+
case TGParameterCompressorPreGain: SetCompressorPreGain (nValue, nTG); break;
1134+
case TGParameterCompressorAttack: SetCompressorAttack (nValue, nTG); break;
1135+
case TGParameterCompressorRelease: SetCompressorRelease (nValue, nTG); break;
1136+
case TGParameterCompressorThresh: SetCompressorThresh (nValue, nTG); break;
1137+
case TGParameterCompressorRatio: SetCompressorRatio (nValue, nTG); break;
11281138

11291139
default:
11301140
assert (0);
@@ -1177,6 +1187,11 @@ int CMiniDexed::GetTGParameter (TTGParameter Parameter, unsigned nTG)
11771187
case TGParameterATEGBias: return getModController(3, 3, nTG);
11781188

11791189
case TGParameterCompressorEnable: return m_bCompressorEnable[nTG];
1190+
case TGParameterCompressorPreGain: return m_nCompressorPreGain[nTG];
1191+
case TGParameterCompressorAttack: return m_nCompressorAttack[nTG];
1192+
case TGParameterCompressorRelease: return m_nCompressorRelease[nTG];
1193+
case TGParameterCompressorThresh: return m_nCompressorThresh[nTG];
1194+
case TGParameterCompressorRatio: return m_nCompressorRatio[nTG];
11801195

11811196
default:
11821197
assert (0);
@@ -1544,6 +1559,11 @@ bool CMiniDexed::DoSavePerformance (void)
15441559
m_PerformanceConfig.SetReverbSend (m_nReverbSend[nTG], nTG);
15451560

15461561
m_PerformanceConfig.SetCompressorEnable (m_bCompressorEnable[nTG], nTG);
1562+
m_PerformanceConfig.SetCompressorPreGain (m_nCompressorPreGain[nTG], nTG);
1563+
m_PerformanceConfig.SetCompressorAttack (m_nCompressorAttack[nTG], nTG);
1564+
m_PerformanceConfig.SetCompressorRelease (m_nCompressorRelease[nTG], nTG);
1565+
m_PerformanceConfig.SetCompressorThresh (m_nCompressorThresh[nTG], nTG);
1566+
m_PerformanceConfig.SetCompressorRatio (m_nCompressorRatio[nTG], nTG);
15471567
}
15481568

15491569
m_PerformanceConfig.SetReverbEnable (!!m_nParameter[ParameterReverbEnable]);
@@ -1574,6 +1594,66 @@ void CMiniDexed::SetCompressorEnable(bool compressor, unsigned nTG)
15741594
m_UI.ParameterChanged ();
15751595
}
15761596

1597+
void CMiniDexed::SetCompressorPreGain (int preGain, unsigned nTG)
1598+
{
1599+
preGain = constrain (preGain, -12, 12);
1600+
assert (nTG < CConfig::AllToneGenerators);
1601+
if (nTG >= m_nToneGenerators) return; // Not an active TG
1602+
1603+
assert (m_pTG[nTG]);
1604+
m_nCompressorPreGain[nTG] = preGain;
1605+
m_pTG[nTG]->setCompressorPreGain_dB (preGain);
1606+
m_UI.ParameterChanged ();
1607+
}
1608+
1609+
void CMiniDexed::SetCompressorAttack (unsigned attack, unsigned nTG)
1610+
{
1611+
attack = constrain (attack, 0u, 1000u);
1612+
assert (nTG < CConfig::AllToneGenerators);
1613+
if (nTG >= m_nToneGenerators) return; // Not an active TG
1614+
1615+
assert (m_pTG[nTG]);
1616+
m_nCompressorAttack[nTG] = attack;
1617+
m_pTG[nTG]->setCompressorAttack_sec (attack / 1000.0);
1618+
m_UI.ParameterChanged ();
1619+
}
1620+
1621+
void CMiniDexed::SetCompressorRelease (unsigned release, unsigned nTG)
1622+
{
1623+
release = constrain (release, 0u, 1000u);
1624+
assert (nTG < CConfig::AllToneGenerators);
1625+
if (nTG >= m_nToneGenerators) return; // Not an active TG
1626+
1627+
assert (m_pTG[nTG]);
1628+
m_nCompressorRelease[nTG] = release;
1629+
m_pTG[nTG]->setCompressorRelease_sec (release / 1000.0);
1630+
m_UI.ParameterChanged ();
1631+
}
1632+
1633+
void CMiniDexed::SetCompressorThresh (int thresh, unsigned nTG)
1634+
{
1635+
thresh = constrain (thresh, -30, -20);
1636+
assert (nTG < CConfig::AllToneGenerators);
1637+
if (nTG >= m_nToneGenerators) return; // Not an active TG
1638+
1639+
assert (m_pTG[nTG]);
1640+
m_nCompressorThresh[nTG] = thresh;
1641+
m_pTG[nTG]->setCompressorThresh_dBFS (thresh);
1642+
m_UI.ParameterChanged ();
1643+
}
1644+
1645+
void CMiniDexed::SetCompressorRatio (unsigned ratio, unsigned nTG)
1646+
{
1647+
ratio = constrain (ratio, 1u, 20u);
1648+
assert (nTG < CConfig::AllToneGenerators);
1649+
if (nTG >= m_nToneGenerators) return; // Not an active TG
1650+
1651+
assert (m_pTG[nTG]);
1652+
m_nCompressorRatio[nTG] = ratio;
1653+
m_pTG[nTG]->setCompressionRatio (ratio);
1654+
m_UI.ParameterChanged ();
1655+
}
1656+
15771657
void CMiniDexed::setMonoMode(uint8_t mono, uint8_t nTG)
15781658
{
15791659
assert (nTG < CConfig::AllToneGenerators);
@@ -2046,6 +2126,11 @@ void CMiniDexed::LoadPerformanceParameters(void)
20462126
setAftertouchTarget (m_PerformanceConfig.GetAftertouchTarget (nTG), nTG);
20472127

20482128
SetCompressorEnable (m_PerformanceConfig.GetCompressorEnable (nTG), nTG);
2129+
SetCompressorPreGain (m_PerformanceConfig.GetCompressorPreGain (nTG), nTG);
2130+
SetCompressorAttack (m_PerformanceConfig.GetCompressorAttack (nTG), nTG);;
2131+
SetCompressorRelease (m_PerformanceConfig.GetCompressorRelease (nTG), nTG);
2132+
SetCompressorThresh (m_PerformanceConfig.GetCompressorThresh (nTG), nTG);
2133+
SetCompressorRatio (m_PerformanceConfig.GetCompressorRatio (nTG), nTG);
20492134
}
20502135

20512136
// Effects

src/minidexed.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ class CMiniDexed
106106

107107
void SetReverbSend (unsigned nReverbSend, unsigned nTG); // 0 .. 127
108108

109-
void SetCompressorEnable (bool compressor, unsigned nTG);
109+
void SetCompressorEnable (bool compressor, unsigned nTG); // 0 .. 1 (default 1)
110+
void SetCompressorPreGain (int preGain, unsigned nTG); // -12 .. 12 dB (default 0)
111+
void SetCompressorAttack (unsigned attack, unsigned nTG); // 0 .. 1000 ms (default 5)
112+
void SetCompressorRelease (unsigned release, unsigned nTG); // 0 .. 1000 ms (default 200)
113+
void SetCompressorThresh (int thresh, unsigned nTG); // -30 .. -20 dB (default -20)
114+
void SetCompressorRatio (unsigned ratio, unsigned nTG); // 1 .. 20 (default 5)
110115

111116
void setMonoMode(uint8_t mono, uint8_t nTG);
112117
void setPitchbendRange(uint8_t range, uint8_t nTG);
@@ -223,6 +228,11 @@ class CMiniDexed
223228
TGParameterATEGBias,
224229

225230
TGParameterCompressorEnable,
231+
TGParameterCompressorPreGain,
232+
TGParameterCompressorAttack,
233+
TGParameterCompressorRelease,
234+
TGParameterCompressorThresh,
235+
TGParameterCompressorRatio,
226236

227237
TGParameterUnknown
228238
};
@@ -309,6 +319,11 @@ class CMiniDexed
309319
unsigned m_nReverbSend[CConfig::AllToneGenerators];
310320

311321
bool m_bCompressorEnable[CConfig::AllToneGenerators];
322+
int m_nCompressorPreGain[CConfig::AllToneGenerators];
323+
unsigned m_nCompressorAttack[CConfig::AllToneGenerators];
324+
unsigned m_nCompressorRelease[CConfig::AllToneGenerators];
325+
int m_nCompressorThresh[CConfig::AllToneGenerators];
326+
unsigned m_nCompressorRatio[CConfig::AllToneGenerators];
312327

313328
uint8_t m_nRawVoiceData[156];
314329

src/performanceconfig.cpp

Lines changed: 95 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,21 @@ bool CPerformanceConfig::Load (void)
212212
PropertyName.Format ("CompressorEnable%u", nTG+1);
213213
m_bCompressorEnable[nTG] = m_Properties.GetNumber (PropertyName, 1);
214214

215+
PropertyName.Format ("CompressorPreGain%u", nTG+1);
216+
m_nCompressorPreGain[nTG] = m_Properties.GetSignedNumber (PropertyName, 0);
217+
218+
PropertyName.Format ("CompressorAttack%u", nTG+1);
219+
m_nCompressorAttack[nTG] = m_Properties.GetNumber (PropertyName, 5);
220+
221+
PropertyName.Format ("CompressorRelease%u", nTG+1);
222+
m_nCompressorRelease[nTG] = m_Properties.GetNumber (PropertyName, 200);
223+
224+
PropertyName.Format ("CompressorThresh%u", nTG+1);
225+
m_nCompressorThresh[nTG] = m_Properties.GetSignedNumber (PropertyName, -20);
226+
227+
PropertyName.Format ("CompressorRatio%u", nTG+1);
228+
m_nCompressorRatio[nTG] = m_Properties.GetNumber (PropertyName, 5);
229+
215230
}
216231

217232
m_bReverbEnable = m_Properties.GetNumber ("ReverbEnable", 1) != 0;
@@ -223,11 +238,12 @@ bool CPerformanceConfig::Load (void)
223238
m_nReverbLevel = m_Properties.GetNumber ("ReverbLevel", 99);
224239

225240
// Compatibility
226-
if (m_Properties.IsSet ("CompressorEnable"))
241+
if (m_Properties.IsSet ("CompressorEnable") && m_Properties.GetNumber ("CompressorEnable", 1) == 0)
227242
{
228-
bool bValue = m_Properties.GetNumber ("CompressorEnable", 1);
229243
for (unsigned nTG = 0; nTG < CConfig::AllToneGenerators; nTG++)
230-
m_bCompressorEnable[nTG] = bValue;
244+
{
245+
m_bCompressorEnable[nTG] = 0;
246+
}
231247
}
232248

233249
return bResult;
@@ -339,6 +355,21 @@ bool CPerformanceConfig::Save (void)
339355
PropertyName.Format ("CompressorEnable%u", nTG+1);
340356
m_Properties.SetNumber (PropertyName, m_bCompressorEnable[nTG]);
341357

358+
PropertyName.Format ("CompressorPreGain%u", nTG+1);
359+
m_Properties.SetSignedNumber (PropertyName, m_nCompressorPreGain[nTG]);
360+
361+
PropertyName.Format ("CompressorAttack%u", nTG+1);
362+
m_Properties.SetNumber (PropertyName, m_nCompressorAttack[nTG]);
363+
364+
PropertyName.Format ("CompressorRelease%u", nTG+1);
365+
m_Properties.SetNumber (PropertyName, m_nCompressorRelease[nTG]);
366+
367+
PropertyName.Format ("CompressorThresh%u", nTG+1);
368+
m_Properties.SetSignedNumber (PropertyName, m_nCompressorThresh[nTG]);
369+
370+
PropertyName.Format ("CompressorRatio%u", nTG+1);
371+
m_Properties.SetNumber (PropertyName, m_nCompressorRatio[nTG]);
372+
342373
}
343374

344375
m_Properties.SetNumber ("ReverbEnable", m_bReverbEnable ? 1 : 0);
@@ -749,6 +780,67 @@ bool CPerformanceConfig::GetCompressorEnable (unsigned nTG) const
749780
return m_bCompressorEnable[nTG];
750781
}
751782

783+
void CPerformanceConfig::SetCompressorPreGain (int nValue, unsigned nTG)
784+
{
785+
assert (nTG < CConfig::AllToneGenerators);
786+
m_nCompressorPreGain[nTG] = nValue;
787+
}
788+
789+
int CPerformanceConfig::GetCompressorPreGain (unsigned nTG) const
790+
{
791+
assert (nTG < CConfig::AllToneGenerators);
792+
return m_nCompressorPreGain[nTG];
793+
}
794+
795+
void CPerformanceConfig::SetCompressorAttack (unsigned nValue, unsigned nTG)
796+
{
797+
assert (nTG < CConfig::AllToneGenerators);
798+
m_nCompressorAttack[nTG] = nValue;
799+
}
800+
801+
unsigned CPerformanceConfig::GetCompressorAttack (unsigned nTG) const
802+
{
803+
assert (nTG < CConfig::AllToneGenerators);
804+
return m_nCompressorAttack[nTG];
805+
}
806+
807+
void CPerformanceConfig::SetCompressorRelease (unsigned nValue, unsigned nTG)
808+
{
809+
assert (nTG < CConfig::AllToneGenerators);
810+
m_nCompressorRelease[nTG] = nValue;
811+
}
812+
813+
unsigned CPerformanceConfig::GetCompressorRelease (unsigned nTG) const
814+
{
815+
assert (nTG < CConfig::AllToneGenerators);
816+
return m_nCompressorRelease[nTG];
817+
}
818+
819+
void CPerformanceConfig::SetCompressorThresh (int nValue, unsigned nTG)
820+
{
821+
assert (nTG < CConfig::AllToneGenerators);
822+
m_nCompressorThresh[nTG] = nValue;
823+
}
824+
825+
int CPerformanceConfig::GetCompressorThresh (unsigned nTG) const
826+
{
827+
assert (nTG < CConfig::AllToneGenerators);
828+
return m_nCompressorThresh[nTG];
829+
}
830+
831+
void CPerformanceConfig::SetCompressorRatio (unsigned nValue, unsigned nTG)
832+
{
833+
assert (nTG < CConfig::AllToneGenerators);
834+
m_nCompressorRatio[nTG] = nValue;
835+
}
836+
837+
unsigned CPerformanceConfig::GetCompressorRatio (unsigned nTG) const
838+
{
839+
assert (nTG < CConfig::AllToneGenerators);
840+
return m_nCompressorRatio[nTG];
841+
}
842+
843+
752844
void CPerformanceConfig::SetVoiceDataToTxt (const uint8_t *pData, unsigned nTG)
753845
{
754846
assert (nTG < CConfig::AllToneGenerators);

src/performanceconfig.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ class CPerformanceConfig // Performance configuration
7272
unsigned GetAftertouchTarget (unsigned nTG) const; // 0 .. 7
7373

7474
bool GetCompressorEnable (unsigned nTG) const; // 0 .. 1
75+
int GetCompressorPreGain (unsigned nTG) const;
76+
unsigned GetCompressorAttack (unsigned nTG) const;
77+
unsigned GetCompressorRelease (unsigned nTG) const;
78+
int GetCompressorThresh (unsigned nTG) const;
79+
unsigned GetCompressorRatio (unsigned nTG) const;
7580

7681
void SetBankNumber (unsigned nValue, unsigned nTG);
7782
void SetVoiceNumber (unsigned nValue, unsigned nTG);
@@ -103,7 +108,12 @@ class CPerformanceConfig // Performance configuration
103108
void SetAftertouchRange (unsigned nValue, unsigned nTG);
104109
void SetAftertouchTarget (unsigned nValue, unsigned nTG);
105110

106-
void SetCompressorEnable (bool bCompressor, unsigned nTG);
111+
void SetCompressorEnable (bool nValue, unsigned nTG);
112+
void SetCompressorPreGain (int nValue, unsigned nTG);
113+
void SetCompressorAttack (unsigned nValue, unsigned nTG);
114+
void SetCompressorRelease (unsigned nValue, unsigned nTG);
115+
void SetCompressorThresh (int nValue, unsigned nTG);
116+
void SetCompressorRatio (unsigned nValue, unsigned nTG);
107117

108118
// Effects
109119
bool GetReverbEnable (void) const;
@@ -186,6 +196,11 @@ class CPerformanceConfig // Performance configuration
186196
unsigned m_nAftertouchTarget[CConfig::AllToneGenerators];
187197

188198
bool m_bCompressorEnable[CConfig::AllToneGenerators];
199+
int m_nCompressorPreGain[CConfig::AllToneGenerators];
200+
unsigned m_nCompressorAttack[CConfig::AllToneGenerators];
201+
unsigned m_nCompressorRelease[CConfig::AllToneGenerators];
202+
int m_nCompressorThresh[CConfig::AllToneGenerators];
203+
unsigned m_nCompressorRatio[CConfig::AllToneGenerators];
189204

190205
unsigned m_nLastPerformance;
191206
unsigned m_nActualPerformance = 0;

src/uimenu.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ const CUIMenu::TMenuItem CUIMenu::s_TGMenu[] =
9494
const CUIMenu::TMenuItem CUIMenu::s_EditCompressorMenu[] =
9595
{
9696
{"Enable", EditTGParameter, 0, CMiniDexed::TGParameterCompressorEnable},
97+
{"Pre Gain", EditTGParameter, 0, CMiniDexed::TGParameterCompressorPreGain},
98+
{"Attack", EditTGParameter, 0, CMiniDexed::TGParameterCompressorAttack},
99+
{"Release", EditTGParameter, 0, CMiniDexed::TGParameterCompressorRelease},
100+
{"Threshold", EditTGParameter, 0, CMiniDexed::TGParameterCompressorThresh},
101+
{"Ratio", EditTGParameter, 0, CMiniDexed::TGParameterCompressorRatio},
97102
{0}
98103
};
99104

@@ -272,6 +277,11 @@ const CUIMenu::TParameter CUIMenu::s_TGParameter[CMiniDexed::TGParameterUnknown]
272277
{0, 1, 1, ToOnOff}, //AT Amp
273278
{0, 1, 1, ToOnOff}, //AT EGBias
274279
{0, 1, 1, ToOnOff}, // TGParameterCompressorEnable
280+
{-12, 12, 1, TodB}, // TGParameterCompressorPreGain
281+
{0, 1000, 5, ToMillisec}, // TGParameterCompressorAttack
282+
{0, 1000, 5, ToMillisec}, // TGParameterCompressorRelease
283+
{-30, -20, 1, TodB}, // TGParameterCompressorThresh
284+
{1, 20, 1, ToRatio}, // TGParameterCompressorRatio
275285
};
276286

277287
// must match DexedVoiceParameters in Synth_Dexed
@@ -1245,6 +1255,21 @@ string CUIMenu::ToPolyMono (int nValue)
12451255
}
12461256
}
12471257

1258+
std::string CUIMenu::TodB (int nValue)
1259+
{
1260+
return std::to_string (nValue) + " dB";
1261+
}
1262+
1263+
std::string CUIMenu::ToMillisec (int nValue)
1264+
{
1265+
return std::to_string (nValue) + " ms";
1266+
}
1267+
1268+
std::string CUIMenu::ToRatio (int nValue)
1269+
{
1270+
return std::to_string (nValue) + ":1";
1271+
}
1272+
12481273
void CUIMenu::TGShortcutHandler (TMenuEvent Event)
12491274
{
12501275
assert (m_nCurrentMenuDepth >= 2);

src/uimenu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ class CUIMenu
118118
static std::string ToPortaMode (int nValue);
119119
static std::string ToPortaGlissando (int nValue);
120120
static std::string ToPolyMono (int nValue);
121+
static std::string TodB (int nValue);
122+
static std::string ToMillisec (int nValue);
123+
static std::string ToRatio (int nValue);
121124

122125
void TGShortcutHandler (TMenuEvent Event);
123126
void OPShortcutHandler (TMenuEvent Event);

0 commit comments

Comments
 (0)