Re: silence a chunk in Audio Unit render function
Re: silence a chunk in Audio Unit render function
- Subject: Re: silence a chunk in Audio Unit render function
- From: "Roni Music" <email@hidden>
- Date: Tue, 3 Jun 2003 11:10:43 +0200
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
>
________________________________________________________________________
>
__
_______________________________________________
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.