129 int currentPitchWheelPosition) = 0;
146 virtual void stopNote (
float velocity,
bool allowTailOff) = 0;
152 virtual bool isVoiceActive()
const;
167 virtual void aftertouchChanged (
int newAftertouchValue);
172 virtual void channelPressureChanged (
int newChannelPressureValue);
207 virtual void setCurrentPlaybackSampleRate (
double newRate);
214 virtual bool isPlayingChannel (
int midiChannel)
const;
230 void setKeyDown (
bool isNowDown)
noexcept { keyIsDown = isNowDown; }
247 return isVoiceActive() && ! (isKeyDown() || isSostenutoPedalDown() || isSustainPedalDown());
266 void clearCurrentNote();
273 double currentSampleRate = 44100.0;
274 int currentlyPlayingNote = -1, currentPlayingMidiChannel = 0;
275 uint32 noteOnTime = 0;
277 bool keyIsDown =
false, sustainPedalDown =
false, sostenutoPedalDown =
false;
281 #if JUCE_CATCH_DEPRECATED_CODE_MISUSE
283 virtual int stopNote (
bool) {
return 0; }
286 JUCE_LEAK_DETECTOR (SynthesiserVoice)
349 void removeVoice (
int index);
369 void removeSound (
int index);
378 void setNoteStealingEnabled (
bool shouldStealNotes);
399 virtual void noteOn (
int midiChannel,
415 virtual void noteOff (
int midiChannel,
434 virtual void allNotesOff (
int midiChannel,
448 virtual void handlePitchWheel (
int midiChannel,
463 virtual void handleController (
int midiChannel,
464 int controllerNumber,
465 int controllerValue);
480 virtual void handleAftertouch (
int midiChannel,
int midiNoteNumber,
int aftertouchValue);
494 virtual void handleChannelPressure (
int midiChannel,
int channelPressureValue);
497 virtual void handleSustainPedal (
int midiChannel,
bool isDown);
500 virtual void handleSostenutoPedal (
int midiChannel,
bool isDown);
503 virtual void handleSoftPedal (
int midiChannel,
bool isDown);
509 virtual void handleProgramChange (
int midiChannel,
518 virtual void setCurrentPlaybackSampleRate (
double sampleRate);
567 void setMinimumRenderingSubdivisionSize (
int numSamples,
bool shouldBeStrict =
false) noexcept;
578 int lastPitchWheelValues [16];
584 virtual
void renderVoices (
AudioBuffer<
float>& outputAudio,
585 int startSample,
int numSamples);
586 virtual
void renderVoices (
AudioBuffer<
double>& outputAudio,
587 int startSample,
int numSamples);
600 bool stealIfNoneAvailable) const;
609 int midiNoteNumber) const;
633 double sampleRate = 0;
634 uint32 lastNoteOnCounter = 0;
635 int minimumSubBlockSize = 32;
636 bool subBlockSubdivisionIsStrict = false;
637 bool shouldStealNotes = true;
640 template <typename floatType>
643 #if JUCE_CATCH_DEPRECATED_CODE_MISUSE
645 virtual int findFreeVoice (
const bool)
const {
return 0; }
646 virtual int noteOff (
int,
int,
int) {
return 0; }
647 virtual int findFreeVoice (SynthesiserSound*,
const bool) {
return 0; }
648 virtual int findVoiceToSteal (SynthesiserSound*)
const {
return 0; }
651 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Synthesiser)
A multi-channel buffer containing floating point audio samples.
An arbitrarily large integer class.
Holds a sequence of time-stamped midi events.
Encapsulates a MIDI message.
An array designed for holding objects.
Holds a list of objects derived from ReferenceCountedObject, or which implement basic reference-count...
A base class which provides methods for reference-counting.
Describes one of the sounds that a Synthesiser can play.
virtual bool appliesToNote(int midiNoteNumber)=0
Returns true if this sound should be played when a given midi note is pressed.
virtual bool appliesToChannel(int midiChannel)=0
Returns true if the sound should be triggered by midi events on a given channel.
Represents a voice that a Synthesiser can use to play a SynthesiserSound.
bool isSostenutoPedalDown() const noexcept
Returns true if the sostenuto pedal is currently active for this voice.
double getSampleRate() const noexcept
Returns the current target sample rate at which rendering is being done.
virtual void stopNote(float velocity, bool allowTailOff)=0
Called to stop a note.
bool isSustainPedalDown() const noexcept
Returns true if the sustain pedal is currently active for this voice.
void setSustainPedalDown(bool isNowDown) noexcept
Modifies the sustain pedal flag.
void setSostenutoPedalDown(bool isNowDown) noexcept
Modifies the sostenuto pedal flag.
virtual void renderNextBlock(AudioBuffer< float > &outputBuffer, int startSample, int numSamples)=0
Renders the next block of data for this voice.
bool isKeyDown() const noexcept
Returns true if the key that triggered this voice is still held down.
void setKeyDown(bool isNowDown) noexcept
Allows you to modify the flag indicating that the key that triggered this voice is still held down.
virtual void controllerMoved(int controllerNumber, int newControllerValue)=0
Called to let the voice know that a midi controller has been moved.
int getCurrentlyPlayingNote() const noexcept
Returns the midi note that this voice is currently playing.
virtual void startNote(int midiNoteNumber, float velocity, SynthesiserSound *sound, int currentPitchWheelPosition)=0
Called to start a new note.
virtual bool canPlaySound(SynthesiserSound *)=0
Must return true if this voice object is capable of playing the given sound.
virtual void pitchWheelMoved(int newPitchWheelValue)=0
Called to let the voice know that the pitch wheel has been moved.
bool isPlayingButReleased() const noexcept
Returns true if a voice is sounding in its release phase.
SynthesiserSound::Ptr getCurrentlyPlayingSound() const noexcept
Returns the sound that this voice is currently playing.
Base class for a musical device that can play sounds.
int getNumSounds() const noexcept
Returns the number of sounds that have been added to the synth.
double getSampleRate() const noexcept
Returns the current target sample rate at which rendering is being done.
int getNumVoices() const noexcept
Returns the number of voices that have been added.
bool isNoteStealingEnabled() const noexcept
Returns true if note-stealing is enabled.
SynthesiserSound::Ptr getSound(int index) const noexcept
Returns one of the sounds.
#define JUCE_API
This macro is added to all JUCE public class declarations.