RE: Setting sample rate
RE: Setting sample rate
- Subject: RE: Setting sample rate
- From: "Tracy Lakin" <email@hidden>
- Date: Mon, 22 Jul 2002 15:08:52 -0700
- Thread-topic: Setting sample rate
I have similar experience, although from Obj-C/C/C++.
I wrote an audio file player in order to test the Audio Unit I wrote, as there is no other way to test. Well, the DAVE example program to a degree is worthwhile, but I needed to test with real world songs, not generated audio from MIDI.
(ASIDE: DAVE needs the Jaguar Audio Frameworks to build, but once built, will run under 10.1.4/10.1.5. I've found it crash prone under Jaguar and 10.1.x.)
I'm using the default audio output device. Setting its Stream Format away from 44.1k/float/Stereo does not seem to work. When you ask for the format after setting to other than 44.1k/float/Stereo, you get back the original 44.1k/float/Stereo. No error is reported, it just does not seem to take.
If you are going to use the converters, I would use AudioConverterFillBuffer and not AudioConverterConvertBuffer. I was not able to get AudioConverterConvertBuffer to work. I believe others have posted similar results to this list.
I recommend using the "standard" format of 44.1k/float throughout your audio chain. This seems to work well. I am converting manually, though, in my Audio Unit, from AIFF files to this standard format. This ended up being the easiest to get working and maintain, while keeping up performance.
Caveats:
Since I'm writing the player only to demo and test my Audio Unit, I just kept trying things until they worked. That is, I was focused on getting a demo program "good enough," so I'm not doing extensive testing on the Audio calls.
Also, I'm developing under 10.1.5, started on 10.1.4. I gave up on the WWDC Jaguar seed, as it was too unreliable (for me, anyway). I have not received any seeds past that one, so I can't speak for fixes in Jaguar.
Tracy
Tracy Lakin
Senior Software Engineer
www.octiv.com
>
-----Original Message-----
>
From: Albert Russel [mailto:email@hidden]
>
Sent: Monday, July 22, 2002 12:24 AM
>
To: email@hidden
>
Subject: Setting sample rate
>
>
>
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.