I have a vector of float
vector<float>nFloats;
I would like to pass it to the following function:
/* This is a non-stream oriented interface to just change the speed of a sound sample */
int sonicChangeFloatSpeed(
float *samples,
int numSamples,
float speed,
float pitch,
float rate,
float volume,
int useChordPitch,
int sampleRate,
int numChannels)
{
sonicStream stream = sonicCreateStream(sampleRate, numChannels);
sonicSetSpeed(stream, speed);
sonicSetPitch(stream, pitch);
sonicSetRate(stream, rate);
sonicSetVolume(stream, volume);
sonicSetChordPitch(stream, useChordPitch);
sonicWriteFloatToStream(stream, samples, numSamples);
sonicFlushStream(stream);
numSamples = sonicSamplesAvailable(stream);
sonicReadFloatFromStream(stream, samples, numSamples);
sonicDestroyStream(stream);
return numSamples;
}
Can anybody tell me how to do it correctly?
My attempts
1) int iRet = sonicChangeFloatSpeed(&nFloats[0], *num, 1, 0.5, 1, 1, 1, 48000, 1);
2) int iRet = sonicChangeFloatSpeed(nFloats[0], *num, 1, 0.5, 1, 1, 1, 48000, 1);
3) int iRet = sonicChangeFloatSpeed(*nFloats, *num, 1, 0.5, 1, 1, 1, 48000, 1);
all don't work.
I'm sure such a question has already been asked, but I couldn't find any exact duplicate.
Can anybody help?
Thank you.
resize()the vector before using it to an appropriate buffer size.all don't work? Doesn't work in which way? The first method looks fine to me.