Loading...
Searching...
No Matches
juce_MPESynthesiser.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class JUCE_API MPESynthesiser : public MPESynthesiserBase
{
public:
//==============================================================================
MPESynthesiser();
MPESynthesiser (MPEInstrument& instrumentToUse);
~MPESynthesiser() override;
//==============================================================================
void clearVoices();
int getNumVoices() const noexcept { return voices.size(); }
MPESynthesiserVoice* getVoice (int index) const;
void addVoice (MPESynthesiserVoice* newVoice);
void removeVoice (int index);
void reduceNumVoices (int newNumVoices);
virtual void turnOffAllVoices (bool allowTailOff);
//==============================================================================
void setVoiceStealingEnabled (bool shouldSteal) noexcept { shouldStealVoices = shouldSteal; }
bool isVoiceStealingEnabled() const noexcept { return shouldStealVoices; }
//==============================================================================
void setCurrentPlaybackSampleRate (double newRate) override;
//==============================================================================
void handleMidiEvent (const MidiMessage&) override;
virtual void handleController (int /*midiChannel*/,
int /*controllerNumber*/,
int /*controllerValue*/) {}
virtual void handleProgramChange (int /*midiChannel*/,
int /*programNumber*/) {}
protected:
//==============================================================================
void noteAdded (MPENote newNote) override;
void noteReleased (MPENote finishedNote) override;
void notePressureChanged (MPENote changedNote) override;
void notePitchbendChanged (MPENote changedNote) override;
void noteTimbreChanged (MPENote changedNote) override;
void noteKeyStateChanged (MPENote changedNote) override;
//==============================================================================
void renderNextSubBlock (AudioBuffer<float>& outputAudio,
int startSample,
int numSamples) override;
void renderNextSubBlock (AudioBuffer<double>& outputAudio,
int startSample,
int numSamples) override;
//==============================================================================
virtual MPESynthesiserVoice* findFreeVoice (MPENote noteToFindVoiceFor,
bool stealIfNoneAvailable) const;
virtual MPESynthesiserVoice* findVoiceToSteal (MPENote noteToStealVoiceFor = MPENote()) const;
void startVoice (MPESynthesiserVoice* voice, MPENote noteToStart);
void stopVoice (MPESynthesiserVoice* voice, MPENote noteToStop, bool allowTailOff);
//==============================================================================
OwnedArray<MPESynthesiserVoice> voices;
CriticalSection voicesLock;
private:
//==============================================================================
std::atomic<bool> shouldStealVoices { false };
uint32 lastNoteOnCounter = 0;
mutable CriticalSection stealLock;
mutable Array<MPESynthesiserVoice*> usableVoicesToStealArray;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPESynthesiser)
};
} // 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::isVoiceStealingEnabled
bool isVoiceStealingEnabled() const noexcept
Definition juce_MPESynthesiser.h:127
juce::MPESynthesiser::MPESynthesiser
MPESynthesiser()
Definition juce_MPESynthesiser.cpp:26
juce::MPESynthesiser::clearVoices
void clearVoices()
Definition juce_MPESynthesiser.cpp:275
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::MPESynthesiserBase
MPESynthesiserBase()
Definition juce_MPESynthesiserBase.cpp:26