• 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: getting generator audio unit output in render callback
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting generator audio unit output in render callback


  • Subject: Re: getting generator audio unit output in render callback
  • From: Aran Mulholland <email@hidden>
  • Date: Fri, 10 May 2013 09:38:16 +1000

This must be some configuration setup problem. I have had plenty of these kinds of issues, usually it is a stream format somewhere. Once the audio is running through that graph you can manipulate it using a callback.
To debug/fiddle/test try connecting another node between your speech unit and your output, like a mixer, then try attaching your render callback to that.


On Fri, May 10, 2013 at 8:42 AM, Rich E <email@hidden> wrote:
Due to the silence about this topic, I am under the impression that the AUGraph API is unfortunately limited in this manner.  We are moving forward with an AUGraph-less implementation for our project's needs, but I would still be happy to hear that this wasn't true and I could still benifit from the inherent thread safety / ability to update stream properties that is within the AUGraph API and not Audio Component Services.

Best,
Rich Eakin


On Wed, Jan 9, 2013 at 1:49 AM, Rich E <email@hidden> wrote:
It appears to only be an issue when using an AUGraph; the following code successfully gives me the same setup as what I previously posted.  Can anyone see why the AUGraph version in the previous email doesn't work?

- (int)createSynthWithoutAUGraph {

// speech synthesizer
AudioComponentDescription speechCD = {0};
speechCD.componentType = kAudioUnitType_Generator;
speechCD.componentSubType = kAudioUnitSubType_SpeechSynthesis;
speechCD.componentManufacturer = kAudioUnitManufacturer_Apple;

// output device (speakers)
AudioComponentDescription outputCD = {0};
outputCD.componentType = kAudioUnitType_Output;
outputCD.componentSubType = kAudioUnitSubType_DefaultOutput;
outputCD.componentManufacturer = kAudioUnitManufacturer_Apple;

AudioComponent speechComponent = AudioComponentFindNext(NULL, &speechCD);
if(!speechComponent) {
AU_LOG(@"Error: could not locate speech unit");
return -1;
}
AU_CHECK( AudioComponentInstanceNew( speechComponent, &_speechUnit ) );
AU_CHECK( AudioUnitInitialize( _speechUnit ) );

AudioComponent outputComponent = AudioComponentFindNext(NULL, &outputCD);
if(!outputComponent) {
AU_LOG(@"Error: could not locate output unit");
return -1;
}
AU_CHECK( AudioComponentInstanceNew( outputComponent, &_outputUnit ) );
AU_CHECK( AudioUnitInitialize( _outputUnit ) );

// setup callback:
AURenderCallbackStruct callback = { &PdRenderCallback, self };
AU_CHECK( AudioUnitSetProperty( _outputUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &callback, sizeof(callback)) );

// finally init and start
AU_LOG( @"AU successfully initialized without graph." );
AU_CHECK( AudioOutputUnitStart( _outputUnit) );
return 0;
}


On Sun, Jan 6, 2013 at 1:32 AM, Rich E <email@hidden> wrote:
I've been trying without success to manipulate the samples produced by kAudioUnitType_Generator audio units by attaching an AURenderCallbackStruct to the input of the audio unit right after.  I managed to get this working on OS X using the following simple graph:

(input callback) -> multichannel mixer -> (intput callback) -> default output

But I've failed with the following (even simpler) graphs that start with a generator unit:

speech synthesis -> (intput callback) -> default output           | fails in render callback with kAudioUnitErr_Uninitialized
audiofile player -> (intput callback) -> default output               | fails when scheduling file region with kAudioUnitErr_Uninitialized

I've tried just about everything I can think of, from setting ASBD format to sample rates, but I always get these errors.  Does anyone know how to setup a graph where we can manipulate samples from these nice generator units?

Below is the failing render callback function and graph instantiation method for the attempt using speech synthesis.  The audiofile player is almost identical for this, except setting up the file playback, of course.  Both of these setups work if I remove the callback and add an AUGraphConnectNodeInput in it's place...


static OSStatus RenderCallback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData) {

AppDelegate *app = (AppDelegate *)inRefCon;
AudioUnit inputUnit = app->_speechUnit;
OSStatus status = noErr;

status = AudioUnitRender(inputUnit, ioActionFlags, inTimeStamp, 0, inNumberFrames, ioData);
// *** ERROR *** kAudioUnitErr_Uninitialized, code: -10867

return status;
}

- (int)createSynthGraph {
AUGRAPH_CHECK( NewAUGraph( &_graph ) );

AUNode speechNode, outputNode;

// speech synthesizer
AudioComponentDescription speechCD = {0};
speechCD.componentType = kAudioUnitType_Generator;
speechCD.componentSubType = kAudioUnitSubType_SpeechSynthesis;
speechCD.componentManufacturer = kAudioUnitManufacturer_Apple;

// output device (speakers)
AudioComponentDescription outputCD = {0};
outputCD.componentType = kAudioUnitType_Output;
outputCD.componentSubType = kAudioUnitSubType_DefaultOutput;
outputCD.componentManufacturer = kAudioUnitManufacturer_Apple;

AUGRAPH_CHECK( AUGraphAddNode( _graph, &outputCD, &outputNode ) );
AUGRAPH_CHECK( AUGraphAddNode( _graph, &speechCD, &speechNode ) );

AUGRAPH_CHECK( AUGraphOpen( _graph ) );
AUGRAPH_CHECK( AUGraphNodeInfo( _graph, outputNode, NULL, &_outputUnit ) );
AUGRAPH_CHECK( AUGraphNodeInfo( _graph, speechNode, NULL, &_speechUnit ) );

// setup stream formats:
AudioStreamBasicDescription streamFormat = [self streamFormat];
AU_CHECK( AudioUnitSetProperty( _speechUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &streamFormat, sizeof(streamFormat) ) );

// setup callback:
AURenderCallbackStruct callback;
callback.inputProc = RenderCallback;
callback.inputProcRefCon = self;
AUGRAPH_CHECK( AUGraphSetNodeInputCallback ( _graph, outputNode, 0, &callback ) );

// init and start
AUGRAPH_CHECK( AUGraphInitialize( _graph ) );
AUGRAPH_CHECK( AUGraphStart( _graph ) );
return 0;
}

Thanks for reading!

cheers,
Rich



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: getting generator audio unit output in render callback
      • From: Rich E <email@hidden>
References: 
 >Re: getting generator audio unit output in render callback (From: Rich E <email@hidden>)

  • Prev by Date: Re: getting generator audio unit output in render callback
  • Next by Date: Re: m4a metadata
  • Previous by thread: Re: getting generator audio unit output in render callback
  • Next by thread: Re: getting generator audio unit output in render callback
  • Index(es):
    • Date
    • Thread