AudioObject
public class AudioObject : CustomDebugStringConvertible
extension AudioObject: Hashable
A HAL audio object
-
The underlying audio object ID
Declaration
Swift
public let objectID: AudioObjectID
-
Returns
true
ifself
hasproperty
Declaration
Swift
public final func hasProperty(_ property: PropertyAddress) -> Bool
Parameters
property
The property to query
-
Returns
true
ifproperty
is settableThrows
An error ifself
does not haveproperty
Declaration
Swift
public final func isPropertySettable(_ property: PropertyAddress) throws -> Bool
Parameters
property
The property to query
-
A block called with one or more changed audio object properties
Declaration
Swift
public typealias PropertyChangeNotificationBlock = (_ changes: [PropertyAddress]) -> Void
Parameters
changes
An array of changed property addresses
-
Registers
block
to be performed whenproperty
changesThrows
An error if the property listener could not be registeredDeclaration
Swift
public final func whenPropertyChanges(_ property: PropertyAddress, perform block: PropertyChangeNotificationBlock?) throws
Parameters
property
The property to observe
block
A closure to invoke when
property
changes ornil
to remove the previous value -
Declaration
Swift
public var debugDescription: String { get }
-
Declaration
Swift
public static func == (lhs: AudioObject, rhs: AudioObject) -> Bool
-
Declaration
Swift
public func hash(into hasher: inout Hasher)
-
Returns the numeric value of
property
Note
The underlying audio object property must be backed by an equivalent native C type ofT
Throws
An error ifself
does not haveproperty
or the property value could not be retrievedDeclaration
Swift
public func getProperty<T>(_ property: PropertyAddress, type: T.Type, qualifier: PropertyQualifier? = nil, initialValue: T = 0) throws -> T where T : Numeric
Parameters
property
The address of the desired property
type
The underlying numeric type
qualifier
An optional property qualifier
initialValue
An optional initial value for
outData
when callingAudioObjectGetPropertyData
-
Returns the Core Foundation object value of
property
Note
The underlying audio object property must be backed by a Core Foundation object and return aCFType
with a +1 retain countThrows
An error ifself
does not haveproperty
or the property value could not be retrievedDeclaration
Swift
public func getProperty<T>(_ property: PropertyAddress, type: T.Type, qualifier: PropertyQualifier? = nil) throws -> T where T : AnyObject
Parameters
property
The address of the desired property
type
The underlying
CFType
qualifier
An optional property qualifier
-
Returns the
AudioValueRange
value ofproperty
Note
The underlying audio object property must be backed byAudioValueRange
Throws
An error ifself
does not haveproperty
or the property value could not be retrievedDeclaration
Swift
public func getProperty(_ property: PropertyAddress) throws -> AudioValueRange
Parameters
property
The address of the desired property
-
Returns the
AudioStreamBasicDescription
value ofproperty
Note
The underlying audio object property must be backed byAudioStreamBasicDescription
Throws
An error ifself
does not haveproperty
or the property value could not be retrievedDeclaration
Swift
public func getProperty(_ property: PropertyAddress) throws -> AudioStreamBasicDescription
Parameters
property
The address of the desired property
-
Sets the value of
property
tovalue
Note
The underlying audio object property must be backed byT
Throws
An error ifself
does not haveproperty
,property
is not settable, or the property value could not be setDeclaration
Swift
public func setProperty<T>(_ property: PropertyAddress, to value: T) throws
Parameters
property
The address of the desired property
value
The desired value
-
Returns the array value of
property
Note
The underlying audio object property must be backed by a C array ofT
Throws
An error ifself
does not haveproperty
or the property value could not be retrievedDeclaration
Swift
public func getProperty<T>(_ property: PropertyAddress, elementType type: T.Type, qualifier: PropertyQualifier? = nil) throws -> [T]
Parameters
property
The address of the desired property
type
The underlying array element type
qualifier
An optional property qualifier
-
Sets the value of
property
tovalue
Note
The underlying audio object property must be backed by a C array ofT
Throws
An error ifself
does not haveproperty
,property
is not settable, or the property value could not be setDeclaration
Swift
public func setProperty<T>(_ property: PropertyAddress, to value: [T]) throws
Parameters
property
The address of the desired property
value
The desired value
-
Returns the base class of the underlying HAL audio object
Remark
This corresponds to the propertykAudioObjectPropertyBaseClass
Declaration
Swift
public func baseClass() throws -> AudioClassID
-
Returns the class of the underlying HAL audio object
Remark
This corresponds to the propertykAudioObjectPropertyClass
Declaration
Swift
public func `class`() throws -> AudioClassID
-
Returns the audio object’s owning object
Remark
This corresponds to the propertykAudioObjectPropertyOwner
Note
The system audio object does not have an ownerDeclaration
Swift
public func owner() throws -> AudioObject
-
Returns the audio object’s name
Remark
This corresponds to the propertykAudioObjectPropertyName
Declaration
Swift
public func name() throws -> String
-
Returns the audio object’s model name
Remark
This corresponds to the propertykAudioObjectPropertyModelName
Declaration
Swift
public func modelName() throws -> String
-
Returns the audio object’s manufacturer
Remark
This corresponds to the propertykAudioObjectPropertyManufacturer
Declaration
Swift
public func manufacturer() throws -> String
-
Returns the name of
element
Remark
This corresponds to the propertykAudioObjectPropertyElementName
Declaration
Swift
public func nameOfElement(_ element: PropertyElement, inScope scope: PropertyScope = .global) throws -> String
Parameters
element
The desired element
scope
The desired scope
-
Returns the category name of
element
inscope
Remark
This corresponds to the propertykAudioObjectPropertyElementCategoryName
Declaration
Swift
public func categoryNameOfElement(_ element: PropertyElement, inScope scope: PropertyScope = .global) throws -> String
Parameters
element
The desired element
scope
The desired scope
-
Returns the number name of
element
Remark
This corresponds to the propertykAudioObjectPropertyElementNumberName
Declaration
Swift
public func numberNameOfElement(_ element: PropertyElement, inScope scope: PropertyScope = .global) throws -> String
-
Returns the audio objects owned by
self
Remark
This corresponds to the propertykAudioObjectPropertyOwnedObjects
Declaration
Swift
public func ownedObjects(ofType type: [AudioClassID]? = nil) throws -> [AudioObject]
Parameters
type
An optional array of
AudioClassID
s to which the returned objects will be restricted -
Returns
true
if the audio object’s hardware is drawing attention to itselfRemark
This corresponds to the propertykAudioObjectPropertyIdentify
Declaration
Swift
public func identify() throws -> Bool
-
Sets whether the audio object’s hardware should draw attention to itself
Remark
This corresponds to the propertykAudioObjectPropertyIdentify
Declaration
Swift
public func setIdentify(_ value: Bool) throws
Parameters
value
Whether the audio hardware should draw attention to itself
-
Returns the audio object’s serial number
Remark
This corresponds to the propertykAudioObjectPropertySerialNumber
Declaration
Swift
public func serialNumber() throws -> String
-
Returns the audio object’s firmware version
Remark
This corresponds to the propertykAudioObjectPropertyFirmwareVersion
Declaration
Swift
public func firmwareVersion() throws -> String
-
Creates and returns an initialized
AudioObject
Whenever possible this will return a specialized subclass exposing additional functionality
Declaration
Swift
public class func make(_ objectID: AudioObjectID) -> AudioObject
Parameters
objectID
The audio object ID
-
Returns
true
ifself
hasselector
inscope
onelement
Declaration
Swift
public func hasSelector(_ selector: AudioObjectSelector<AudioObject>, inScope scope: PropertyScope = .global, onElement element: PropertyElement = .master) -> Bool
Parameters
selector
The selector of the desired property
scope
The desired scope
element
The desired element
-
Returns
true
ifselector
inscope
onelement
is settableThrows
An error ifself
does not have the requested propertyDeclaration
Swift
public func isSelectorSettable(_ selector: AudioObjectSelector<AudioObject>, inScope scope: PropertyScope = .global, onElement element: PropertyElement = .master) throws -> Bool
Parameters
selector
The selector of the desired property
scope
The desired scope
element
The desired element
-
Registers
block
to be performed whenselector
inscope
onelement
changesThrows
An error if the property listener could not be registeredDeclaration
Swift
public func whenSelectorChanges(_ selector: AudioObjectSelector<AudioObject>, inScope scope: PropertyScope = .global, onElement element: PropertyElement = .master, perform block: PropertyChangeNotificationBlock?) throws
Parameters
selector
The selector of the desired property
scope
The desired scope
element
The desired element
block
A closure to invoke when the property changes or
nil
to remove the previous value