• 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
Re: silence a chunk in Audio Unit render function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: silence a chunk in Audio Unit render function


  • Subject: Re: silence a chunk in Audio Unit render function
  • From: Bill Stewart <email@hidden>
  • Date: Mon, 2 Jun 2003 17:16:34 -0700

But as most of the time you are dealing with floats, this is fine...

Also - to really silence it, make sure you set the render flags "is silent" bit, so those downstream know that you are outputting silence

Bill

On Sunday, June 1, 2003, at 02:27 PM, Brian Willoughby wrote:

[ To silence a chunk in an Audio Unit render function I do this:
[ memset(ioData->mData, 0, ioData->mDataByteSize);
[ which works fine for 16-bit audio
[ Is this correct for 8-bit as well?

Rolf,

Your code only works for signed integer formats. If, by some strange chance,
you came across 16-bit unsigned audio, your memset() would be incorrect. Same
for 8-bit unsigned audio.

Check the output stream format flags in your Audio Unit code.

If kAudioFormatFlagIsFloat is clear, then you have integer audio data. If
kAudioFormatFlagIsSignedInteger is set, then your simple memset() will work.
If both of these flags are clear, then you'll have to set memory to 0x80 for
all 8-bit data bytes, or set 0x8000 for all 16-bit data words ... the latter
will probably be slightly less efficient than memset().

The output format can only change when your AudioUnit is uninitialized, so you
can cache any state you need in a variable. Once initialized, the format
should not change - at least that's how I read the notes. You still might want
to catch the cases of audio data that are float or some non-PCM format, which
will require different values for silence.


Historically, I believe that 8-bit RIFF/WAVE files are unsigned, while
originally 8-bit FORM/AIFF files are signed. I'm not absolutely certain about
this, but I do remember having to treat 8-bit audio data as unsigned on the PC,
while it is generally signed on the Mac. Fortunately, AudioUnits do not
suffer from uncertain specifications in this case, because there is a stream
format which precisely describes the format at the moment.

Brian Willoughby
Sound Consulting
_______________________________________________
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.


-- mailto:email@hidden
tel: +1 408 974 4056

________________________________________________________________________ __
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________ __
_______________________________________________
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: silence a chunk in Audio Unit render function
      • From: "Roni Music" <email@hidden>
  • Prev by Date: Re: Is running an idle graph considered expensive?
  • Next by Date: Re: Apple DLS only audible on first few instruments
  • Previous by thread: silence a chunk in Audio Unit render function
  • Next by thread: Re: silence a chunk in Audio Unit render function
  • Index(es):
    • Date
    • Thread