OpenShot Audio Library | OpenShotAudio: juce_MPESynthesiser.h Source File

OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_MPESynthesiser.h
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//==============================================================================
54 class JUCE_API MPESynthesiser : public MPESynthesiserBase
55{
56public:
57 //==============================================================================
63 MPESynthesiser();
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 //==============================================================================
300 OwnedArray<MPESynthesiserVoice> voices;
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
310 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiser)
311};
312
313} // namespace juce
juce::AudioBuffer
Definition juce_AudioSampleBuffer.h:34
juce::CriticalSection
Definition juce_CriticalSection.h:43
juce::MPEInstrument
Definition juce_MPEInstrument.h:54
juce::MPESynthesiserVoice
Definition juce_MPESynthesiserVoice.h:38
juce::MPESynthesiser
Definition juce_MPESynthesiser.h:55
juce::MPESynthesiser::isVoiceStealingEnabled
bool isVoiceStealingEnabled() const noexcept
Definition juce_MPESynthesiser.h:127
juce::MPESynthesiser::getNumVoices
int getNumVoices() const noexcept
Definition juce_MPESynthesiser.h:81
juce::MPESynthesiser::setVoiceStealingEnabled
void setVoiceStealingEnabled(bool shouldSteal) noexcept
Definition juce_MPESynthesiser.h:124
juce::MPESynthesiser::handleProgramChange
virtual void handleProgramChange(int, int)
Definition juce_MPESynthesiser.h:173
juce::MPESynthesiser::handleController
virtual void handleController(int, int, int)
Definition juce_MPESynthesiser.h:162
juce::MidiMessage
Definition juce_MidiMessage.h:35
juce::OwnedArray
Definition juce_OwnedArray.h:50
juce::MPENote
Definition juce_MPENote.h:40
juce::MPESynthesiserBase
Definition juce_MPESynthesiserBase.h:47