EZOutputDelegate
@protocol EZOutputDelegate <NSObject>
The EZOutputDelegate for the EZOutput component provides a receiver to handle play state, device, and audio data change events. This is very similar to the EZMicrophoneDelegate for the EZMicrophone and the EZAudioFileDelegate for the EZAudioFile.
-
Called anytime the EZOutput starts or stops. - parameter: output The instance of the EZOutput that triggered the event. - parameter: isPlaying A BOOL indicating whether the EZOutput instance is playing or not.
Declaration
Objective-C
- (void)output:(EZOutput *)output changedPlayingState:(BOOL)isPlaying;
Swift
optional func output(_ output: EZOutput!, changedPlayingState isPlaying: Bool)
Parameters
output
The instance of the EZOutput that triggered the event.
isPlaying
A BOOL indicating whether the EZOutput instance is playing or not.
-
Called anytime the
device
changes on an EZOutput instance. - parameter: output The instance of the EZOutput that triggered the event. - parameter: device The instance of the new EZAudioDevice the output is using to play audio data.Declaration
Objective-C
- (void)output:(EZOutput *)output changedDevice:(EZAudioDevice *)device;
Swift
optional func output(_ output: EZOutput!, changedDevice device: EZAudioDevice!)
Parameters
output
The instance of the EZOutput that triggered the event.
device
The instance of the new EZAudioDevice the output is using to play audio data.
-
Like the EZMicrophoneDelegate, for the EZOutput this method provides an array of float arrays of the audio received, each float array representing a channel of audio data. This occurs on the background thread so any drawing code must explicity perform its functions on the main thread. - parameter: output The instance of the EZOutput that triggered the event. - parameter: buffer The audio data as an array of float arrays. In a stereo signal buffer[0] represents the left channel while buffer[1] would represent the right channel. - parameter: bufferSize A UInt32 representing the size of each of the buffers (the length of each float array). - parameter: numberOfChannels A UInt32 representing the number of channels (you can use this to know how many float arrays are in the
buffer
parameter. - warning: This function executes on a background thread to avoid blocking any audio operations. If operations should be performed on any other thread (like the main thread) it should be performed within a dispatch block like so: dispatch_async(dispatch_get_main_queue(), ^{ …Your Code… })Declaration
Objective-C
- (void)output:(EZOutput *)output playedAudio:(float **)buffer withBufferSize:(UInt32)bufferSize withNumberOfChannels:(UInt32)numberOfChannels;
Swift
optional func output(_ output: EZOutput!, playedAudio buffer: UnsafeMutablePointer
Parameters
output
The instance of the EZOutput that triggered the event.
buffer
The audio data as an array of float arrays. In a stereo signal buffer[0] represents the left channel while buffer[1] would represent the right channel.
bufferSize
A UInt32 representing the size of each of the buffers (the length of each float array).
numberOfChannels
A UInt32 representing the number of channels (you can use this to know how many float arrays are in the
buffer
parameter.