Last active
June 10, 2021 18:00
-
-
Save standinga/68a1ffbbdae393a9e9ec1780f8e591db to your computer and use it in GitHub Desktop.
connectAudioUnitWithPlayer() connecting host view controller with audio unit plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func connectAudioUnitWithPlayer() { | |
var componentDescription = AudioComponentDescription() | |
componentDescription.componentType = kAudioUnitType_Effect | |
// used https://codebeautify.org/string-hex-converter to convert strings to fourCC hex | |
componentDescription.componentSubType = 0x44656d6f // "Demo" | |
componentDescription.componentManufacturer = 0x44656d6f // "Demo" | |
componentDescription.componentFlags = 0 | |
componentDescription.componentFlagsMask = 0 | |
AUAudioUnit.registerSubclass(VolumePluginAudioUnit.self, as: componentDescription, name: "demo: VolumePlugin", version: UInt32.max) | |
audioPlayer.selectAudioUnitWithComponentDescription(componentDescription) { | |
guard let audioUnit = self.audioPlayer.audioUnit as? VolumePluginAudioUnit else { | |
fatalError("playEngine.testAudioUnit nil or cast failed") | |
} | |
self.pluginVC.audioUnit = audioUnit | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment