• 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: Tue, 3 Jun 2003 12:13:21 -0700

The data size is given to you as a "command" - give me this much data - as that is what I need to fulfil the render requirement... So, you can't change this on the client side or the AU won't have enough data to process.

If you want to change the rendering size to smaller cycles - then you need to change the devices number of frames... See the OutputUnit test code for an example of doing this (I think PlaySequence might do the same thing as well)

Bill

On Tuesday, June 3, 2003, at 02:10 AM, Roni Music wrote:

Hi,

----- Original Message -----
From: "Bill Stewart" <email@hidden>
To: "Brian Willoughby" <email@hidden>
Cc: "Rolf Nilsson" <email@hidden>; <email@hidden>
Sent: Tuesday, June 03, 2003 2:16 AM
Subject: Re: silence a chunk in Audio Unit render function


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

OK


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


I'm using the AudioUnitRenderSlice() callback
that only have actionFlags as input.
but maybe this is not a major issue?


But this leads to another question:

I want to decrease the ioData->mDataByteSize in the render callback.

I do as below and it works OK but I can't understand if the bIsInput flag in the

AudioDeviceSet/GetProperty() calls should be true or false??

-----


// get the output device AudioDeviceID
AudioDeviceID deviceID;
UInt32 thePropertySize = sizeof(AudioDeviceID);

/*theErr = */AudioUnitGetProperty(outputAudioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Input, 0, &deviceID, &thePropertySize);


// change the buffer size in the render callback to 2048 (default seems to be 4096)
// should bIsInput be true or false????

bool bIsInput = true;
UInt32 bufferSize = 2048;
thePropertySize = sizeof(bufferSize);
/*theErr = */AudioDeviceSetProperty(deviceID, NULL, 0, bIsInput, kAudioDevicePropertyBufferSize, thePropertySize, &bufferSize);

// check that it worked OK
/*theErr = */AudioDeviceGetProperty(deviceID, 0, bIsInput, kAudioDevicePropertyBufferSize, &thePropertySize, &bufferSize);


---------------

As I said, what I do seems to work.

Will decreasing the buffer size always work on any computer/device or do I need to check something first?

Any help appreciated

Rolf





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
______________________________________________________________________ __
__




--
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.
References: 
 >Re: silence a chunk in Audio Unit render function (From: "Roni Music" <email@hidden>)

  • Prev by Date: Re: How To Give Idle Time From The AU To The Host ?
  • Next by Date: Re: getting PCM data from an audio file
  • Previous by thread: Re: silence a chunk in Audio Unit render function
  • Next by thread: Griffin iMic issue
  • Index(es):
    • Date
    • Thread