Reputation: 175
In OS X, I am trying to find an example of how to discover all the Audio Units installed on an end-users system and get back that information for display and use.
I know that Audio Component is involved with that task, but I am completely baffled how to go about doing it. All the examples I come across are based around finding a 'known' Apple AU with AudioComponentFindNext, and I cannot find an example for discovering anything else.
Can anyone point me to an example?
Thanks
Upvotes: 4
Views: 1262
Reputation: 2737
Simply use the provided AVAudioUnitComponentManager components function to get audio units.
It will return an array of audio units that match the AudioComponentDescription
you pass.
Command click AudioComponentDescription
and kAudioUnitType_MusicDevice
to see the various values you can use.
// Exemple to get instruments audio units
var match = AudioComponentDescription()
match.componentType = kAudioUnitType_MusicDevice
let audioUnitComponents = AVAudioUnitComponentManager.shared().components(matching: match)
Upvotes: -1
Reputation: 16976
You can set up a AudioComponentDescription
struct using 0
as a wildcard for type, subtype, and manufacturer. Pass that to AudioComponentFindNext
:
AudioComponentDescription acd = { 0 };
AudioComponent comp = nullptr;
while((comp = AudioComponentFindNext(comp, &acd)) {
// Found an AU
}
Here is some relevant documentation from the header:
@function AudioComponentFindNext
@abstract Finds an audio component.
@discussion This function is used to find an audio component that is the closest match
to the provided values.
@param inComponent
If NULL, then the search starts from the beginning until an audio
component is found that matches the description provided by inDesc.
If non-NULL, then the search starts (continues) from the previously
found audio component specified by inComponent, and will return the next
found audio component.
@param inDesc
The type, subtype and manufacturer fields are used to specify the audio
component to search for. A value of 0 (zero) for any of these fields is
a wildcard, so the first match found is returned.
@result An audio component that matches the search parameters, or NULL if none found.
Upvotes: 3