Play samples with SynthesiserVoice

audio

#1

Hi,
I have my drum sampler plugin in wich I’m trying to play, for now, a single kick sample triggered by any noteOn event incoming.
I’m using a custom Synthesiser class that overrides the handleMidiEvent, and in the constructor adds a sound and a voice.
I took some code from this tutorial:

https://docs.juce.com/master/tutorial_looping_audio_sample_buffer_advanced.html.

File loading is fine, it’s made by my SynthesiserSound derived class, in wich i derived from Thread too, in order to make the thread handle the loading. I know it’s fine because I can hear my kick sample playing, but it’s looped and I cannot prevent this (yeah I know the tutorial says “Looping Audio…”, just don’t understand how to not loop).
Also I have no control on the sample’s start, that I’d want to be triggered by a noteOn event of course.

I copied the getNextAudioBlock from this tutorial and it became my renderNextBlock in the SynthesiserVoice class, then tried to change something in that loop, but nothing.

Don’t understand if it’s caused by this method, or by the thread’s run() method, or something else, but I think the solution it’s in the renderNextBlock’s code.

Somebody can help me please?
Thanks


#2

There’s a SamplerVoice and SamplerSound class in JUCE which you could take a look to see where you might be going wrong: