我使用以下代码
执行此操作inputNode = audioEngine.inputNode
let bus = 0
inputNode!.installTap(onBus: bus, bufferSize: 2048, format: inputNode!.inputFormat(forBus: bus)) {
(buffer: AVAudioPCMBuffer!, time: AVAudioTime!) -> Void in
let firstChannel = buffer.floatChannelData?[0]
let arr = Array(UnsafeBufferPointer(start: firstChannel, count:Int(buffer.frameLength)))
self.array.append(contentsOf: arr)
audioEngine.prepare()
do{
try audioEngine.start()
}catch {
print("audioEngine start failed")
}
现在我想在我的Watchos3应用程序中执行此操作但是watchos3上没有输入节点..... 我该怎么做才能获得真正的麦克风数据(Float)?
答案 0 :(得分:0)
您是否已将AVAudioSession
类别设置为AVAudioSessionCategoryRecord
或AVAudioSessionCategoryPlayAndRecord
并激活会话?