Re: Setting the samplerate
Re: Setting the samplerate
- Subject: Re: Setting the samplerate
- From: Jeff Moore <email@hidden>
- Date: Mon, 9 Sep 2002 12:09:44 -0700
First off, you are filling out the AudioStreamBasicDescription
incorrectly. The mFormatFlags filed is pretty much never going to be 0
for linear PCM data. Please refer to <CoreAudio/CoreAudioTypes.h> for
info about the AudioStreamBasicDescription struct.
Secondly, have you checked to be sure that the iMic supports the format
you are requesting using kAudioDevicePropertyStreamFormats? I'm pretty
sure the iMic is stereo only. It may support an 8K sample rate, but I
don't think it does (don't have one on hand to check). Note that if a
format you want isn't directly supported by the hardware, you will get
an error if you try to set it.
In Jaguar, you can set the sample rate using
kAudioDevicePropertyActualSampleRate and
kAudioDevicePropertyAvailableNominalSampleRates.
On Monday, September 9, 2002, at 02:04 AM, Fredrik Oja wrote:
I want to capture mono 16bit linear PCM from my audio devices. I have
one iMIC and one philips vestra pro camera. When I try to set the
stream format the call fails. What am I doing wrong? Below is some > code
memset(&formatDesc, 0, sizeof(AudioStreamBasicDescription));
formatDesc.mFormatFlags = 0;
formatDesc.mFramesPerPacket = 1;//160;
formatDesc.mBytesPerFrame = 2;
formatDesc.mBytesPerPacket = formatDesc.mFramesPerPacket *
formatDesc.mBytesPerFrame;
formatDesc.mChannelsPerFrame = 1;
formatDesc.mBitsPerChannel = 16;
formatDesc.mSampleRate = (double) 8000.0;
formatDesc.mFormatID = kAudioFormatLinearPCM;
status = AudioDeviceSetProperty(
inputDevices[inputDeviceIndex].id, 0, 0,
true, kAudioDevicePropertyStreamFormat,
sizeof(formatDesc), &formatDesc);
if (status != kAudioHardwareNoError) {
printf("Failed setting AudioDevicePropertyStreamFormat\n");
}
I have also tried by only setting the samplerate variable and leaving
everything else at zero, but the call fails anyway.
Any suggestions will be greatly appreciated
/ Fredrik Oja
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.
--
Jeff Moore
Core Audio
Apple
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.