• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Setting sample rate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Setting sample rate
      • From: email@hidden
  • Prev by Date: Audio Capture (Java)
  • Next by Date: Re: Setting sample rate
  • Previous by thread: Re: Audio Capture (Java)
  • Next by thread: Re: Setting sample rate
  • Index(es):
    • Date
    • Thread