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: Jeff Moore <email@hidden>
- Date: Mon, 3 Aug 2009 18:05:15 -0700
You problem is probably that you are not filling out the ASBD
correctly. Specifically, you are not setting the fields,
mBytesPerPacket, mBytesPerFrame, and mBitsPerChannel to the proper
values to describe a 32 bit floating point number, which is four bytes
in size. You have filled out the ASBD as if the 32 bit float was only
two bytes long.
On Aug 3, 2009, at 5:52 PM, David Lecoutre wrote:
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...
--
Jeff Moore
Core Audio
Apple
_______________________________________________
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