Open zjfMVC opened 3 months ago
No, but you can record in a file, which I do like this:
audioPlayer.addFrameFilter(withName: "RecordFilter", afterFilterWithName: "CustomEQFilter") { (channelsPerFrame, bytesPerFrame, frameCount, frames) in
let sampleRate: Double = 44100
if audioFile == nil {
let settings = [
AVFormatIDKey: self.formatIDKey, // kAudioFormatLinearPCM
AVSampleRateKey: sampleRate,
AVNumberOfChannelsKey: channelsPerFrame,
] as [String : Any]
do {
audioFile = try AVAudioFile(forWriting: outputUrl, settings: settings, commonFormat: .pcmFormatInt16, interleaved: true)
} catch {
let error = error as NSError
print("Error: \(error.localizedDescription)")
}
}
let format = AVAudioFormat(commonFormat: .pcmFormatInt16, sampleRate: sampleRate, channels: channelsPerFrame, interleaved: true)
let buffer = AVAudioPCMBuffer(pcmFormat: format!, frameCapacity: frameCount)
buffer?.frameLength = frameCount
memmove(buffer?.int16ChannelData?[0], frames, Int(frameCount * bytesPerFrame))
do {
if let buffer = buffer {
try audioFile?.write(from: buffer)
}
} catch let error as NSError {
print("Error: \(error)")
}
}
Hello, the project I am currently developing uses this excellent open-source library. I have a question to know if this library supports local caching. For example, can I replay the previously played audio after playing first hand music and then disconnecting from the network?