AudioConverterConvertBuffer
AudioConverterConvertBuffer
- Subject: AudioConverterConvertBuffer
- From: Matthew Johnson <email@hidden>
- Date: Mon, 6 Nov 2006 10:38:10 +1100
Hi,
I am trying to use a ioproc added to the default input device with
the format:
SampleRate = 44100
FormatFlags = 00000009
BytesPerPacket = 8
FramesPerPacket = 1
ChannelsPerFrame = 2
BytesPerFrame = 8
BitsPerChannel = 32
with AudioConverterConvertBuffer to convert from the above to :
SampleRate = 8000
BytesPerPacket = 2
FramesPerPacket = 1
ChannelsPerFrame = 1
BytesPerFrame = 2
BitsPerChannel = 16
with the ultimate goal of then converting those 8kHz 16 bit integers
samples
to U-Law 2:1, Mono, 8.000 kHz.
Is AudioConverterConvertBuffer the right function to use or should I
just roll my own, cause the DAYS of agony trying to get this working
are not worth it.
I don't want to use AudioConverterFillBuffer cause that seems a
little daft to me when all I want to do is have the ioproc write (U-
Law 2:1, Mono, 8.000 kHz) directly down a socket without having to
implement
some other thread to read a ring buffer filled by a ioproc.
I really should just roll my own shouldn't I. i.e for a ioproc like:
OSStatus recordCallback( AudioDeviceID device,
const AudioTimeStamp *now,
const AudioBufferList *input_data,
const AudioTimeStamp *input_time,
AudioBufferList *output_data,
const AudioTimeStamp *output_time,
void *client_data)
{
int num_of_units = 0,count=0;
float* new_data = NULL;
struct timeval timeout={0,0};
new_data = (float*)(input_data->mBuffers[0].mData);
num_of_units = input_data->mBuffers[0].mDataByteSize / sizeof
(float);
unsigned char *buffer;
#ifdef USEACCB
unsigned char fbuffer[10240];
long len=sizeof(fbuffer);
if(( AudioConverterConvertBuffer(myconverter, &outlen,
new_data,&len, &fbuffer))!=0)
if(( Convert8kMonoShortsTo8KUlaw(num_of_units, &len, fbuffer,
&buffer))!=0)
#else
if(( Convert441StereoFloatsTo8KUlaw(num_of_units, &outlen,
new_data, &buffer))!=0)
#endif
{
if(SocketPollSendReady(mysocket,&timeout))
if((count=write(mysocket,buffer,outlen)) <= 0)
stopAudioCallbacks();
}
return kAudioHardwareNoError;
}
where I write my own Convert441StereoFloatsTo8KUlaw instead of using
AudioConverterConvertBuffer then Convert8kMonoShortsTo8KUlaw?
Thanks,
Matt Johnson
_______________________________________________
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