From 0f8abfd428a6e80447588863aafbcbaa46a1b2bc Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Sat, 15 Aug 2020 12:32:16 +0000 Subject: [PATCH] - LFO: added Sync modes Frequency, Phase and Frequency + Phase - added GUI Parameter MIDISYNC_MODE and MIDISYNC_BERATDIV - wired MIDISYNC params down to global LFO git-svn-id: http://moon:8086/svn/software/trunk/projects/JaySynth@726 b431acfa-c32f-4a4a-93f1-934dc6c82436 --- Source/JaySynth.cpp | 27 ++++-- Source/JaySynthAudioProcessorEditor.cpp | 118 +++++++++++++++++++++--- Source/JaySynthAudioProcessorEditor.h | 3 + Source/synth/lfo.c | 74 +++++++++++---- Source/synth/lfo.h | 15 ++- Source/synth/param_scale.c | 42 ++++++++- Source/synth/param_scale.h | 8 ++ Source/synth/voice.c | 25 +++++ Source/synth/voice.h | 8 ++ 9 files changed, 278 insertions(+), 42 deletions(-) diff --git a/Source/JaySynth.cpp b/Source/JaySynth.cpp index 8a36354..1c35d37 100644 --- a/Source/JaySynth.cpp +++ b/Source/JaySynth.cpp @@ -28,9 +28,8 @@ #include "synth/lfo.h" #ifndef WITH_DEV_SYNCED_LFO -#define WITH_DEV_SYNCED_LFO 0 +#define WITH_DEV_SYNCED_LFO 1 #endif -#define DEV_SYNCED_LFO_FACTOR 1 //============================================================================== /** A JaySynth that just plays incredible sounds.. */ @@ -93,7 +92,7 @@ JaySynth::JaySynth (int num_voices, String pathToWaves) ppHumanizedSliders[i] = new synth_float_t[max_num_voices]; for (j=0; j < max_num_voices; j++) { - sprintf(paramName, "%s Voice# %03d", getParamInfo(i)->pName, j); + snprintf(paramName, sizeof(paramName), "%s Voice# %03d", getParamInfo(i)->pName, j); paramInfoInit(&humanize_voice_param[i][j], getParamInfo(i)->id, paramName); paramInfoCopy(&humanize_voice_param[i][j], getParamInfo(i)); ppHumanizedSliders[i][j] = 0; @@ -809,6 +808,20 @@ void JaySynth::setParam(int paramID, int voice) voice_param_type = VOICE_PARAM_LFO_0_SYMMETRY + (paramID - SYNTH_PARAM_LFO_0_SYMMETRY); break; + case SYNTH_PARAM_LFO_0_MIDISYNC_MODE: + case SYNTH_PARAM_LFO_1_MIDISYNC_MODE: + case SYNTH_PARAM_LFO_2_MIDISYNC_MODE: + case SYNTH_PARAM_LFO_3_MIDISYNC_MODE: + voice_param_type = VOICE_PARAM_LFO_0_MIDISYNC_MODE + (paramID - SYNTH_PARAM_LFO_0_MIDISYNC_MODE); + break; + + case SYNTH_PARAM_LFO_0_MIDISYNC_BEATDIV: + case SYNTH_PARAM_LFO_1_MIDISYNC_BEATDIV: + case SYNTH_PARAM_LFO_2_MIDISYNC_BEATDIV: + case SYNTH_PARAM_LFO_3_MIDISYNC_BEATDIV: + voice_param_type = VOICE_PARAM_LFO_0_MIDISYNC_BEATDIV + (paramID - SYNTH_PARAM_LFO_0_MIDISYNC_BEATDIV); + break; + default: break; } @@ -1153,7 +1166,7 @@ void JaySynth::handleMidiEvent (const MidiMessage& m) if (m_isMidiClockStarted) { #if WITH_DEV_SYNCED_LFO - voiceSetMidiBeat(m_clock_cnt_bar % m_numMidiclocksPerQuarterNote); + voiceSetMidiBeat(m_clock_cnt_bar); #endif if (m_clock_cnt_bar % m_numMidiClocksPerBeat == 0) { @@ -1173,16 +1186,16 @@ void JaySynth::handleMidiEvent (const MidiMessage& m) } } -void JaySynth::voiceSetMidiBeat(int quarterBeatCount) +void JaySynth::voiceSetMidiBeat(int barBeatCount) { lfo_t *pLfo = &m_pVoices[0].pCom->glfo[0]; - synth_float_t phase = Sync_mod(DEV_SYNCED_LFO_FACTOR*(synth_float_t)quarterBeatCount/m_numMidiclocksPerQuarterNote, 1.0); + synth_float_t phase = Sync_mod((synth_float_t)barBeatCount/m_numMidiClocksPerBar, 1.0); LFO_sync(pLfo, phase); for (int i=0; i < max_num_voices; i++) { JaySynthVoice* const voice = voices.getUnchecked (i); - voice->setMidiBeat(quarterBeatCount); + voice->setMidiBeat(barBeatCount); } } diff --git a/Source/JaySynthAudioProcessorEditor.cpp b/Source/JaySynthAudioProcessorEditor.cpp index 5a1a897..b82b4d0 100644 --- a/Source/JaySynthAudioProcessorEditor.cpp +++ b/Source/JaySynthAudioProcessorEditor.cpp @@ -1896,6 +1896,39 @@ JaySynthAudioProcessorEditor::JaySynthAudioProcessorEditor (JaySynthAudioProcess m_labelDebug->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); addAndMakeVisible (m_btn_midiClockLed = new ButtonLED (L"MidiClock")); + addAndMakeVisible (m_label_lfo0_midisync_factor = new Label ("LFO 1 Midi Sync. Factor", + TRANS("value"))); + m_label_lfo0_midisync_factor->setTooltip (TRANS("LFO 1 Midi Sync. Factor")); + m_label_lfo0_midisync_factor->setFont (Font (14.00f, Font::plain)); + m_label_lfo0_midisync_factor->setJustificationType (Justification::centred); + m_label_lfo0_midisync_factor->setEditable (true, true, false); + m_label_lfo0_midisync_factor->setColour (Label::outlineColourId, Colour (0x00000000)); + m_label_lfo0_midisync_factor->setColour (TextEditor::textColourId, Colours::azure); + m_label_lfo0_midisync_factor->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); + m_label_lfo0_midisync_factor->setColour (TextEditor::highlightColourId, Colour (0x00f7f7f7)); + m_label_lfo0_midisync_factor->addListener (this); + + addAndMakeVisible (m_slider_lfo0_midisync_divisor = new Slider ("LFO 1 Midi Sync Divisor")); + m_slider_lfo0_midisync_divisor->setTooltip (TRANS("LFO 1 Midi Sync Divisor")); + m_slider_lfo0_midisync_divisor->setRange (0, 1, 0); + m_slider_lfo0_midisync_divisor->setSliderStyle (Slider::RotaryVerticalDrag); + m_slider_lfo0_midisync_divisor->setTextBoxStyle (Slider::NoTextBox, false, 80, 20); + m_slider_lfo0_midisync_divisor->setColour (Slider::rotarySliderFillColourId, Colour (0x7fffffff)); + m_slider_lfo0_midisync_divisor->setColour (Slider::rotarySliderOutlineColourId, Colour (0x66ffffff)); + m_slider_lfo0_midisync_divisor->addListener (this); + + addAndMakeVisible (m_comboBox_lfo0_midisync_mode = new ComboBox ("LFO 1 Midi Sync Mode")); + m_comboBox_lfo0_midisync_mode->setTooltip (TRANS("LFO 1 Midi Sync Mode")); + m_comboBox_lfo0_midisync_mode->setEditableText (false); + m_comboBox_lfo0_midisync_mode->setJustificationType (Justification::centred); + m_comboBox_lfo0_midisync_mode->setTextWhenNothingSelected (String::empty); + m_comboBox_lfo0_midisync_mode->setTextWhenNoChoicesAvailable (TRANS("(no choices)")); + m_comboBox_lfo0_midisync_mode->addItem (TRANS("Off"), 1); + m_comboBox_lfo0_midisync_mode->addItem (TRANS("F"), 2); + m_comboBox_lfo0_midisync_mode->addItem (TRANS("P"), 3); + m_comboBox_lfo0_midisync_mode->addItem (TRANS("F + P"), 4); + m_comboBox_lfo0_midisync_mode->addListener (this); + //[UserPreSize] //[/UserPreSize] @@ -2183,6 +2216,10 @@ JaySynthAudioProcessorEditor::JaySynthAudioProcessorEditor (JaySynthAudioProcess m_slider_lfo1_symmetry->setComponentID(String("SLIDER ") + String(SYNTH_PARAM_LFO_1_SYMMETRY)); m_slider_lfo2_symmetry->setComponentID(String("SLIDER ") + String(SYNTH_PARAM_LFO_2_SYMMETRY)); m_slider_lfo3_symmetry->setComponentID(String("SLIDER ") + String(SYNTH_PARAM_LFO_3_SYMMETRY)); + m_slider_lfo0_midisync_divisor->setComponentID(String("SLIDER ") + String(SYNTH_PARAM_LFO_0_MIDISYNC_BEATDIV)); +// m_slider_lfo1_midisync_divisor->setComponentID(String("SLIDER ") + String(SYNTH_PARAM_LFO_1_MIDISYNC_BEATDIV)); +// m_slider_lfo2_midisync_divisor->setComponentID(String("SLIDER ") + String(SYNTH_PARAM_LFO_2_MIDISYNC_BEATDIV)); +// m_slider_lfo3_midisync_divisor->setComponentID(String("SLIDER ") + String(SYNTH_PARAM_LFO_3_MIDISYNC_BEATDIV)); // -------------------------------------------------------------------- // Labels @@ -2279,6 +2316,10 @@ JaySynthAudioProcessorEditor::JaySynthAudioProcessorEditor (JaySynthAudioProcess m_label_lfo1_symmetry->setComponentID(String("LABEL ") + String(SYNTH_PARAM_LFO_1_SYMMETRY)); m_label_lfo2_symmetry->setComponentID(String("LABEL ") + String(SYNTH_PARAM_LFO_2_SYMMETRY)); m_label_lfo3_symmetry->setComponentID(String("LABEL ") + String(SYNTH_PARAM_LFO_3_SYMMETRY)); + m_label_lfo0_midisync_factor->setComponentID(String("LABEL ") + String(SYNTH_PARAM_LFO_0_MIDISYNC_BEATDIV)); +// m_label_lfo1_midisync_factor->setComponentID(String("LABEL ") + String(SYNTH_PARAM_LFO_1_MIDISYNC_BEATDIV)); +// m_label_lfo2_midisync_factor->setComponentID(String("LABEL ") + String(SYNTH_PARAM_LFO_2_MIDISYNC_BEATDIV)); +// m_label_lfo3_midisync_factor->setComponentID(String("LABEL ") + String(SYNTH_PARAM_LFO_3_MIDISYNC_BEATDIV)); // -------------------------------------------------------------------- // Comboboxes @@ -2313,6 +2354,11 @@ JaySynthAudioProcessorEditor::JaySynthAudioProcessorEditor (JaySynthAudioProcess m_comboBox_lfo3_shape->setComponentID(String("COMBOBOX ") + String(SYNTH_PARAM_LFO_3_SHAPE)); m_comboBox_vcf_order->setComponentID(String("COMBOBOX ") + String(SYNTH_PARAM_VCF_ORDER)); + m_comboBox_lfo0_midisync_mode->setComponentID(String("COMBOBOX ") + String(SYNTH_PARAM_LFO_0_MIDISYNC_MODE)); +// m_comboBox_lfo1_midisync_mode->setComponentID(String("COMBOBOX ") + String(SYNTH_PARAM_LFO_1_MIDISYNC_MODE)); +// m_comboBox_lfo2_midisync_mode->setComponentID(String("COMBOBOX ") + String(SYNTH_PARAM_LFO_2_MIDISYNC_MODE)); +// m_comboBox_lfo3_midisync_mode->setComponentID(String("COMBOBOX ") + String(SYNTH_PARAM_LFO_3_MIDISYNC_MODE)); + // -------------------------------------------------------------------- getProcessor()->addActionListener(this); @@ -2571,6 +2617,9 @@ JaySynthAudioProcessorEditor::~JaySynthAudioProcessorEditor() m_label_num_voices_playing = nullptr; m_labelDebug = nullptr; m_btn_midiClockLed = nullptr; + m_label_lfo0_midisync_factor = nullptr; + m_slider_lfo0_midisync_divisor = nullptr; + m_comboBox_lfo0_midisync_mode = nullptr; //[Destructor]. You can add your own custom destruction code here.. @@ -2843,7 +2892,7 @@ void JaySynthAudioProcessorEditor::paint (Graphics& g) g.setColour (Colours::black); g.setFont (Font (10.00f, Font::plain)); g.drawText (TRANS("Smooth"), - 386, 120, 44, 16, + 386, 256, 44, 16, Justification::centred, true); g.setColour (Colours::black); @@ -3215,7 +3264,7 @@ void JaySynthAudioProcessorEditor::paint (Graphics& g) g.setColour (Colours::black); g.setFont (Font (10.00f, Font::plain)); g.drawText (TRANS("Symmetry"), - 362, 256, 48, 16, + 338, 256, 48, 16, Justification::centred, true); g.setColour (Colours::black); @@ -3380,6 +3429,12 @@ void JaySynthAudioProcessorEditor::paint (Graphics& g) 966, 394, 100, 18, Justification::centredRight, true); + g.setColour (Colours::black); + g.setFont (Font (10.00f, Font::plain)); + g.drawText (TRANS("Divisor"), + 386, 119, 48, 16, + Justification::centred, true); + //[UserPaint] Add your own custom painting code here.. //[/UserPaint] } @@ -3437,7 +3492,7 @@ void JaySynthAudioProcessorEditor::resized() m_label_lfo1_speed->setBounds (452, 70, 52, 20); m_comboBox_osc0_shape->setBounds (244, 68, 64, 16); m_comboBox_osc1_shape->setBounds (244, 382, 64, 16); - m_comboBox_lfo0_shape->setBounds (354, 38, 64, 16); + m_comboBox_lfo0_shape->setBounds (355, 38, 64, 16); m_comboBox_lfo1_shape->setBounds (470, 38, 64, 16); m_slider_lfo2_speed->setBounds (346, 402, 36, 36); m_slider_lfo3_speed->setBounds (460, 402, 36, 36); @@ -3459,8 +3514,8 @@ void JaySynthAudioProcessorEditor::resized() m_comboBox_vcf_type->setBounds (880, 74, 68, 16); m_slider_lfo1_smooth->setBounds (506, 88, 36, 36); m_label_lfo1_smooth->setBounds (498, 70, 52, 20); - m_slider_lfo0_smooth->setBounds (392, 88, 36, 36); - m_label_lfo0_smooth->setBounds (384, 70, 52, 20); + m_slider_lfo0_smooth->setBounds (392, 224, 36, 36); + m_label_lfo0_smooth->setBounds (384, 206, 52, 20); m_slider_lfo2_smooth->setBounds (392, 402, 36, 36); m_label_lfo2_smooth->setBounds (384, 384, 52, 20); m_slider_lfo3_smooth->setBounds (506, 402, 36, 36); @@ -3561,8 +3616,8 @@ void JaySynthAudioProcessorEditor::resized() m_label_lfo3_attack->setBounds (498, 452, 52, 20); m_button_lfo0_restart_enable->setBounds (356, 278, 16, 16); m_button_lfo0_individual_enable->setBounds (402, 278, 16, 16); - m_slider_lfo0_symmetry->setBounds (370, 224, 36, 36); - m_label_lfo0_symmetry->setBounds (362, 206, 52, 20); + m_slider_lfo0_symmetry->setBounds (346, 224, 36, 36); + m_label_lfo0_symmetry->setBounds (338, 206, 52, 20); m_slider_lfo1_symmetry->setBounds (484, 224, 36, 36); m_label_lfo1_symmetry->setBounds (476, 206, 52, 20); m_button_lfo1_restart_enable->setBounds (468, 277, 16, 16); @@ -3596,6 +3651,9 @@ void JaySynthAudioProcessorEditor::resized() m_label_num_voices_playing->setBounds (1060, 598, 42, 18); m_labelDebug->setBounds (966, 274, 150, 24); m_btn_midiClockLed->setBounds (1058, 272, 32, 32); + m_label_lfo0_midisync_factor->setBounds (384, 70, 52, 20); + m_slider_lfo0_midisync_divisor->setBounds (392, 88, 36, 36); + m_comboBox_lfo0_midisync_mode->setBounds (393, 12, 47, 16); //[UserResized] Add your own custom resize handling here.. //[/UserResized] } @@ -4000,6 +4058,11 @@ void JaySynthAudioProcessorEditor::sliderValueChanged (Slider* sliderThatWasMove //[UserSliderCode_m_slider_vcf_q_amt1] -- add your slider handling code here.. //[/UserSliderCode_m_slider_vcf_q_amt1] } + else if (sliderThatWasMoved == m_slider_lfo0_midisync_divisor) + { + //[UserSliderCode_m_slider_lfo0_midisync_divisor] -- add your slider handling code here.. + //[/UserSliderCode_m_slider_lfo0_midisync_divisor] + } //[UsersliderValueChanged_Post] //[/UsersliderValueChanged_Post] @@ -4465,6 +4528,11 @@ void JaySynthAudioProcessorEditor::labelTextChanged (Label* labelThatHasChanged) //[UserLabelCode_m_label_num_voices_playing] -- add your label text handling code here.. //[/UserLabelCode_m_label_num_voices_playing] } + else if (labelThatHasChanged == m_label_lfo0_midisync_factor) + { + //[UserLabelCode_m_label_lfo0_midisync_factor] -- add your label text handling code here.. + //[/UserLabelCode_m_label_lfo0_midisync_factor] + } //[UserlabelTextChanged_Post] //[/UserlabelTextChanged_Post] @@ -4761,6 +4829,11 @@ void JaySynthAudioProcessorEditor::comboBoxChanged (ComboBox* comboBoxThatHasCha //[UserComboBoxCode_m_comboBox_vcf_q_src1] -- add your combo box handling code here.. //[/UserComboBoxCode_m_comboBox_vcf_q_src1] } + else if (comboBoxThatHasChanged == m_comboBox_lfo0_midisync_mode) + { + //[UserComboBoxCode_m_comboBox_lfo0_midisync_mode] -- add your combo box handling code here.. + //[/UserComboBoxCode_m_comboBox_lfo0_midisync_mode] + } //[UsercomboBoxChanged_Post] //[/UsercomboBoxChanged_Post] @@ -5335,7 +5408,7 @@ BEGIN_JUCER_METADATA fontname="Default font" fontsize="10" bold="0" italic="0" justification="36"/> - @@ -5459,7 +5532,7 @@ BEGIN_JUCER_METADATA fontname="Default font" fontsize="10" bold="0" italic="0" justification="36"/> - @@ -5515,6 +5588,8 @@ BEGIN_JUCER_METADATA fontname="Default font" fontsize="10" bold="0" italic="0" justification="36"/> +