Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AKAudioFile Format changed after export #2133

Closed
nikolindima opened this issue Jul 5, 2020 · 2 comments
Closed

AKAudioFile Format changed after export #2133

nikolindima opened this issue Jul 5, 2020 · 2 comments

Comments

@nikolindima
Copy link

I try to use AKNodeRecorder to record mic data.
After i run record() method - i get this output in console:
[general] AKNodeRecorder.swift:record():114:Recording using format <AVAudioFormat 0x2817fe210: 2 ch, 48000 Hz, Float32, non-inter> (AKNodeRecorder.swift:record():114)

My session is setup for 48 kHz - AKSettings.sampleRate = 48000

After recording I try to save data but saved file have different sample rate

recorder.stop()
let tape = recorder.audioFile
print(tape?.fileFormat) // Optional(<AVAudioFormat 0x2821dd9f0: 2 ch, 48000 Hz, Float32, inter>)
print(tape?.processingFormat) // Optional(<AVAudioFormat 0x2821dd810: 2 ch, 48000 Hz, Float32, non-inter>)
tape?.exportAsynchronously(name: "name", baseDir: .documents, exportFormat: .m4a) {file, exportError in
if let error = exportError {
print("Export Failed (error)")
} else {
print("Export succeeded")
print(file?.fileFormat) //Optional(<AVAudioFormat 0x2821de2b0: 2 ch, 44100 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame>)
print(file?.processingFormat) //Optional(<AVAudioFormat 0x2821dd9f0: 2 ch, 44100 Hz, Float32, non-inter>)
}
}

I have this problem only with m4a and mp4 format. With caf, aif and wav - format is 48 kHz

@ryanfrancesconi
Copy link
Member

AKAudioFile is going to be deprecated. I recommend using AKConverter instead. If the source sample rate is 48k the output should be there as well.

@aure aure closed this as completed Jul 14, 2020
@ryanfrancesconi
Copy link
Member

check the macOS Recorder example in the v5 development branch for the AKConverter example. AKAudioFile is now removed from the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants