Browse Source

Added an AudioProcessorPlayer::setMidiOutput() method for forwarding MIDI messages from the AudioProcessor and updated the standalone plugin holder to use this

tags/2021-05-28
ed 7 years ago
parent
commit
92141bf279
3 changed files with 35 additions and 11 deletions
  1. +4
    -2
      modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h
  2. +12
    -0
      modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp
  3. +19
    -9
      modules/juce_audio_utils/players/juce_AudioProcessorPlayer.h

+ 4
- 2
modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h View File

@@ -118,7 +118,6 @@ public:
//==============================================================================
virtual void createPlugin()
{
#if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client
processor.reset (::createPluginFilterOfType (AudioProcessor::wrapperType_Standalone));
#else
@@ -427,7 +426,8 @@ private:
deviceSelector (deviceManagerToUse,
minAudioInputChannels, maxAudioInputChannels,
minAudioOutputChannels, maxAudioOutputChannels,
true, false,
true,
(pluginHolder.processor.get() != nullptr && pluginHolder.processor->producesMidi()),
true, false),
shouldMuteLabel ("Feedback Loop:", "Feedback Loop:"),
shouldMuteButton ("Mute audio input")
@@ -508,10 +508,12 @@ private:
emptyBuffer.clear();
player.audioDeviceAboutToStart (device);
player.setMidiOutput (deviceManager.getDefaultMidiOutput());
}
void audioDeviceStopped() override
{
player.setMidiOutput (nullptr);
player.audioDeviceStopped();
emptyBuffer.setSize (0, 0);
}


+ 12
- 0
modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp View File

@@ -88,6 +88,15 @@ void AudioProcessorPlayer::setDoublePrecisionProcessing (bool doublePrecision)
}
}
void AudioProcessorPlayer::setMidiOutput (MidiOutput* midiOutputToUse)
{
if (midiOutput != midiOutputToUse)
{
const ScopedLock sl (lock);
midiOutput = midiOutputToUse;
}
}
//==============================================================================
void AudioProcessorPlayer::audioDeviceIOCallback (const float** const inputChannelData,
const int numInputChannels,
@@ -163,6 +172,9 @@ void AudioProcessorPlayer::audioDeviceIOCallback (const float** const inputChann
processor->processBlock (buffer, incomingMidi);
}
if (midiOutput != nullptr)
midiOutput->sendBlockOfMessagesNow (incomingMidi);
return;
}
}


+ 19
- 9
modules/juce_audio_utils/players/juce_AudioProcessorPlayer.h View File

@@ -35,7 +35,8 @@ namespace juce
give it a processor to use by calling setProcessor().
It's also a MidiInputCallback, so you can connect it to both an audio and midi
input to send both streams through the processor.
input to send both streams through the processor. To set a MidiOutput for the processor,
use the setMidiOutput() method.
@see AudioProcessor, AudioProcessorGraph
@@ -68,18 +69,26 @@ public:
*/
MidiMessageCollector& getMidiMessageCollector() noexcept { return messageCollector; }
/** Sets the MIDI output that should be used, if required.
The MIDI output will not be deleted or owned by this object. If the MIDI output is
deleted, pass a nullptr to this method.
*/
void setMidiOutput (MidiOutput* midiOutputToUse);
/** Switch between double and single floating point precisions processing.
The audio IO callbacks will still operate in single floating point
precision, however, all internal processing including the
AudioProcessor will be processed in double floating point precision if
the AudioProcessor supports it (see
AudioProcessor::supportsDoublePrecisionProcessing()).
Otherwise, the processing will remain single precision irrespective of
the parameter doublePrecision. */
The audio IO callbacks will still operate in single floating point precision,
however, all internal processing including the AudioProcessor will be processed in
double floating point precision if the AudioProcessor supports it (see
AudioProcessor::supportsDoublePrecisionProcessing()). Otherwise, the processing will
remain single precision irrespective of the parameter doublePrecision.
*/
void setDoublePrecisionProcessing (bool doublePrecision);
/** Returns true if this player processes internally processes the samples with
double floating point precision. */
double floating point precision.
*/
inline bool getDoublePrecisionProcessing() { return isDoublePrecision; }
//==============================================================================
@@ -107,6 +116,7 @@ private:
MidiBuffer incomingMidi;
MidiMessageCollector messageCollector;
MidiOutput* midiOutput = nullptr;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessorPlayer)
};


Loading…
Cancel
Save