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;
344 void removeVoice (
int index);
364 void removeSound (
int index);
373 void setNoteStealingEnabled (
bool shouldStealNotes);
394 virtual void noteOn (
int midiChannel,
410 virtual void noteOff (
int midiChannel,
429 virtual void allNotesOff (
int midiChannel,
443 virtual void handlePitchWheel (
int midiChannel,
458 virtual void handleController (
int midiChannel,
459 int controllerNumber,
460 int controllerValue);
475 virtual void handleAftertouch (
int midiChannel,
int midiNoteNumber,
int aftertouchValue);
489 virtual void handleChannelPressure (
int midiChannel,
int channelPressureValue);
492 virtual void handleSustainPedal (
int midiChannel,
bool isDown);
495 virtual void handleSostenutoPedal (
int midiChannel,
bool isDown);
498 virtual void handleSoftPedal (
int midiChannel,
bool isDown);
504 virtual void handleProgramChange (
int midiChannel,
513 virtual void setCurrentPlaybackSampleRate (
double sampleRate);
562 void setMinimumRenderingSubdivisionSize (
int numSamples,
bool shouldBeStrict =
false) noexcept;
573 int lastPitchWheelValues [16];
579 virtual
void renderVoices (
AudioBuffer<
float>& outputAudio,
580 int startSample,
int numSamples);
581 virtual
void renderVoices (
AudioBuffer<
double>& outputAudio,
582 int startSample,
int numSamples);
595 bool stealIfNoneAvailable) const;
604 int midiNoteNumber) const;
628 double sampleRate = 0;
629 uint32 lastNoteOnCounter = 0;
630 int minimumSubBlockSize = 32;
631 bool subBlockSubdivisionIsStrict = false;
632 bool shouldStealNotes = true;
635 template <typename floatType>
638 #if JUCE_CATCH_DEPRECATED_CODE_MISUSE
640 virtual int findFreeVoice (
const bool)
const {
return 0; }
641 virtual int noteOff (
int,
int,
int) {
return 0; }
642 virtual int findFreeVoice (SynthesiserSound*,
const bool) {
return 0; }
643 virtual int findVoiceToSteal (SynthesiserSound*)
const {
return 0; }
646 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Synthesiser)
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.