AFSoundcardDelegate Protocol Reference


Overview


The AFSoundcardDelegate protocol defines optional methods implemented by the delegates of AFSoundcard objects.



Tasks


Audio Buffers

-
inputReceivedFromSoundcard:buffers:numberOfBuffers:samples:
- outputNeededBySoundcard:buffers:numberOfBuffers:samples:


Hardware Changes

- soundcard:hardwareChanged:


Selected Sound Card Changes

-
soundcard:selectedSoundcardRemoved:
- soundcard:deviceChangedTo:
-
soundcard:samplingRateChangedTo:
- soundcard:formatChangedToChannels:bits:
-
soundcard:soundSourceChangedTo:
-
soundcard:volumeChangedTo:channel:




Instance Methods



inputReceivedFromSoundcard:buffers:numberOfBuffers:samples:

Invoked to send data from an input sound card to the delegate.

buffers is an array of pointers to floating point buffers. There should be n (numberOfBuffers) pointers and buffers. The number of buffers is either the number of channels in the device, or is the number of channels available in the mask, if the mask is non-zero.

- (void)inputReceivedFromSoundcard:(AFSoundcard*)card buffers:(float**)buffers numberOfBuffers:(int)n samples:(int)samples

Parameters

card
the AFSoundcard that issued the call,

buffers
an array pointers to floating point buffers. There should be n such pointers,

n
the number of buffers,

samples
the number of floating point samples in each buffer.




outputNeededBySoundcard:buffers:numberOfBuffers:samples:

Invoked to obtain output sound card data from the delegate. The delegate returns true if after it successfully placed data in the buffers.

The delegate returns false if nothing is placed in the buffers. In this case, the AFSoundcard will check if there data within its memory that has previously been place there when the delegate called
-pushBuffers. If there is nothing in the pushed buffers, the AFSoundcard will send zeros to the sound card.

buffers is an array of pointers to floating point buffers that AFSoundcard supplies. There should be n (numberOfBuffers) pointers and buffers. The number of buffers is either the number of channels in the device, or is the number of channels available in the mask, if the mask is non-zero. Samples are the number of floating point samples that needs to be written into each buffer.

- (Boolean)outputNeededBySoundcard:(AFSoundcard*)card buffers:(float**)buffers numberOfBuffers:(int)n samples:(int)samples

Parameters

card
the AFSoundcard that issued the call,

buffers
an array pointers to floating point buffers. There should be n such pointers,

n
the number of buffers,

samples
the number of floating point samples in each buffer.


Return Value

True if the delegate has placed data into the buffers, false if the delegate has not written data into the buffers.


soundcard:deviceChangedTo:

Invoked to send tell the delegate that a new AFDevice is selected by the managed Device Menu or by the -selectDevice method.

- (void)soundcard:(AFSoundcard*)card deviceChangedTo:(AFDevice*)device

Parameters

card
the AFSoundcard that issued the call,

device
the new AFDevice.



soundcard:formatChangedToChannels:bits:

Invoked to send tell the delegate that the number of channels or number of bits has changed. The format could have been changed by the AFSoundcard that issued the call, or by a different AFSoundcard, or by another completely different process.

- (void)soundcard:(AFSoundcard*)card formatChangedTo:(int)channels bits:(int)bits

Parameters

card
the AFSoundcard that issued the call,

channels
the new number of channels,

bits
the new number of bits.



soundcard:hardwareChanged:

Invoked to send tell the delegate that the number of sound cards has changed. (Other hardware changes are not currently sent to the delegate.)

- (void)soundcard:(AFSoundcard*)card hardwareChanged:(AudioObjectPropertySelector)selector

Parameters

card
the AFSoundcard that issued the call,

selector
kAudioHardwarePropertyDevices.



soundcard:samplingRateChangedTo:

Invoked to send tell the delegate that the device sampling rate has changed. The sampling rate could have been changed by the AFSoundcard that issued the call, or by a different AFSoundcard, or by another completely different process.

- (void)soundcard:(AFSoundcard*)card samplingRateChangedTo:(float)samplingRate

Parameters

card
the AFSoundcard that issued the call,

samplingRate
the new sampling rate.



soundcard:selectedSoundcardRemoved:

Invoked to send tell the delegate that the selected device has been removed. AFSoundcard will use the default device in the Sound pref panel of System Preferences.

- (void)soundcard:(AFSoundcard*)card selectedSoundcardRemoved:(AudioDeviceID)deviceID

Parameters

card
the AFSoundcard that issued the call,

deviceID
deviceID of the default device.



soundcard:soundSourceChangedTo:

Invoked to send tell the delegate that the device sound source has changed. The source could have been changed by the AFSoundcard that issued the call, or by a different AFSoundcard, or by another completely different process.

- (void)soundcard:(AFSoundcard*)card soundSourceChangedTo:(NSString*)source

Parameters

card
the AFSoundcard that issued the call,

source
the name of the new source.



soundcard:volumeChangedTo:channel:

Invoked to send tell the delegate that the scalar volume has changed for the specified channel. The format could have been changed by the AFSoundcard that issued the call, or by a different AFSoundcard, or by another completely different process.

The volume is a scalar value between 0 and 1.0. Channel 0 is the master channel.

- (void)soundcard:(AFSoundcard*)card volumeChangedTo:(float)volume channel:(int)channel

Parameters

card
the AFSoundcard that issued the call,

volume
scalar volume,

channel
the channel the volume changed.