Setting sample rate
Setting sample rate
- Subject: Setting sample rate
- From: "Albert Russel" <email@hidden>
- Date: Mon, 22 Jul 2002 09:24:23 +0200
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.