Help with random.nextFloat in Simple Synthesis (Noise) Tutorial

Hi -

I’m running into a problem with the following section of the Symple Synthesis tutorial:

void getNextAudioBlock(const AudioSourceChannelInfo& bufferToFill) override
		for (int channel = 0; channel < bufferToFill.buffer->getNumChannels(); ++channel)
			// Get a pointer to the start sample in the buffer for this audio output channel
			float* const buffer = bufferToFill.buffer->getWritePointer(channel, bufferToFill.startSample);

			// Fill the required number of samples with noise betweem -0.125 and +0.125
			for (int sample = 0; sample < bufferToFill.numSamples; ++sample)
				buffer[sample] = random.nextFloat() * 0.25f - 0.125f;

In Visual Studio 2015 it’s highlighting random.nextFloat() and giving me ‘identifier “random” is undefined’. I’m coming to C++ from other languages, so my assumption is that I’m not including the random function properly from somewhere else - but I’m not 100% sure on what I need to do.

Any help would be great - didn’t see this anywhere else on the forums (presumably because it’s generally not an issue)


Where is your declaration of the variable random? ie. Random random;

Derp. Didn’t exist…

Thanks cpr - you’re awesome!

The demo project has a member Random object:

BTW It’s important not to create the Random object on every callback, but create it once then reuse it on each callback.