Instance Method

installTapOnBus:bufferSize:format:block:

Installs an audio tap on the bus to record. monitor, and observe the output of the node

Declaration

- (void)installTapOnBus:(AVAudioNodeBus)bus bufferSize:(AVAudioFrameCount)bufferSize format:(AVAudioFormat *)format block:(AVAudioNodeTapBlock)tapBlock;

Parameters

bus

The node output bus to which to attach the tap.

bufferSize

The requested size of the incoming buffers. The implementation may choose another size.

format

If non-nil, attempts to apply this as the format of the specified output bus.

This should only be done when attaching to an output bus which is not connected to another node; an error will result otherwise. The tap and connection formats (if non-nil) on the specified bus should be identical. Otherwise, the latter operation will override any previously set format.

For AVAudioOutputNode, tap format must be specified as nil.

tapBlock

A block to be called with audio buffers. See AVAudioNodeTapBlock for the block parameters.

Discussion

Only one tap may be installed on any bus. Taps may be safely installed and removed while the engine is running.

AVAudioEngine *engine = [[AVAudioEngine alloc] init];
AVAudioInputNode *input = [engine inputNode];
AVAudioFormat *format = [input outputFormatForBus: 0];
[input installTapOnBus: 0 bufferSize: 8192 format: format block: ^(AVAudioPCMBuffer *buf, AVAudioTime *when) {
// ‘buf' contains audio captured from input node at time 'when'
}];
....
// start engine

See Also

Installing and Removing An Audio Tap

removeTapOnBus:

Removes an audio tap on a bus.