EZMicrophoneDelegate
@protocol EZMicrophoneDelegate <NSObject>
The EZMicrophoneDelegate for the EZMicrophone provides a receiver for the incoming audio data events. When the microphone has been successfully internally configured it will try to send its delegate an AudioStreamBasicDescription describing the format of the incoming audio data.
The audio data itself is sent back to the delegate in various forms:
-microphone:hasAudioReceived:withBufferSize:withNumberOfChannels:
Provides float arrays instead of the AudioBufferList structure to hold the audio data. There could be a number of float arrays depending on the number of channels (see the function description below). These are useful for doing any visualizations that would like to make use of the raw audio data.
-microphone:hasBufferList:withBufferSize:withNumberOfChannels:
Provides the AudioBufferList structures holding the audio data. These are the native structures Core Audio uses to hold the buffer information and useful for piping out directly to an output (see EZOutput).
-
Called anytime the EZMicrophone starts or stops. - parameter: output The instance of the EZMicrophone that triggered the event. - parameter: isPlaying A BOOL indicating whether the EZMicrophone instance is playing or not.
Declaration
Objective-C
- (void)microphone:(EZMicrophone *)microphone changedPlayingState:(BOOL)isPlaying;
Swift
optional func microphone(_ microphone: EZMicrophone!, changedPlayingState isPlaying: Bool)
Parameters
output
The instance of the EZMicrophone that triggered the event.
isPlaying
A BOOL indicating whether the EZMicrophone instance is playing or not.
-
Called anytime the input device changes on an
EZMicrophone
instance. - parameter: microphone The instance of the EZMicrophone that triggered the event. - parameter: device The instance of the new EZAudioDevice the microphone is using to pull input.Declaration
Objective-C
- (void)microphone:(EZMicrophone *)microphone changedDevice:(EZAudioDevice *)device;
Swift
optional func microphone(_ microphone: EZMicrophone!, changedDevice device: EZAudioDevice!)
Parameters
microphone
The instance of the EZMicrophone that triggered the event.
device
The instance of the new EZAudioDevice the microphone is using to pull input.
-
Returns back the audio stream basic description as soon as it has been initialized. This is guaranteed to occur before the stream callbacks,
microphone:hasBufferList:withBufferSize:withNumberOfChannels:
ormicrophone:hasAudioReceived:withBufferSize:withNumberOfChannels:
- parameter: microphone The instance of the EZMicrophone that triggered the event. - parameter: audioStreamBasicDescription The AudioStreamBasicDescription that was created for the microphone instance.Declaration
Objective-C
- (void)microphone:(EZMicrophone *)microphone hasAudioStreamBasicDescription: (AudioStreamBasicDescription)audioStreamBasicDescription;
Swift
optional func microphone(_ microphone: EZMicrophone!, hasAudioStreamBasicDescription audioStreamBasicDescription: AudioStreamBasicDescription)
Parameters
microphone
The instance of the EZMicrophone that triggered the event.
audioStreamBasicDescription
The AudioStreamBasicDescription that was created for the microphone instance.
-
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: microphone The instance of the EZMicrophone 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 The size of each of the buffers (the length of each float array). - parameter: numberOfChannels The number of channels for the incoming audio. - 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)microphone:(EZMicrophone *)microphone hasAudioReceived:(float **)buffer withBufferSize:(UInt32)bufferSize withNumberOfChannels:(UInt32)numberOfChannels;
Swift
optional func microphone(_ microphone: EZMicrophone!, hasAudioReceived buffer: UnsafeMutablePointer
Parameters
microphone
The instance of the EZMicrophone 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
The size of each of the buffers (the length of each float array).
numberOfChannels
The number of channels for the incoming audio.
-
Returns back the buffer list containing the audio received. This occurs on the background thread so any drawing code must explicity perform its functions on the main thread. - parameter: microphone The instance of the EZMicrophone that triggered the event. - parameter: bufferList The AudioBufferList holding the audio data. - parameter: bufferSize The size of each of the buffers of the AudioBufferList. - parameter: numberOfChannels The number of channels for the incoming audio. - 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)microphone:(EZMicrophone *)microphone hasBufferList:(AudioBufferList *)bufferList withBufferSize:(UInt32)bufferSize withNumberOfChannels:(UInt32)numberOfChannels;
Swift
optional func microphone(_ microphone: EZMicrophone!, hasBufferList bufferList: UnsafeMutablePointer
Parameters
microphone
The instance of the EZMicrophone that triggered the event.
bufferList
The AudioBufferList holding the audio data.
bufferSize
The size of each of the buffers of the AudioBufferList.
numberOfChannels
The number of channels for the incoming audio.