WhiteNoise Tutorial


#1

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


#2

How did you initialize your random object ?


#3

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.


#4

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:

private:
    Random random;

#5

Thanks this worked.


#6

Thank you, it’s work for me too.