mashu
October 14, 2015, 6:58am
1
Thanks again everyone for all the masses of help lately with getting me on my feet. Still a long way to go, but feels like it's all coming together quite well now. So cheers for that! :D
so now i have this 100sample long table of noise, which i am just creating as a private variable in my MainContentComponent, like this:
const float noiseArray[100] =
{0.582156, 0.967879, 0.967879, ......(snip snip)......., -0.442867, -0.54287, -0.628586};
and i want to use that as an AudioSampleBuffer, and it seems there is a constructor that does that:
AudioSampleBuffer (float *const *dataToReferTo, int numChannels, int numSamples) noexcept
but...i can't figure out the syntax. I know it's another failure to understand basic pointer usage, but please help?
ckk
October 14, 2015, 7:10am
2
This is what I do in these cases:
float* data[1] = {noiseArray};
AudioSampleBuffer buffer(data, 1, 100);
You’d need to declate noiseArray as float instead of const float. Maybe it’d work if you use a const AudioSampleBuffer.
mashu
October 15, 2015, 1:29am
3
thanks, that does seem to compile at least.
although, there's still soemthing wrong with the way i'm doing it, and i get exec bad access errors.
here's what my private variables look like:
AudioSampleBuffer noiseBuffer;
float noiseArray[100] =
{0.582156, 0.967879, 0.967879, ... ....-0.442867, -0.54287, -0.628586};
float* noisePointer[1] = {noiseArray};
and then i am initializing my component like this:
MainContentComponent() : noiseBuffer(noisePointer, 1, 100)
edit: and the jassert i get is:
// you have to pass in the same number of valid pointers as numChannels
mashu
October 15, 2015, 2:39am
4
arghh!! i got it...finally!
i was declaring my noiseBuffer BEFORE declaring and defining the float array.
a wasted morning perhaps...or maybe a good lesson to remember that execution order does matter!