iOS - Synthesiser/SamplerSound - weird noise

Hi there,

I have a problem while trying to use Synthesiser and SamplerSound.

My code is based on the JUCE demo code AudioSynthesiserDemo.h and is a static library for an iOS app.

I managed to play audio files using Synthesiser and SamplerSound. However my problem is that the resultant sound always has a noise near the end of the playback duration. It’s a white noise that is initially not noticeable but gets really loud in the end. I also tried using the cello.wav file that comes with the JUCE demo, and the same noise can be observed.

Does anyone know the cause of the white noise and how it can be removed?

Some more info about my code…

I didn’t use MidiMessageCollector like in AudioSynthesiserDemo.h and simply called synth.noteOn(midiChannel, midiNoteNumber, velocity); to play a note. My getNextAudioBlock of AudioSource has

juce::MidiBuffer incomingMidi;
synth.renderNextBlock (*bufferToFill.buffer, incomingMidi, 0, bufferToFill.numSamples);

… which supplies an empty MidiBuffer and I’m not sure if that’s right or not, but I don’t know what else to set.

I also tried using different velocity values and the result seems to be the same.

Thanks!

I figured it out myself… it’s due to a combination of:

  • I used a velocity of 127, thought it’s supposed to range from 0 to 127. In fact the velocity is simply used as gain in juce_Sampler.cpp startNote(). So using a velocity of 1.0 as max is probably more appropriate.
  • I didn’t use noteOff() so there is no release phase applied.