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