OpenShot Audio Library | OpenShotAudio 0.3.2
|
#include <juce_MPESynthesiserBase.h>
Public Types | |
using | TrackingMode = MPEInstrument::TrackingMode |
Protected Member Functions | |
virtual void | renderNextSubBlock (AudioBuffer< float > &outputAudio, int startSample, int numSamples)=0 |
virtual void | renderNextSubBlock (AudioBuffer< double > &, int, int) |
Protected Attributes | |
std::unique_ptr< MPEInstrument > | instrument |
Derive from this class to create a basic audio generator capable of MPE. Implement the callbacks of MPEInstrument::Listener (noteAdded, notePressureChanged etc.) to let your audio generator know that MPE notes were triggered, modulated, or released. What to do inside them, and how that influences your audio generator, is up to you!
This class uses an instance of MPEInstrument internally to handle the MPE note state logic.
This class is a very low-level base class for an MPE instrument. If you need something more sophisticated, have a look at MPESynthesiser. This class extends MPESynthesiserBase by adding the concept of voices that can play notes, a voice stealing algorithm, and much more.
Definition at line 46 of file juce_MPESynthesiserBase.h.
Definition at line 168 of file juce_MPESynthesiserBase.h.
juce::MPESynthesiserBase::MPESynthesiserBase | ( | ) |
Constructor.
Definition at line 26 of file juce_MPESynthesiserBase.cpp.
juce::MPESynthesiserBase::MPESynthesiserBase | ( | MPEInstrument * | instrument | ) |
Constructor.
If you use this constructor, the synthesiser will take ownership of the provided instrument object, and will use it internally to handle the MPE note state logic. This is useful if you want to use an instance of your own class derived from MPEInstrument for the MPE logic.
Definition at line 32 of file juce_MPESynthesiserBase.cpp.
void juce::MPESynthesiserBase::enableLegacyMode | ( | int | pitchbendRange = 2 , |
Range< int > | channelRange = Range<int> (1, 17) |
||
) |
Puts the synthesiser into legacy mode.
pitchbendRange | The note pitchbend range in semitones to use when in legacy mode. Must be between 0 and 96, otherwise behaviour is undefined. The default pitchbend range in legacy mode is +/- 2 semitones. |
channelRange | The range of MIDI channels to use for notes when in legacy mode. The default is to use all MIDI channels (1-16). |
To get out of legacy mode, set a new MPE zone layout using setZoneLayout.
Definition at line 51 of file juce_MPESynthesiserBase.cpp.
Returns the range of MIDI channels (1-16) to be used for notes when in legacy mode.
Definition at line 61 of file juce_MPESynthesiserBase.cpp.
|
noexcept |
Returns the pitchbend range in semitones (0-96) to be used for notes when in legacy mode.
Definition at line 71 of file juce_MPESynthesiserBase.cpp.
|
inlinenoexcept |
Returns the current target sample rate at which rendering is being done. Subclasses may need to know this so that they can pitch things correctly.
Definition at line 84 of file juce_MPESynthesiserBase.h.
Referenced by juce::MPESynthesiser::addVoice().
|
noexcept |
Returns the synthesiser's internal MPE zone layout. This happens by value, to enforce thread-safety and class invariants.
Definition at line 40 of file juce_MPESynthesiserBase.cpp.
|
virtual |
Handle incoming MIDI events (called from renderNextBlock).
The default implementation provided here simply forwards everything to MPEInstrument::processNextMidiEvent, where it is used to update the MPE notes, zones etc. MIDI messages not relevant for MPE are ignored.
This method can be overridden if you need to do custom MIDI handling on top of MPE. The MPESynthesiser class overrides this to implement callbacks for MIDI program changes and non-MPE-related MIDI controller messages.
Reimplemented in juce::MPESynthesiser.
Definition at line 98 of file juce_MPESynthesiserBase.cpp.
Referenced by juce::MPESynthesiser::handleMidiEvent(), and renderNextBlock().
|
noexcept |
Returns true if the instrument is in legacy mode, false otherwise.
Definition at line 56 of file juce_MPESynthesiserBase.cpp.
template void juce::MPESynthesiserBase::renderNextBlock< double > | ( | AudioBuffer< floatType > & | outputAudio, |
const MidiBuffer & | inputMidi, | ||
int | startSample, | ||
int | numSamples | ||
) |
Creates the next block of audio output.
Call this to make sound. This will chop up the AudioBuffer into subBlock pieces separated by events in the MIDI buffer, and then call processNextSubBlock on each one of them. In between you will get calls to noteAdded/Changed/Finished, where you can update parameters that depend on those notes to use for your audio rendering.
Definition at line 105 of file juce_MPESynthesiserBase.cpp.
|
inlineprotectedvirtual |
Implement this method if you want to render 64-bit audio as well; otherwise leave blank.
Reimplemented in juce::MPESynthesiser.
Definition at line 191 of file juce_MPESynthesiserBase.h.
|
protectedpure virtual |
Implement this method to render your audio inside.
Implemented in juce::MPESynthesiser.
Referenced by renderNextBlock().
Tells the synthesiser what the sample rate is for the audio it's being used to render.
Reimplemented in juce::MPESynthesiser.
Definition at line 162 of file juce_MPESynthesiserBase.cpp.
Referenced by juce::MPESynthesiser::setCurrentPlaybackSampleRate().
Re-sets the range of MIDI channels (1-16) to be used for notes when in legacy mode.
Definition at line 66 of file juce_MPESynthesiserBase.cpp.
Re-sets the pitchbend range in semitones (0-96) to be used for notes when in legacy mode.
Definition at line 76 of file juce_MPESynthesiserBase.cpp.
|
noexcept |
Sets a minimum limit on the size to which audio sub-blocks will be divided when rendering.
When rendering, the audio blocks that are passed into renderNextBlock() will be split up into smaller blocks that lie between all the incoming midi messages, and it is these smaller sub-blocks that are rendered with multiple calls to renderVoices().
Obviously in a pathological case where there are midi messages on every sample, then renderVoices() could be called once per sample and lead to poor performance, so this setting allows you to set a lower limit on the block size.
The default setting is 32, which means that midi messages are accurate to about < 1ms accuracy, which is probably fine for most purposes, but you may want to increase or decrease this value for your synth.
If shouldBeStrict is true, the audio sub-blocks will strictly never be smaller than numSamples.
If shouldBeStrict is false (default), the first audio sub-block in the buffer is allowed to be smaller, to make sure that the first MIDI event in a buffer will always be sample-accurate (this can sometimes help to avoid quantisation or phasing issues).
Definition at line 173 of file juce_MPESynthesiserBase.cpp.
void juce::MPESynthesiserBase::setPitchbendTrackingMode | ( | TrackingMode | modeToUse | ) |
Set the MPE tracking mode for the pitchbend dimension.
Definition at line 87 of file juce_MPESynthesiserBase.cpp.
void juce::MPESynthesiserBase::setPressureTrackingMode | ( | TrackingMode | modeToUse | ) |
Set the MPE tracking mode for the pressure dimension.
Definition at line 82 of file juce_MPESynthesiserBase.cpp.
void juce::MPESynthesiserBase::setTimbreTrackingMode | ( | TrackingMode | modeToUse | ) |
Set the MPE tracking mode for the timbre dimension.
Definition at line 92 of file juce_MPESynthesiserBase.cpp.
void juce::MPESynthesiserBase::setZoneLayout | ( | MPEZoneLayout | newLayout | ) |
Re-sets the synthesiser's internal MPE zone layout to the one passed in. As a side effect, this will discard all currently playing notes, call noteReleased for all of them, and disable legacy mode (if previously enabled).
Definition at line 45 of file juce_MPESynthesiserBase.cpp.
Referenced by juce::MPESynthesiser::MPESynthesiser().
|
protected |
Definition at line 198 of file juce_MPESynthesiserBase.h.
Referenced by enableLegacyMode(), getLegacyModeChannelRange(), getLegacyModePitchbendRange(), getZoneLayout(), handleMidiEvent(), isLegacyModeEnabled(), MPESynthesiserBase(), MPESynthesiserBase(), setCurrentPlaybackSampleRate(), setLegacyModeChannelRange(), setLegacyModePitchbendRange(), setPitchbendTrackingMode(), setPressureTrackingMode(), setTimbreTrackingMode(), setZoneLayout(), and juce::MPESynthesiser::turnOffAllVoices().