• 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
using integer audio data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

using integer audio data


  • Subject: using integer audio data
  • From: "Timothy J. Wood" <email@hidden>
  • Date: Tue, 21 Aug 2001 12:46:05 -0700

This is probably a FAQ, but the searching support for lists.apple.com seems to be useless, as is the searching support for ADC (or this subject has never come up before, something I find hard to believe :)


I'd like to use CoreAudio to feed 16-bit signed lpcm data to the hardware. Now, judging from the headers in 10.0.4, this should be possible if the system supports it. So, I build a AudioStreamBasicDescription that looks like the following:

memset(&streamDesc, 0, sizeof(streamDesc));
streamDesc.mSampleRate = 22050.0f;
streamDesc.mFormatID = kAudioFormatLinearPCM;
streamDesc.mFormatFlags = kLinearPCMFormatFlagIsBigEndian | kLinearPCMFormatFlagIsSignedInteger;
streamDesc.mBytesPerPacket = 0;
streamDesc.mBytesPerFrame = 0;
streamDesc.mChannelsPerFrame = 0;
streamDesc.mBitsPerChannel = 0;

and then ask the audio device to provide the best matching format:

propertySize = sizeof(streamDesc);
status = AudioDeviceGetProperty(audioDeviceID, 0, FALSE, kAudioDevicePropertyStreamFormatMatch, &propertySize, &streamDesc);

but the format that is returned is a floating point format:

Matching format:
44100.000000 mSampleRate
lpcm
11 mFormatFlags (i.e., kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsBigEndian | kLinearPCMFormatFlagIsPacked)
8 mBytesPerPacket
1 mFramesPerPacket
8 mBytesPerFrame
2 mChannelsPerFrame
32 mBitsPerChannel


I suppose I could live with floating point samples, but this would be really slow or require more work since the game I'm porting (Giants - Citizen Kabuto) uses 16-bit signed short sound data. Int/float conversions suck on PPC, so I'd either need to preconvert sounds to floating point samples (certainly a possibility, but it'd use twice as much room), or I'd need to write an Altivec version of my mixer.

Additionally, I'd really like to use 22050 instead of 44100 since, again, that is how my sound data is formatted.

I would just keep using Carbon SoundManager, but while my mixing routing is taking about 1% of my total application time, SoundManager is eating a whole bunch more on its own in weird SoundComponent calls (looks like it is trying to rate convert and do some other crud).

What is the fastest route to mix sound and get it to the hardware (where fastest is in total CPU resources spent, not latency)? Surely the 44100 floating point path isn't it...

Thanks!

-tim


  • Follow-Ups:
    • Re: using integer audio data
      • From: Jeff Moore <email@hidden>
  • Prev by Date: Re: easiest way to record using MacOS X
  • Next by Date: Re: using integer audio data
  • Previous by thread: Re: easiest way to record using MacOS X
  • Next by thread: Re: using integer audio data
  • Index(es):
    • Date
    • Thread