Re: Issues for loading an array of data into a stream buffer
Re: Issues for loading an array of data into a stream buffer
- Subject: Re: Issues for loading an array of data into a stream buffer
- From: David Lecoutre <email@hidden>
- Date: Mon, 3 Aug 2009 19:52:45 -0500
Do you think that I don't play the floats correctly ? If you look at the DefaultOutputUnit sample, I made those changes in the RenderSin function.
void RenderSin (UInt32 startingFrameCount,
UInt32 inFrames,
void* inBuffer,
double inSampleRate,
double amplitude,
double frequency,
int inOutputFormat,
Float32* _mysoundbuffer,
UInt32 SizeBuffer)
{
for (UInt32 frame = 0; frame < (inFrames); ++frame)
{
if((theLastPosition+frame)<SizeBuffer){
Float32 nextFloat = _mysoundbuffer[(theLastPosition+frame)];
static_cast<Float32*>(inBuffer)[frame] = nextFloat;
}else{
// go back to the beginning of the buffer
theLastPosition=0;
}
}
theLastPosition+=inFrames;
}
This is how I'm initializing my AudioStream :
AudioStreamBasicDescription streamFormat;
streamFormat.mSampleRate = 44100; // the sample rate of the audio stream streamFormat.mFormatID = kAudioFormatLinearPCM; // the specific encoding type of audio stream
I am not sure if this is the right formatID...
streamFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked
| kAudioFormatFlagIsNonInterleaved; // flags specific to each format
streamFormat.mBytesPerPacket = 2; streamFormat.mFramesPerPacket = 1;
streamFormat.mBytesPerFrame = 2; streamFormat.mChannelsPerFrame = 1;
streamFormat.mBitsPerChannel = 16; With those settings I don't get any sound when I'm trying to play the floats ( I've filled the buffer of floats with a wav file, the values are between -100 and 100 ). It seems that I'm doing something wrong but I didn't figure out what...
Thanks,
David L-
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden