-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
AudioPlayer buffer samplerate mismatch #2794
Comments
Your solution does not seem bad, though it would be nice if it just worked. If you come up with a change that fixes it from within AudioKit, make a PR and I'll release a version with the fix. |
The current AudioPlayer is full of if's for buffered and non-buffered behaviour. Also unexpected behaviour as mentioned here: #2788 I am thinking about writing my own Any thought on this being changed for AudioKit? If so I can see if I can get some time to make it and push a PR. |
I think breaking it up into its own thing is a great idea, would welcome a PR to this end. |
@renezuidhof Happy to collaborate with you on this, I would like a BufferedAudioPlayer too. Thank you for the workaround! |
I actually only just started on creating a buffered audioplayer for my own application. I hope to move this to AudioKit when it is done. So far I could work with the current AudioPlayer available in AudioKit. For a new feature I need offline rendering, this gives me some problems since I cannot use the I'm not sure how long it will take, but hopefully I can get around to it soon! EDIT:
|
It's all good. You might want to take a look at the |
Thanks for the update! I just checked out the What would be the alternative for I was planning on creating the BufferedAudioPlayer with the |
We could create our own audio player audio unit. You can still use things like |
Update: It sounds like |
Setting the Audio Player's initial file/buffer after the engine's output is set seems to make the format update correctly. |
macOS Version(s) Used to Build
macOS 12 Monterey
Xcode Version(s)
Xcode 14
Description
The samplerate of the
outputFormat
ofplayerNode
in anAudioPlayer
does not seem to match with the buffer that is being used. I don't have any issues when using a non-bufferedAudioPlayer
This results in slowed down audio because the
outputFormat
of theplayerNode
is 44100 while the file has a samplerate of 48000 (on my device, in the simulator it works fine).In
AVFAudio.AVAudioPlayerNode
there's a comment mentioning:When playing buffers, there is an implicit assumption that the buffers are at the same sample rate as the node's output format.
I've read somewhere that setting the audioFormat fixes these kind of issues but it does not work.
I noticed there's a check on format in the AudioPlayer:
https://github.com/AudioKit/AudioKit/blob/main/Sources/AudioKit/Nodes/Playback/AudioPlayer/AudioPlayer.swift#L257
But when loading the first file, this part will not be checked. Therefor the
makeInternalConnections
function on line 273 will not be called.I've created an extension function of the AudioPlayer where I choose to reconnect the AudioPlayer. This solves the issue.
Is there something I'm missing so I don't have to reconnect? Or is this the way to go for now?
Crash Logs, Screenshots or Other Attachments (if applicable)
No response
The text was updated successfully, but these errors were encountered: