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

Update Synth_Dexed to 65d8383ad5 #791

Closed
wants to merge 6 commits into from
Closed
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
9 changes: 5 additions & 4 deletions src/effect_compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MIT License. use at your own risk.
*/

#include <algorithm>
#include <circle/logger.h>
#include <cstdlib>
#include "effect_compressor.h"
Expand Down Expand Up @@ -203,7 +204,7 @@ void Compressor::setPreGain_dB(float32_t gain_dB)

void Compressor::setCompressionRatio(float32_t cr)
{
comp_ratio = max(0.001f, cr); //limit to positive values
comp_ratio = std::max(0.001f, cr); //limit to positive values
updateThresholdAndCompRatioConstants();
}

Expand All @@ -213,7 +214,7 @@ void Compressor::setAttack_sec(float32_t a, float32_t fs_Hz)
attack_const = expf(-1.0f / (attack_sec * fs_Hz)); //expf() is much faster than exp()

//also update the time constant for the envelope extraction
setLevelTimeConst_sec(min(attack_sec,release_sec) / 5.0, fs_Hz); //make the level time-constant one-fifth the gain time constants
setLevelTimeConst_sec(std::min(attack_sec,release_sec) / 5.0, fs_Hz); //make the level time-constant one-fifth the gain time constants
}

void Compressor::setRelease_sec(float32_t r, float32_t fs_Hz)
Expand All @@ -222,13 +223,13 @@ void Compressor::setRelease_sec(float32_t r, float32_t fs_Hz)
release_const = expf(-1.0f / (release_sec * fs_Hz)); //expf() is much faster than exp()

//also update the time constant for the envelope extraction
setLevelTimeConst_sec(min(attack_sec,release_sec) / 5.0, fs_Hz); //make the level time-constant one-fifth the gain time constants
setLevelTimeConst_sec(std::min(attack_sec,release_sec) / 5.0, fs_Hz); //make the level time-constant one-fifth the gain time constants
}

void Compressor::setLevelTimeConst_sec(float32_t t_sec, float32_t fs_Hz)
{
const float32_t min_t_sec = 0.002f; //this is the minimum allowed value
level_lp_sec = max(min_t_sec,t_sec);
level_lp_sec = std::max(min_t_sec,t_sec);
level_lp_const = expf(-1.0f / (level_lp_sec * fs_Hz)); //expf() is much faster than exp()
}

Expand Down
20 changes: 20 additions & 0 deletions src/mididevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ LOGMODULE ("mididevice");
#define MIDI_CC_MODULATION 1
#define MIDI_CC_BREATH_CONTROLLER 2
#define MIDI_CC_FOOT_PEDAL 4
#define MIDI_CC_PORTAMENTO_TIME 5
#define MIDI_CC_VOLUME 7
#define MIDI_CC_PAN_POSITION 10
#define MIDI_CC_BANK_SELECT_LSB 32
#define MIDI_CC_BANK_SUSTAIN 64
#define MIDI_CC_PORTAMENTO 65
#define MIDI_CC_SOSTENUTO 66
#define MIDI_CC_HOLD2 69
#define MIDI_CC_RESONANCE 71
#define MIDI_CC_FREQUENCY_CUTOFF 74
#define MIDI_CC_REVERB_LEVEL 91
Expand Down Expand Up @@ -385,6 +389,10 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
m_pSynthesizer->ControllersRefresh (nTG);
break;

case MIDI_CC_PORTAMENTO_TIME:
m_pSynthesizer->setPortamentoTime (maplong (pMessage[2], 0, 127, 0, 99), nTG);
break;

case MIDI_CC_BREATH_CONTROLLER:
m_pSynthesizer->setBreathController (pMessage[2], nTG);
m_pSynthesizer->ControllersRefresh (nTG);
Expand All @@ -409,6 +417,18 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
case MIDI_CC_BANK_SUSTAIN:
m_pSynthesizer->setSustain (pMessage[2] >= 64, nTG);
break;

case MIDI_CC_SOSTENUTO:
m_pSynthesizer->setSostenuto (pMessage[2] >= 64, nTG);
break;

case MIDI_CC_PORTAMENTO:
m_pSynthesizer->setPortamentoMode (pMessage[2] >= 64, nTG);
break;

case MIDI_CC_HOLD2:
m_pSynthesizer->setHoldMode (pMessage[2] >= 64, nTG);
break;

case MIDI_CC_RESONANCE:
m_pSynthesizer->SetResonance (maplong (pMessage[2], 0, 127, 0, 99), nTG);
Expand Down
22 changes: 20 additions & 2 deletions src/minidexed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,24 @@ void CMiniDexed::setSustain(bool sustain, unsigned nTG)
m_pTG[nTG]->setSustain (sustain);
}

void CMiniDexed::setSostenuto(bool sostenuto, unsigned nTG)
{
assert (nTG < CConfig::AllToneGenerators);
if (nTG >= m_nToneGenerators) return; // Not an active TG

assert (m_pTG[nTG]);
m_pTG[nTG]->setSostenuto (sostenuto);
}

void CMiniDexed::setHoldMode(bool holdmode, unsigned nTG)
{
assert (nTG < CConfig::AllToneGenerators);
if (nTG >= m_nToneGenerators) return; // Not an active TG

assert (m_pTG[nTG]);
m_pTG[nTG]->setHold (holdmode);
}

void CMiniDexed::panic(uint8_t value, unsigned nTG)
{
assert (nTG < CConfig::AllToneGenerators);
Expand Down Expand Up @@ -1169,7 +1187,7 @@ std::string CMiniDexed::GetVoiceName (unsigned nTG)
if (nTG < m_nToneGenerators)
{
assert (m_pTG[nTG]);
m_pTG[nTG]->setName (VoiceName);
m_pTG[nTG]->getName (VoiceName);
}
std::string Result (VoiceName);
return Result;
Expand Down Expand Up @@ -1992,7 +2010,7 @@ void CMiniDexed::SetVoiceName (const std::string &VoiceName, unsigned nTG)
char Name[11];
strncpy(Name, VoiceName.c_str(),10);
Name[10] = '\0';
m_pTG[nTG]->getName (Name);
m_pTG[nTG]->setName (Name);
}

bool CMiniDexed::DeletePerformance(unsigned nID)
Expand Down
2 changes: 2 additions & 0 deletions src/minidexed.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class CMiniDexed
void keydown (int16_t pitch, uint8_t velocity, unsigned nTG);

void setSustain (bool sustain, unsigned nTG);
void setSostenuto (bool sostenuto, unsigned nTG);
void setHoldMode(bool holdmode, unsigned nTG);
void panic (uint8_t value, unsigned nTG);
void notesOff (uint8_t value, unsigned nTG);
void setModWheel (uint8_t value, unsigned nTG);
Expand Down
2 changes: 1 addition & 1 deletion submod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ cd -
#
# Use fixed master branch of Synth_Dexed
cd Synth_Dexed/
git checkout c9f5274
git checkout 65d8383ad5
cd -