FahlGrahn Audio v1.0.0
Loading...
Searching...
No Matches
DrumSampler.h
1#include <JuceHeader.h>
2
3class DrumSampler : public juce::Synthesiser
4{
5 void noteOn(int midiChannel, int midiNoteNumber, float velocity) override
6 {
7 const juce::ScopedLock sl(lock);
8
9 for (auto *sound : sounds)
10 {
11 if (sound->appliesToNote(midiNoteNumber) && sound->appliesToChannel(midiChannel))
12 {
13 // If hitting a note that's still ringing, stop it first (it could be
14 // still playing because of the sustain or sostenuto pedal).
15 for (auto *voice : voices)
16 {
17 if ((voice->getCurrentlyPlayingNote() == midiNoteNumber) && voice->isPlayingChannel(midiChannel) &&
18 (voice->getCurrentlyPlayingSound().get() == sound))
19 {
20 stopVoice(voice, 1.0f, true);
21 }
22 }
23
24 startVoice(findFreeVoice(sound, midiChannel, midiNoteNumber, isNoteStealingEnabled()), sound,
25 midiChannel, midiNoteNumber, velocity);
26 }
27 }
28 }
29};
Definition DrumSampler.h:4