iOS 9错误AKBooster

时间:2018-04-05 19:27:28

标签: ios swift audiokit

将音频工具包应用程序下载到iPad 2时出现以下错误:AURemoteIO :: IOThread(7):EXC_BAD_ACCESS(代码= 1,地址= 0x0)。但是,当我将AudioKit.output更改为modulin时,它可以工作。这将导致我相信问题在于AKBooster应用于voltageControlledAmplifer。我没有关注AudioKit配置的具体顺序吗?

public var modulin: AKOperationGenerator!
public var voltageControlledAmplifier: AKBooster!
public var recordingNode: AKMixer!

private var recorder: AKNodeRecorder!
private var player: AKAudioPlayer?

private let midi = AKMIDI()
public var midiChannelIn: MIDIChannel = MIDIChannel(UserDefaults.midiChannel)
private var currentlySelectedMidiNotes = Set<MIDINoteNumber>()

// MARK: Init

init() {
    setUpAudioKit()
    setUpMidi()
}

// MARK: Private Functions

private func setUpAudioKit() {
    modulin = AKOperationGenerator.modulin()
    modulin.start()
    voltageControlledAmplifier = AKBooster(modulin, gain: 1)

    AKSettings.playbackWhileMuted = true
    AKSettings.defaultToSpeaker = true
    AKSettings.bufferLength = AKSettings.BufferLength(rawValue: UserDefaults.preferredBufferSize)!
    AKSettings.sampleRate = UserDefaults.preferredSampleRate

    do {
        try AKSettings.setSession(category: .playAndRecord, with: [.defaultToSpeaker, .allowBluetooth, .mixWithOthers])

        recordingNode = AKMixer(voltageControlledAmplifier)
        // Recording Node and AudioKit Output must be the same
        AudioKit.output = recordingNode
        recorder = try AKNodeRecorder(node: recordingNode)

        try AudioKit.start()
    } catch {
        print("AudioKit failed to set itself up.")
    }
}

感谢您的帮助。

0 个答案:

没有答案