I want to record from iphone microphone and convert to ulaw format streaming data,I guess that is pcm data but I got noise.
What audio format is installTap buff? How can I do to got ulaw data format?
I can got it from AVAudioRecorder but I'm not to got a file.
Do change format settings 'AVFormatIDKey=kAudioFormatULaw' will got crash.
func testMicrophoneRecording1 () throws {
let tapNode: AVAudioNode = mixerNode
let format = tapNode.outputFormat(forBus: 0)
tapNode.installTap(onBus: 0, bufferSize: 1024, format: format, block: {
(buffer, time) in
let d = buffer.toNSData() as Data
let ulaw_data = convert_pcm_(to_ulaw: d)
sendUlawDataToDevice(data: ulaw_data)
})
try engine.start()
}
and connections is:
func makeConnections() {
let inputNode = engine.inputNode
let inputFormat = inputNode.outputFormat(forBus: 0)
engine.connect(inputNode, to: mixerNode, format: inputFormat)
let mainMixerNode = engine.mainMixerNode
let mixerFormat = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: 44100, channels: 1, interleaved: true)
engine.connect(mixerNode, to: mainMixerNode, format: mixerFormat)
}
question from:
https://stackoverflow.com/questions/66059910/i-want-to-record-from-iphone-microphone-and-convert-to-ulaw-format-streaming 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…