- use expectations
- improved gibbs sampling - LayerArray is template class git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@18 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -163,7 +163,10 @@ void Synthesiser::renderNextBlock (AudioSampleBuffer& outputBuffer, const MidiBu
|
||||
: numSamples;
|
||||
|
||||
if (numThisTime > 0)
|
||||
renderVoices (outputBuffer, startSample, numThisTime);
|
||||
{
|
||||
for (int i = voices.size(); --i >= 0;)
|
||||
voices.getUnchecked (i)->renderNextBlock (outputBuffer, startSample, numThisTime);
|
||||
}
|
||||
|
||||
if (useEvent)
|
||||
handleMidiEvent (m);
|
||||
@@ -173,12 +176,6 @@ void Synthesiser::renderNextBlock (AudioSampleBuffer& outputBuffer, const MidiBu
|
||||
}
|
||||
}
|
||||
|
||||
void Synthesiser::renderVoices (AudioSampleBuffer& buffer, int startSample, int numSamples)
|
||||
{
|
||||
for (int i = voices.size(); --i >= 0;)
|
||||
voices.getUnchecked (i)->renderNextBlock (buffer, startSample, numSamples);
|
||||
}
|
||||
|
||||
void Synthesiser::handleMidiEvent (const MidiMessage& m)
|
||||
{
|
||||
if (m.isNoteOn())
|
||||
@@ -187,7 +184,7 @@ void Synthesiser::handleMidiEvent (const MidiMessage& m)
|
||||
}
|
||||
else if (m.isNoteOff())
|
||||
{
|
||||
noteOff (m.getChannel(), m.getNoteNumber(), m.getFloatVelocity(), true);
|
||||
noteOff (m.getChannel(), m.getNoteNumber(), true);
|
||||
}
|
||||
else if (m.isAllNotesOff() || m.isAllSoundOff())
|
||||
{
|
||||
@@ -233,7 +230,7 @@ void Synthesiser::noteOn (const int midiChannel,
|
||||
|
||||
if (voice->getCurrentlyPlayingNote() == midiNoteNumber
|
||||
&& voice->isPlayingChannel (midiChannel))
|
||||
stopVoice (voice, 1.0f, true);
|
||||
stopVoice (voice, true);
|
||||
}
|
||||
|
||||
startVoice (findFreeVoice (sound, shouldStealNotes),
|
||||
@@ -251,7 +248,7 @@ void Synthesiser::startVoice (SynthesiserVoice* const voice,
|
||||
if (voice != nullptr && sound != nullptr)
|
||||
{
|
||||
if (voice->currentlyPlayingSound != nullptr)
|
||||
voice->stopNote (0.0f, false);
|
||||
voice->stopNote (false);
|
||||
|
||||
voice->startNote (midiNoteNumber, velocity, sound,
|
||||
lastPitchWheelValues [midiChannel - 1]);
|
||||
@@ -264,11 +261,11 @@ void Synthesiser::startVoice (SynthesiserVoice* const voice,
|
||||
}
|
||||
}
|
||||
|
||||
void Synthesiser::stopVoice (SynthesiserVoice* voice, float velocity, const bool allowTailOff)
|
||||
void Synthesiser::stopVoice (SynthesiserVoice* voice, const bool allowTailOff)
|
||||
{
|
||||
jassert (voice != nullptr);
|
||||
|
||||
voice->stopNote (velocity, allowTailOff);
|
||||
voice->stopNote (allowTailOff);
|
||||
|
||||
// the subclass MUST call clearCurrentNote() if it's not tailing off! RTFM for stopNote()!
|
||||
jassert (allowTailOff || (voice->getCurrentlyPlayingNote() < 0 && voice->getCurrentlyPlayingSound() == 0));
|
||||
@@ -276,7 +273,6 @@ void Synthesiser::stopVoice (SynthesiserVoice* voice, float velocity, const bool
|
||||
|
||||
void Synthesiser::noteOff (const int midiChannel,
|
||||
const int midiNoteNumber,
|
||||
const float velocity,
|
||||
const bool allowTailOff)
|
||||
{
|
||||
const ScopedLock sl (lock);
|
||||
@@ -295,7 +291,7 @@ void Synthesiser::noteOff (const int midiChannel,
|
||||
voice->keyIsDown = false;
|
||||
|
||||
if (! (sustainPedalsDown [midiChannel] || voice->sostenutoPedalDown))
|
||||
stopVoice (voice, velocity, allowTailOff);
|
||||
stopVoice (voice, allowTailOff);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,7 +307,7 @@ void Synthesiser::allNotesOff (const int midiChannel, const bool allowTailOff)
|
||||
SynthesiserVoice* const voice = voices.getUnchecked (i);
|
||||
|
||||
if (midiChannel <= 0 || voice->isPlayingChannel (midiChannel))
|
||||
voice->stopNote (1.0f, allowTailOff);
|
||||
voice->stopNote (allowTailOff);
|
||||
}
|
||||
|
||||
sustainPedalsDown.clear();
|
||||
@@ -383,7 +379,7 @@ void Synthesiser::handleSustainPedal (int midiChannel, bool isDown)
|
||||
SynthesiserVoice* const voice = voices.getUnchecked (i);
|
||||
|
||||
if (voice->isPlayingChannel (midiChannel) && ! voice->keyIsDown)
|
||||
stopVoice (voice, 1.0f, true);
|
||||
stopVoice (voice, true);
|
||||
}
|
||||
|
||||
sustainPedalsDown.clearBit (midiChannel);
|
||||
@@ -404,7 +400,7 @@ void Synthesiser::handleSostenutoPedal (int midiChannel, bool isDown)
|
||||
if (isDown)
|
||||
voice->sostenutoPedalDown = true;
|
||||
else if (voice->sostenutoPedalDown)
|
||||
stopVoice (voice, 1.0f, true);
|
||||
stopVoice (voice, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,14 +55,14 @@ public:
|
||||
The Synthesiser will use this information when deciding which sounds to trigger
|
||||
for a given note.
|
||||
*/
|
||||
virtual bool appliesToNote (int midiNoteNumber) = 0;
|
||||
virtual bool appliesToNote (const int midiNoteNumber) = 0;
|
||||
|
||||
/** Returns true if the sound should be triggered by midi events on a given channel.
|
||||
|
||||
The Synthesiser will use this information when deciding which sounds to trigger
|
||||
for a given note.
|
||||
*/
|
||||
virtual bool appliesToChannel (int midiChannel) = 0;
|
||||
virtual bool appliesToChannel (const int midiChannel) = 0;
|
||||
|
||||
/** The class is reference-counted, so this is a handy pointer class for it. */
|
||||
typedef ReferenceCountedObjectPtr<SynthesiserSound> Ptr;
|
||||
@@ -127,8 +127,6 @@ public:
|
||||
|
||||
This will be called during the rendering callback, so must be fast and thread-safe.
|
||||
|
||||
The velocity indicates how quickly the note was released - 0 is slowly, 1 is quickly.
|
||||
|
||||
If allowTailOff is false or the voice doesn't want to tail-off, then it must stop all
|
||||
sound immediately, and must call clearCurrentNote() to reset the state of this voice
|
||||
and allow the synth to reassign it another sound.
|
||||
@@ -138,7 +136,7 @@ public:
|
||||
finishes playing (during the rendering callback), it must make sure that it calls
|
||||
clearCurrentNote().
|
||||
*/
|
||||
virtual void stopNote (float velocity, bool allowTailOff) = 0;
|
||||
virtual void stopNote (bool allowTailOff) = 0;
|
||||
|
||||
/** Called to let the voice know that the pitch wheel has been moved.
|
||||
This will be called during the rendering callback, so must be fast and thread-safe.
|
||||
@@ -175,6 +173,13 @@ public:
|
||||
int startSample,
|
||||
int numSamples) = 0;
|
||||
|
||||
/** Returns true if the voice is currently playing a sound which is mapped to the given
|
||||
midi channel.
|
||||
|
||||
If it's not currently playing, this will return false.
|
||||
*/
|
||||
bool isPlayingChannel (int midiChannel) const;
|
||||
|
||||
/** Changes the voice's reference sample rate.
|
||||
|
||||
The rate is set so that subclasses know the output rate and can set their pitch
|
||||
@@ -183,14 +188,7 @@ public:
|
||||
This method is called by the synth, and subclasses can access the current rate with
|
||||
the currentSampleRate member.
|
||||
*/
|
||||
virtual void setCurrentPlaybackSampleRate (double newRate);
|
||||
|
||||
/** Returns true if the voice is currently playing a sound which is mapped to the given
|
||||
midi channel.
|
||||
|
||||
If it's not currently playing, this will return false.
|
||||
*/
|
||||
bool isPlayingChannel (int midiChannel) const;
|
||||
void setCurrentPlaybackSampleRate (double newRate);
|
||||
|
||||
/** Returns true if the key that triggered this voice is still held down.
|
||||
Note that the voice may still be playing after the key was released (e.g because the
|
||||
@@ -237,11 +235,6 @@ private:
|
||||
SynthesiserSound::Ptr currentlyPlayingSound;
|
||||
bool keyIsDown, sostenutoPedalDown;
|
||||
|
||||
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE
|
||||
// Note the new parameters for this method.
|
||||
virtual int stopNote (bool) { return 0; }
|
||||
#endif
|
||||
|
||||
JUCE_LEAK_DETECTOR (SynthesiserVoice)
|
||||
};
|
||||
|
||||
@@ -372,7 +365,6 @@ public:
|
||||
*/
|
||||
virtual void noteOff (int midiChannel,
|
||||
int midiNoteNumber,
|
||||
float velocity,
|
||||
bool allowTailOff);
|
||||
|
||||
/** Turns off all notes.
|
||||
@@ -452,7 +444,7 @@ public:
|
||||
This value is propagated to the voices so that they can use it to render the correct
|
||||
pitches.
|
||||
*/
|
||||
virtual void setCurrentPlaybackSampleRate (double sampleRate);
|
||||
void setCurrentPlaybackSampleRate (double sampleRate);
|
||||
|
||||
/** Creates the next block of audio output.
|
||||
|
||||
@@ -482,13 +474,6 @@ protected:
|
||||
/** The last pitch-wheel values for each midi channel. */
|
||||
int lastPitchWheelValues [16];
|
||||
|
||||
/** Renders the voices for the given range.
|
||||
By default this just calls renderNextBlock() on each voice, but you may need
|
||||
to override it to handle custom cases.
|
||||
*/
|
||||
virtual void renderVoices (AudioSampleBuffer& outputAudio,
|
||||
int startSample, int numSamples);
|
||||
|
||||
/** Searches through the voices to find one that's not currently playing, and which
|
||||
can play the given sound.
|
||||
|
||||
@@ -526,12 +511,11 @@ private:
|
||||
bool shouldStealNotes;
|
||||
BigInteger sustainPedalsDown;
|
||||
|
||||
void stopVoice (SynthesiserVoice*, float velocity, bool allowTailOff);
|
||||
void stopVoice (SynthesiserVoice*, bool allowTailOff);
|
||||
|
||||
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE
|
||||
// Note the new parameters for these methods.
|
||||
// Note the new parameters for this method.
|
||||
virtual int findFreeVoice (const bool) const { return 0; }
|
||||
virtual int noteOff (int, int, int) { return 0; }
|
||||
#endif
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Synthesiser)
|
||||
|
||||
Reference in New Issue
Block a user