Как создать аудиофайл с форматом обработки in16 в Swift?IOS

Программируем под IOS
Anonymous
Как создать аудиофайл с форматом обработки in16 в Swift?

Сообщение Anonymous »

Это мой код, формат обработки всегда , как сделать так, чтобы он был Int16?
`let documentDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!

let audioURL = documentDirectory.appendingPathComponent("recording_\(UUID().uuidString).wav")
let int16Format = AVAudioFormat(commonFormat: .pcmFormatInt16, sampleRate: 16000, channels: 1, interleaved: true)!

do {
audioFile = try AVAudioFile(forWriting: audioURL, settings: int16Format.settings)
if let processingFormat = audioFile?.processingFormat {
print("Processing format: \(processingFormat)")
}
} catch {
print("Error creating audio file: \(error.localizedDescription)")
}


Подробнее здесь: https://stackoverflow.com/questions/790 ... 6-in-swift

Вернуться в «IOS»