JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_MPESynthesiser.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
54class JUCE_API MPESynthesiser : public MPESynthesiserBase
55{
56public:
57 //==============================================================================
64
71 MPESynthesiser (MPEInstrument& instrumentToUse);
72
74 ~MPESynthesiser() override;
75
76 //==============================================================================
78 void clearVoices();
79
81 int getNumVoices() const noexcept { return voices.size(); }
82
84 MPESynthesiserVoice* getVoice (int index) const;
85
94 void addVoice (MPESynthesiserVoice* newVoice);
95
97 void removeVoice (int index);
98
105 void reduceNumVoices (int newNumVoices);
106
115 virtual void turnOffAllVoices (bool allowTailOff);
116
117 //==============================================================================
124 void setVoiceStealingEnabled (bool shouldSteal) noexcept { shouldStealVoices = shouldSteal; }
125
127 bool isVoiceStealingEnabled() const noexcept { return shouldStealVoices; }
128
129 //==============================================================================
136 void setCurrentPlaybackSampleRate (double newRate) override;
137
138 //==============================================================================
153 void handleMidiEvent (const MidiMessage&) override;
154
162 virtual void handleController (int /*midiChannel*/,
163 int /*controllerNumber*/,
164 int /*controllerValue*/) {}
165
173 virtual void handleProgramChange (int /*midiChannel*/,
174 int /*programNumber*/) {}
175
176protected:
177 //==============================================================================
190 void noteAdded (MPENote newNote) override;
191
205 void noteReleased (MPENote finishedNote) override;
206
213 void notePressureChanged (MPENote changedNote) override;
214
221 void notePitchbendChanged (MPENote changedNote) override;
222
229 void noteTimbreChanged (MPENote changedNote) override;
230
237 void noteKeyStateChanged (MPENote changedNote) override;
238
239 //==============================================================================
244 void renderNextSubBlock (AudioBuffer<float>& outputAudio,
245 int startSample,
246 int numSamples) override;
247
252 void renderNextSubBlock (AudioBuffer<double>& outputAudio,
253 int startSample,
254 int numSamples) override;
255
256 //==============================================================================
267 virtual MPESynthesiserVoice* findFreeVoice (MPENote noteToFindVoiceFor,
268 bool stealIfNoneAvailable) const;
269
282 virtual MPESynthesiserVoice* findVoiceToSteal (MPENote noteToStealVoiceFor = MPENote()) const;
283
289 void startVoice (MPESynthesiserVoice* voice, MPENote noteToStart);
290
297 void stopVoice (MPESynthesiserVoice* voice, MPENote noteToStop, bool allowTailOff);
298
299 //==============================================================================
301 CriticalSection voicesLock;
302
303private:
304 //==============================================================================
305 std::atomic<bool> shouldStealVoices { false };
306 uint32 lastNoteOnCounter = 0;
307 mutable CriticalSection stealLock;
308 mutable Array<MPESynthesiserVoice*> usableVoicesToStealArray;
309
311};
312
313} // namespace juce
A multi-channel buffer containing floating point audio samples.
This class represents an instrument handling MPE.
Represents an MPE voice that an MPESynthesiser can use to play a sound.
Base class for an MPE-compatible musical device that can play sounds.
bool isVoiceStealingEnabled() const noexcept
Returns true if note-stealing is enabled.
int getNumVoices() const noexcept
Returns the number of voices that have been added.
void setVoiceStealingEnabled(bool shouldSteal) noexcept
If set to true, then the synth will try to take over an existing voice if it runs out and needs to pl...
virtual void handleProgramChange(int, int)
Callback for MIDI program change messages.
virtual void handleController(int, int, int)
Callback for MIDI controller messages.
Encapsulates a MIDI message.
An array designed for holding objects.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
JUCE Namespace.
This struct represents a playing MPE note.
Derive from this class to create a basic audio generator capable of MPE.