[SOLVED] SamplerSound applying to single note...confused


#1

Hi all,

So I’m trying to use the SamplerSound class in a quick and dirty way for a bit of prototyping inside a plugin. I just need a single kick and snare sound from a binary resource / wav that I can trigger on a single note from a Synthesiser object.

Ideally I want my loaded sample to play for a single note only. I am able to play my samples fine when I set their ranges from 0-128 etc. but cannot seem to get any playback when specifying a single note range for the SamplerSound object. If I hit MIDI note 36 (C3) I get nothing. No sample triggering on any MIDI note / key when I use a single note range.

Can anyone see an obvious/thick mistake I am making in the code below ? Never really used the SamplerSound class before or even attempted to write a sample instrument so I’m probably doing something wrong.

 //Initialise the synth
        WavAudioFormat wavFormat;
      
        std::unique_ptr<AudioFormatReader> audioReaderKick(wavFormat.createReaderFor(new MemoryInputStream(BinaryData::bassdrum_wav,
                                                                                                           BinaryData::bassdrum_wavSize,
                                                                                                           false),
                                                                                                           true));

        std::unique_ptr<AudioFormatReader> audioReaderSnare(wavFormat.createReaderFor(new MemoryInputStream(BinaryData::snaredrum_wav,
                                                                                                           BinaryData::snaredrum_wavSize,
                                                                                                           false),
                                                                                                           true));
        BigInteger kickNotes;
        kickNotes.setBit(36);

        BigInteger snareNotes;
        snareNotes.setBit(60);

        synth.clearSounds();
        
        synth.addSound(new SamplerSound("Kick Sound", *audioReaderKick, kickNotes, 36, 0.0, 0.1, 5.0));
        synth.addSound(new SamplerSound("Snare Sound", *audioReaderSnare, snareNotes, 60, 0.0, 0.1, 5.0));

        synth.addVoice(new SamplerVoice());

Thanks Jucers.


#2

Ah. Solved. Appeared to be down to a build issue rather than the code.