diff --git a/src/mididevice.cpp b/src/mididevice.cpp index 192821f..ad19b63 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -31,35 +31,35 @@ LOGMODULE ("mididevice"); -#define MIDI_NOTE_OFF 0b1000 -#define MIDI_NOTE_ON 0b1001 -#define MIDI_AFTERTOUCH 0b1010 // TODO -#define MIDI_CHANNEL_AFTERTOUCH 0b1101 // right now Synth_Dexed just manage Channel Aftertouch not Polyphonic AT -> 0b1010 -#define MIDI_CONTROL_CHANGE 0b1011 - #define MIDI_CC_BANK_SELECT_MSB 0 - #define MIDI_CC_MODULATION 1 - #define MIDI_CC_BREATH_CONTROLLER 2 - #define MIDI_CC_FOOT_PEDAL 4 - #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_RESONANCE 71 - #define MIDI_CC_FREQUENCY_CUTOFF 74 - #define MIDI_CC_REVERB_LEVEL 91 - #define MIDI_CC_ORBITONE_LEVEL 92 // added with mixing console - #define MIDI_CC_CHORUS_LEVEL 93 // added with mixing console - #define MIDI_CC_DETUNE_LEVEL 94 - #define MIDI_CC_PHASER_LEVEL 95 // added with mixing console +#define MIDI_NOTE_OFF 0b1000 +#define MIDI_NOTE_ON 0b1001 +#define MIDI_AFTERTOUCH 0b1010 // TODO +#define MIDI_CHANNEL_AFTERTOUCH 0b1101 // right now Synth_Dexed just manage Channel Aftertouch not Polyphonic AT -> 0b1010 +#define MIDI_CONTROL_CHANGE 0b1011 + #define MIDI_CC_BANK_SELECT_MSB 0 + #define MIDI_CC_MODULATION 1 + #define MIDI_CC_BREATH_CONTROLLER 2 + #define MIDI_CC_FOOT_PEDAL 4 + #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_RESONANCE 71 + #define MIDI_CC_FREQUENCY_CUTOFF 74 + #define MIDI_CC_REVERB_LEVEL 91 + #define MIDI_CC_ORBITONE_LEVEL 92 // added with mixing console + #define MIDI_CC_CHORUS_LEVEL 93 // added with mixing console + #define MIDI_CC_DETUNE_LEVEL 94 + #define MIDI_CC_PHASER_LEVEL 95 // added with mixing console #define MIDI_CC_ALL_SOUND_OFF 120 #define MIDI_CC_ALL_NOTES_OFF 123 -#define MIDI_PROGRAM_CHANGE 0b1100 -#define MIDI_PITCH_BEND 0b1110 +#define MIDI_PROGRAM_CHANGE 0b1100 +#define MIDI_PITCH_BEND 0b1110 -#define MIDI_SYSTEM_EXCLUSIVE_BEGIN 0xF0 -#define MIDI_SYSTEM_EXCLUSIVE_END 0xF7 -#define MIDI_TIMING_CLOCK 0xF8 -#define MIDI_ACTIVE_SENSING 0xFE +#define MIDI_SYSTEM_EXCLUSIVE_BEGIN 0xF0 +#define MIDI_SYSTEM_EXCLUSIVE_END 0xF7 +#define MIDI_TIMING_CLOCK 0xF8 +#define MIDI_ACTIVE_SENSING 0xFE CMIDIDevice::TDeviceMap CMIDIDevice::s_DeviceMap; diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 960bd8d..465dc36 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -552,7 +552,7 @@ void CMiniDexed::SetPan (unsigned nPan, unsigned nTG) m_nPan[nTG] = nPan; #if defined(MIXING_CONSOLE_ENABLE) - this->mixing_console_->setPan(nTG, mapfloat(nPan, 0, 127, 0.0f, 1.0f)); + this->mixing_console_->setPan(nTG, nPan / 127.0f); #elif defined(PLATE_REVERB_ENABLE) @@ -1506,41 +1506,41 @@ void CMiniDexed::SetTGParameter (TTGParameter Parameter, int nValue, unsigned nT switch (Parameter) { - case TGParameterVoiceBank: BankSelect (nValue, nTG); break; - case TGParameterVoiceBankMSB: BankSelectMSB (nValue, nTG); break; - case TGParameterVoiceBankLSB: BankSelectLSB (nValue, nTG); break; - case TGParameterProgram: ProgramChange (nValue, nTG); break; - 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 TGParameterPitchBendRange: setPitchbendRange (nValue, nTG); break; - case TGParameterPitchBendStep: setPitchbendStep (nValue, nTG); break; - case TGParameterPortamentoMode: setPortamentoMode (nValue, nTG); break; - case TGParameterPortamentoGlissando: setPortamentoGlissando (nValue, nTG); break; - case TGParameterPortamentoTime: setPortamentoTime (nValue, nTG); break; - case TGParameterMonoMode: setMonoMode (nValue , nTG); break; + case TTGParameter::TGParameterVoiceBank: this->BankSelect (nValue, nTG); break; + case TTGParameter::TGParameterVoiceBankMSB: this->BankSelectMSB (nValue, nTG); break; + case TTGParameter::TGParameterVoiceBankLSB: this->BankSelectLSB (nValue, nTG); break; + case TTGParameter::TGParameterProgram: this->ProgramChange (nValue, nTG); break; + case TTGParameter::TGParameterVolume: this->SetVolume (nValue, nTG); break; + case TTGParameter::TGParameterPan: this->SetPan (nValue, nTG); break; + case TTGParameter::TGParameterMasterTune: this->SetMasterTune (nValue, nTG); break; + case TTGParameter::TGParameterCutoff: this->SetCutoff (nValue, nTG); break; + case TTGParameter::TGParameterResonance: this->SetResonance (nValue, nTG); break; + case TTGParameter::TGParameterPitchBendRange: this->setPitchbendRange (nValue, nTG); break; + case TTGParameter::TGParameterPitchBendStep: this->setPitchbendStep (nValue, nTG); break; + case TTGParameter::TGParameterPortamentoMode: this->setPortamentoMode (nValue, nTG); break; + case TTGParameter::TGParameterPortamentoGlissando: this->setPortamentoGlissando (nValue, nTG); break; + case TTGParameter::TGParameterPortamentoTime: this->setPortamentoTime (nValue, nTG); break; + case TTGParameter::TGParameterMonoMode: this->setMonoMode (nValue , nTG); break; - case TTGParameter::TGParameterMWRange: setModController(0, 0, nValue, nTG); break; - case TTGParameter::TGParameterMWPitch: setModController(0, 1, nValue, nTG); break; - case TTGParameter::TGParameterMWAmplitude: setModController(0, 2, nValue, nTG); break; - case TTGParameter::TGParameterMWEGBias: setModController(0, 3, nValue, nTG); break; + case TTGParameter::TGParameterMWRange: this->setModController(0, 0, nValue, nTG); break; + case TTGParameter::TGParameterMWPitch: this->setModController(0, 1, nValue, nTG); break; + case TTGParameter::TGParameterMWAmplitude: this->setModController(0, 2, nValue, nTG); break; + case TTGParameter::TGParameterMWEGBias: this->setModController(0, 3, nValue, nTG); break; - case TTGParameter::TGParameterFCRange: setModController(1, 0, nValue, nTG); break; - case TTGParameter::TGParameterFCPitch: setModController(1, 1, nValue, nTG); break; - case TTGParameter::TGParameterFCAmplitude: setModController(1, 2, nValue, nTG); break; - case TTGParameter::TGParameterFCEGBias: setModController(1, 3, nValue, nTG); break; + case TTGParameter::TGParameterFCRange: this->setModController(1, 0, nValue, nTG); break; + case TTGParameter::TGParameterFCPitch: this->setModController(1, 1, nValue, nTG); break; + case TTGParameter::TGParameterFCAmplitude: this->setModController(1, 2, nValue, nTG); break; + case TTGParameter::TGParameterFCEGBias: this->setModController(1, 3, nValue, nTG); break; - case TTGParameter::TGParameterBCRange: setModController(2, 0, nValue, nTG); break; - case TTGParameter::TGParameterBCPitch: setModController(2, 1, nValue, nTG); break; - case TTGParameter::TGParameterBCAmplitude: setModController(2, 2, nValue, nTG); break; - case TTGParameter::TGParameterBCEGBias: setModController(2, 3, nValue, nTG); break; + case TTGParameter::TGParameterBCRange: this->setModController(2, 0, nValue, nTG); break; + case TTGParameter::TGParameterBCPitch: this->setModController(2, 1, nValue, nTG); break; + case TTGParameter::TGParameterBCAmplitude: this->setModController(2, 2, nValue, nTG); break; + case TTGParameter::TGParameterBCEGBias: this->setModController(2, 3, nValue, nTG); break; - case TTGParameter::TGParameterATRange: setModController(3, 0, nValue, nTG); break; - case TTGParameter::TGParameterATPitch: setModController(3, 1, nValue, nTG); break; - case TTGParameter::TGParameterATAmplitude: setModController(3, 2, nValue, nTG); break; - case TTGParameter::TGParameterATEGBias: setModController(3, 3, nValue, nTG); break; + case TTGParameter::TGParameterATRange: this->setModController(3, 0, nValue, nTG); break; + case TTGParameter::TGParameterATPitch: this->setModController(3, 1, nValue, nTG); break; + case TTGParameter::TGParameterATAmplitude: this->setModController(3, 2, nValue, nTG); break; + case TTGParameter::TGParameterATEGBias: this->setModController(3, 3, nValue, nTG); break; case TTGParameter::TGParameterMIDIChannel: assert (0 <= nValue && nValue <= 255); @@ -1558,7 +1558,7 @@ void CMiniDexed::SetTGParameter (TTGParameter Parameter, int nValue, unsigned nT case TTGParameter::TGParameterMixingSendFXReverberator: this->setMixingConsoleSendLevel(nTG, MixerOutput::FX_Reverberator, nValue); break; case TTGParameter::TGParameterMixingSendFXMainOutput: this->setMixingConsoleSendLevel(nTG, MixerOutput::MainOutput, nValue); break; #elif defined(PLATE_REVERB_ENABLE) - case TTGParameter::TGParameterReverbSend: this->SetReverbSend (nValue, nTG); break; + case TTGParameter::TGParameterReverbSend: this->SetReverbSend (nValue, nTG); break; #endif // MIXING_CONSOLE_ENABLE default: diff --git a/src/mixing_console.hpp b/src/mixing_console.hpp index 221fca6..72db76e 100644 --- a/src/mixing_console.hpp +++ b/src/mixing_console.hpp @@ -43,12 +43,11 @@ public: ~MixingConsole(); // Send section - inline void setChannelLevel(size_t in, float32_t lvl); inline void setPan(size_t in, float32_t pan); inline void setSendLevel(size_t in, MixerOutput fx, float32_t lvl); inline void setInputSample(size_t in, float32_t sampleL, float32_t sampleR); inline void setInputSampleBuffer(size_t in, float32_t* samples); - inline void setInputSampleBuffer(size_t in, float32_t* samplesL, float32_t* samplesR); + inline void copyInputSampleBuffer(size_t in, float32_t* samplesL, float32_t* samplesR); inline void preProcessInputSampleBuffer(size_t in, size_t nSamples); // Return section @@ -74,14 +73,12 @@ public: void process(float32_t* outL, float32_t* outR); protected: - inline void updatePan(size_t in); inline void setLevel(size_t in, MixerOutput fx, float32_t lvl); inline void setSample(size_t in, float32_t sampleL, float32_t sampleR); private: const size_t BufferSize; - float32_t channel_level_[nb_inputs]; float32_t pan_[StereoChannels::kNumChannels + 1][nb_inputs]; float32_t* tg_input_sample_buffer_[nb_inputs]; float32_t* input_sample_buffer_[StereoChannels::kNumChannels][nb_inputs]; @@ -112,7 +109,6 @@ private: { SS_RESET(ss, precision, std::left); SS_SPACE(ss, ' ', space, std::left, '|'); - SS__TEXT(ss, ' ', space, std::left, '|', "Level"); SS__TEXT(ss, ' ', space, std::left, '|', "Pan L"); SS__TEXT(ss, ' ', space, std::left, '|', "Pan R"); SS__TEXT(ss, ' ', space, std::left, '|', "Pan"); @@ -123,7 +119,6 @@ private: SS_SPACE(ss, '-', space, std::left, '+'); SS_SPACE(ss, '-', space, std::left, '+'); SS_SPACE(ss, '-', space, std::left, '+'); - SS_SPACE(ss, '-', space, std::left, '+'); out << "\t" << ss.str() << std::endl; for(size_t i = 0; i < nb_inputs; ++i) @@ -134,7 +129,6 @@ private: SS_RESET(ss, precision, std::left); SS__TEXT(ss, ' ', space, std::left, '|', s.str()); - SS__TEXT(ss, ' ', space - 1, std::right, " |", this->channel_level_[i]); SS__TEXT(ss, ' ', space - 1, std::right, " |", this->pan_[StereoChannels::Left][i]); SS__TEXT(ss, ' ', space - 1, std::right, " |", this->pan_[StereoChannels::Right][i]); SS__TEXT(ss, ' ', space - 1, std::right, " |", this->pan_[StereoChannels::kNumChannels][i]); @@ -262,7 +256,6 @@ private: for(size_t i = 0; i < nb_inputs; ++i) { - nb_errors += inspector(tag + ".level[ input #" + std::to_string(i) + " ]" , this->channel_level_[i], -1.0f, 1.0f, deepInspection); nb_errors += inspector(tag + ".pan[ L ][ input #" + std::to_string(i) + " ]", this->pan_[StereoChannels::Left][i], -1.0f, 1.0f, deepInspection); nb_errors += inspector(tag + ".pan[ R ][ input #" + std::to_string(i) + " ]", this->pan_[StereoChannels::Right][i], -1.0f, 1.0f, deepInspection); nb_errors += inspector(tag + ".pan[ input #" + std::to_string(i) + " ]", this->pan_[StereoChannels::kNumChannels][i], -1.0f, 1.0f, deepInspection); @@ -360,18 +353,6 @@ MixingConsole::~MixingConsole() } // Send section -template -void MixingConsole::setChannelLevel(size_t in, float32_t lvl) -{ - assert(in < nb_inputs); - - lvl = constrain(lvl, 0.0f, 1.0f); - if(lvl == this->channel_level_[in]) return; - - this->channel_level_[in] = lvl; - this->updatePan(in); -} - template void MixingConsole::setPan(size_t in, float32_t pan) { @@ -382,7 +363,10 @@ void MixingConsole::setPan(size_t in, float32_t pan) if(pan == this->pan_[StereoChannels::kNumChannels][in]) return; this->pan_[StereoChannels::kNumChannels][in] = pan; - this->updatePan(in); + + pan *= Constants::MPI_2; + this->pan_[StereoChannels::Left ][in] = InterpolatedSineOscillator::Cos(pan); + this->pan_[StereoChannels::Right][in] = InterpolatedSineOscillator::Sin(pan); } template @@ -411,7 +395,7 @@ void MixingConsole::setInputSampleBuffer(size_t in, float32_t* sample } template -void MixingConsole::setInputSampleBuffer(size_t in, float32_t* samplesL, float32_t* samplesR) +void MixingConsole::copyInputSampleBuffer(size_t in, float32_t* samplesL, float32_t* samplesR) { // Only used to input stereo samples assert(in < nb_inputs); @@ -561,7 +545,6 @@ FXUnit2* MixingConsole::getDry() template void MixingConsole::init() { - memset(this->channel_level_, 0, nb_inputs * sizeof(float32_t)); for(size_t i = 0; i <= StereoChannels::kNumChannels; ++i) memset(this->pan_[i], 0, nb_inputs * sizeof(float32_t)); for(size_t i = 0; i < MixerOutput::kFXCount; ++i) @@ -653,24 +636,6 @@ void MixingConsole::process(float32_t* outL, float32_t* outR) this->m_nSamples = 0; } -template -void MixingConsole::updatePan(size_t in) -{ - float32_t pan = this->pan_[StereoChannels::kNumChannels][in] * Constants::MPI_2; - if(this->channel_level_[in] != 0.0f) - { - // this->pan_[StereoChannels::Left ][in] = arm_cos_f32(pan) * this->channel_level_[in]; - // this->pan_[StereoChannels::Right][in] = arm_sin_f32(pan) * this->channel_level_[in]; - this->pan_[StereoChannels::Left ][in] = InterpolatedSineOscillator::Cos(pan) * this->channel_level_[in]; - this->pan_[StereoChannels::Right][in] = InterpolatedSineOscillator::Sin(pan) * this->channel_level_[in]; - } - else - { - this->pan_[StereoChannels::Left ][in] = - this->pan_[StereoChannels::Right][in] = 0.0f; - } -} - template void MixingConsole::setLevel(size_t in, MixerOutput fx, float32_t lvl) { diff --git a/src/test/test_fx_mixing_console.cpp b/src/test/test_fx_mixing_console.cpp index 56ceea7..d92c806 100644 --- a/src/test/test_fx_mixing_console.cpp +++ b/src/test/test_fx_mixing_console.cpp @@ -25,6 +25,8 @@ INSTANTIATE_TEST_SUITE_P(MixerOutputTest, MixingConsoleScenarioTest, testing::Ra void setupMixingConsoleFX(Mixer* mixer) { + mixer->setPan(0, 0.5f); + mixer->getTube()->setMute(false); mixer->getTube()->setOverdrive(0.25f); @@ -83,7 +85,6 @@ void setupMixingConsoleFX(Mixer* mixer, int scenarioId) ACTIVE_FX(scenarioId, FX_PlateReverb); ACTIVE_FX(scenarioId, FX_Reverberator); - mixer->setChannelLevel(0, 1.0f); mixer->setPan(0, 0.5f); size_t nbActiveFX = 0; @@ -216,9 +217,6 @@ TEST(MixingConsole, ZeroSamplesTest) setupMixingConsoleFX(&mixer); ASSERT_EQ(0, FULL_INSPECT((&mixer), true)); - mixer.setChannelLevel(0, 1.0f); - ASSERT_EQ(0, FULL_INSPECT((&mixer), true)); - mixer.setPan(0, 0.5f); ASSERT_EQ(0, FULL_INSPECT((&mixer), true)); @@ -269,7 +267,6 @@ TEST(MixingConsole, DryProcessing) mixer.setReturnLevel(static_cast(i), MixerOutput::MainOutput, 0.0f); } - mixer.setChannelLevel(0, 1.0f); mixer.setPan(0, 0.5f); mixer.setSendLevel(0, MixerOutput::MainOutput, 1.0f); ASSERT_EQ(0, INSPECT((&mixer), fullInspector)); @@ -305,7 +302,6 @@ TEST(MixingConsole, ReverberatorProcessing) mixer.setSendLevel(0, MixerOutput::MainOutput, 0.0f); mixer.setSendLevel(0, MixerOutput::FX_Reverberator, 1.0f); mixer.setReturnLevel(MixerOutput::FX_Reverberator, MixerOutput::MainOutput, 1.0f); - mixer.setChannelLevel(0, 1.0f); mixer.setPan(0, 0.5f); ASSERT_EQ(0, INSPECT((&mixer), fullInspector)); @@ -351,7 +347,6 @@ TEST(MixingConsole, ReverberatorNoiseProcessing) mixer.setSendLevel(0, MixerOutput::MainOutput, 0.0f); mixer.setSendLevel(0, MixerOutput::FX_Reverberator, 1.0f); mixer.setReturnLevel(MixerOutput::FX_Reverberator, MixerOutput::MainOutput, 1.0f); - mixer.setChannelLevel(0, 1.0f); mixer.setPan(0, 0.5f); ASSERT_EQ(0, INSPECT((&mixer), fullInspector)); @@ -395,7 +390,7 @@ TEST(MixingConsole, StandardUsageProcessing) mixer.setReturnLevel(MixerOutput::FX_Reverberator, MixerOutput::MainOutput, 0.3f); mixer.setReturnLevel(MixerOutput::FX_Delay, MixerOutput::MainOutput, 0.3f); - mixer.setInputSampleBuffer(0, inSamples[0], inSamples[1]); + mixer.setInputSampleBuffer(0, inSamples[0]); mixer.preProcessInputSampleBuffer(0, size); mixer.process(outSamples[0], outSamples[1]); ASSERT_EQ(0, INSPECT((&mixer), fullInspector)); diff --git a/src/test/test_fx_mixing_console_unitary.cpp b/src/test/test_fx_mixing_console_unitary.cpp index f43acc5..e7e7f83 100644 --- a/src/test/test_fx_mixing_console_unitary.cpp +++ b/src/test/test_fx_mixing_console_unitary.cpp @@ -17,7 +17,6 @@ TEST(MixingConsole, ShortBuffer) const size_t size = 10; Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, size); - mixer->setChannelLevel(0, 1.0f); mixer->setPan(0, 0.5f); mixer->setSendLevel(0, MixerOutput::MainOutput, 1.0f); @@ -53,7 +52,6 @@ TEST(MixingConsole, ReverberatorShortBuffer) const size_t size = 10; Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, size); - mixer->setChannelLevel(0, 1.0f); mixer->setPan(0, 0.5f); mixer->getReverberator()->setInputGain(0.35f); @@ -95,7 +93,6 @@ TEST(MixingConsole, DrySamplesBoundariesTest) mixer->reset(); FULL_INSPECT2(mixer, true, "Mixer.reset"); - mixer->setChannelLevel(0, 1.0f); mixer->setPan(0, 0.5f); mixer->setSendLevel(0, MixerOutput::MainOutput, 1.0f); @@ -147,7 +144,6 @@ TEST(MixingConsole, ReverberatorSamplesBoundariesTest) Mixer* mixer = new Mixer(SAMPLING_FREQUENCY, size); mixer->reset(); - mixer->setChannelLevel(0, 1.0f); mixer->setPan(0, 0.5f); mixer->setSendLevel(0, MixerOutput::MainOutput, 0.4f);