Skip to content

Instantly share code, notes, and snippets.

@standinga
Last active June 10, 2021 18:00
Show Gist options
  • Save standinga/68a1ffbbdae393a9e9ec1780f8e591db to your computer and use it in GitHub Desktop.
Save standinga/68a1ffbbdae393a9e9ec1780f8e591db to your computer and use it in GitHub Desktop.
connectAudioUnitWithPlayer() connecting host view controller with audio unit plugin
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