WhiteNoise Tutorial

Why is the following code giving me an error?

buffer[sample] = random.nextFloat() * 0.25f -0.125f;

It is in the getNextAudioBlock function (within a nested for loop) and it is intended to fill the buffer with random numbers (white noise). [as in Simple synthesis (noise) Tutorial on JUCE website - Build a White Noise Generator]

The error I get is: member reference base type ‘long()’ is not a structure or union

How did you initialize your random object ?

I did it exactly as shown in the tutorial.

Since my last posting I tried adding:
#include “…/JuceLibraryCode/Juce_Random.h”

This gives an error
’…/JuceLibraryCode/Juce_Random.h’ not found

but strangely enough the previous error mentioned in my original post, disappeared.

This behaviour is shown in Xcode and in Producer.

disapeared like it works now? Probably not, the compiler stops already when it doen’t find the include, so it doesn’t reach the next error…

For the include mind that on Mac/OSX filenames are case sensitive. The prefix juce is always lower case, afaik. But I don’t think that you need that include, it comes with the normal #include "../JuceLibraryCode/JuceHeader.h"

Did you read the last sentence in the tutorial:

To achieve this, an instance of the Random class is added to our MainContentComponent class.

Something like this should work, if you don’t have it already:

    Random random;

Thanks this worked.

Thank you, it’s work for me too.