From cf3c26989eba047631c3fe98e1c86ed7be6dab75 Mon Sep 17 00:00:00 2001 From: xenakios Date: Thu, 17 Jan 2019 19:26:41 +0200 Subject: [PATCH] Very preliminary tests to allow reacting to incoming MIDI notes --- Source/PluginProcessor.cpp | 23 +++++++++++++++++++++++ Source/PluginProcessor.h | 1 + paulstretchplugin.jucer | 3 ++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index c6624ad..b4e5df1 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -777,6 +777,29 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M m_stretch_source->setFreezing(getParameter(cpi_freeze)); m_stretch_source->setPaused(getParameter(cpi_pause_enabled)); + MidiBuffer::Iterator midi_it(midiMessages); + MidiMessage midi_msg; + int midi_msg_pos; + while (true) + { + if (midi_it.getNextEvent(midi_msg, midi_msg_pos) == false) + break; + if (midi_msg.isNoteOn()) + { + m_midinote_to_use = midi_msg.getNoteNumber(); + break; + } + if (midi_msg.isNoteOff()) + { + m_midinote_to_use = -1; + } + } + if (m_midinote_to_use >= 0) + { + int note_offset = m_midinote_to_use - 60; + m_ppar.pitch_shift.cents += 100.0*note_offset; + } + m_stretch_source->setProcessParameters(&m_ppar); AudioSourceChannelInfo aif(buffer); if (isNonRealtime() || m_use_backgroundbuffering == false) diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 8434645..6fde7fb 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -273,6 +273,7 @@ private: AudioFilePreviewComponent* m_previewcomponent = nullptr; void saveCaptureBuffer(); SharedResourcePointer m_threadpool; + int m_midinote_to_use = -1; //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor) }; diff --git a/paulstretchplugin.jucer b/paulstretchplugin.jucer index b3f1f2b..b860023 100644 --- a/paulstretchplugin.jucer +++ b/paulstretchplugin.jucer @@ -11,7 +11,8 @@ pluginWantsMidiIn="0" pluginProducesMidiOut="0" pluginIsMidiEffectPlugin="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="paulxstretchAU" aaxIdentifier="com.yourcompany.paulstretchplugin" pluginAAXCategory="2" - jucerVersion="5.4.1" headerPath=" " pluginFormats="buildVST,buildVST3,buildAU,buildStandalone"> + jucerVersion="5.4.1" headerPath=" " pluginFormats="buildVST,buildVST3,buildAU,buildStandalone" + pluginCharacteristicsValue="pluginWantsMidiIn">