Re: Setting sample rate
Re: Setting sample rate
- Subject: Re: Setting sample rate
- From: email@hidden
- Date: Mon, 22 Jul 2002 05:15:14 -0500 (CDT)
Are you certain your device handles 8000 Hz sampling rate in the same
data format as you specified? If so, this post is probably of no help. My
advice is that you should ask the device for the formats it supports and
then go from there in your format selection process. The property to use
for getting the list of formats is simply
kAudioDevicePropertyStreamFormats. Call AudioDeviceGetPropertyInfo to
determine how many formats will be returned and then call
AudioDeviceGetProperty to get the actual list of formats supported.
- Ben
On Mon, 22 Jul 2002, Albert Russel wrote:
>
Somehow I can not set the device properties with AudioDeviceSetProperty. I
>
keep getting the kAUdioDeviceUnsupportedFormatError, anyone here with more
>
succes and some code samples? This did not work:
>
>
count = sizeof(deviceFormat);
>
err = AudioDeviceGetProperty(device, 0, false,
>
kAudioDevicePropertyStreamFormat, &count, &deviceFormat);
>
if (err != kAudioHardwareNoError) {
>
fprintf(stderr, "OSXAudio: get kAudioDevicePropertyStreamFormat error
>
%ld\n", err);
>
return;
>
} else if (deviceFormat.mFormatID != kAudioFormatLinearPCM) {
>
fprintf(stderr, "OSXAudio: mFormatID != kAudioFormatLinearPCM\n");
>
return;
>
}
>
>
deviceFormat.mSampleRate = 8000;
>
deviceFormat.mChannelsPerFrame = 2;
>
deviceFormat.mBytesPerPacket = 8;
>
deviceFormat.mFramesPerPacket = 1;
>
deviceFormat.mBytesPerFrame = 8;
>
deviceFormat.mBitsPerChannel = 32;
>
>
count = sizeof(deviceFormat);
>
err = AudioDeviceSetProperty(device, 0, 0, 0,
>
kAudioDevicePropertyStreamFormat, count, &deviceFormat);
>
if (err != kAudioHardwareNoError) {
>
fprintf(stderr, "OSXAudio: set kAudioDevicePropertyStreamFormat error
>
%ld\n", err);
>
return;
>
}
>
>
>
If I change the SampleRate to 44100 it works fine.
>
>
I would be happy if I could get my hands on more documentation than Apple's
>
"Audio and MIDI on Mac OS X". Also the famous sine wave sample code does not
>
help me for this problem.
>
_______________________________________________
>
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.
_______________________________________________
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.