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

Sound Layer Audio Delay #1179

Closed
starsvanished opened this issue Feb 15, 2019 · 8 comments
Closed

Sound Layer Audio Delay #1179

starsvanished opened this issue Feb 15, 2019 · 8 comments

Comments

@starsvanished
Copy link

@starsvanished starsvanished commented Feb 15, 2019

I can easily import audio into my sound layer in Pencil, but when I press play the audio does not play until after 12-14 frames. I have tried both MP3 and WAV files. When I export the animation, the audio plays normally at the very beginning and makes my animation no longer sync up, as I have animated after 12 or so frames to sync with the audio.

EXAMPLES:
What it sounds like in the program
https://youtu.be/Vbi-x8-K44Q

What it sounds like exported
https://www.youtube.com/watch?v=jFYCEKImgIY

Pencil2D Version: 0.6.0
I downloaded 0.6.2 and had the same issue

Operating System: Windows 10

RAM Size: 4 GB

@Jose-Moreno
Copy link
Member

@Jose-Moreno Jose-Moreno commented Feb 15, 2019

@starsvanished Hi, thank you for reporting. Fortunately this has been actually already been fixed in the latest development versions, as it was reported here #1157 about a month ago along another sound issue that was occurring on export.

So please try out the Windows 64bit build for February 5th 2019: https://drive.google.com/open?id=1juDKIkv1F8fuNruGBwauA_y-7UNWibis and let us know if this fixes your problem or not to truly know if the bug has been thoroughly solved or not 🙂

@starsvanished
Copy link
Author

@starsvanished starsvanished commented Feb 15, 2019

@Jose-Moreno I downloaded the version you linked and I still have this problem. I have had this issue for a long time, but worked around it until I finally exported something today that showed me the difference, so I'm assuming maybe I'm doing something wrong on my end. Is there a different file type I should be using or something?

@CandyFace
Copy link
Member

@CandyFace CandyFace commented Feb 15, 2019

@starsvanished It would be interesting to see the wave structure of the audio file, have you tried opening it in a program called "Audacity" to see if it is indeed supposed to begin right away?

@starsvanished
Copy link
Author

@starsvanished starsvanished commented Feb 15, 2019

@CandyFace Yes, I edited the audio in Audacity and made it start right away. Should I provide my Pencil file?

@scribblemaniac
Copy link
Member

@scribblemaniac scribblemaniac commented Feb 15, 2019

@starsvanished Yes please that would be very helpful. The easiest way to share your file would be to upload it to a cloud service (Google Drive, Dropbox, mega.nz, etc.) and link it here.

@scribblemaniac
Copy link
Member

@scribblemaniac scribblemaniac commented Feb 21, 2019

@starsvanished Thank you for sharing your file, it is helpful for narrowing down the issue. This appears to be different from the other audio issues we've encountered so far, so it could be a while before this gets fixed. One option you have is to syncronize your audio in Pencil2D, and then after exporting use a video editor to correct the delay of the audio.

For developers:
I've looked at the file and there doesn't seem to be anything in particular wrong with it. This is not an issue with the exporter, since the sound is staring in export roughly where it should be. In your video you can tell that the sound is starting somewhere around 12-16 frames later than it should in Pencil2D, but I'm not experiencing that myself. There's only about a 1-2 frame difference in audio synchronization between Pencil2D and the exported video for me. So it could be platform specific (particularly related to the media backend), or could be a difference in system specs. I'm leaning towards the latter option right now. The only thing I can think of right now is that maybe the buffer doesn't start to get filled until the playback begins (or it has to refill because of a position seek), which would be much more noticeable on a slower hard drive. If this is the issue, then I have started to hack together a possible solution, but I will wait until after v0.6.3 and after we do some more testing to determine if that is the actual issue.

@Jose-Moreno
Copy link
Member

@Jose-Moreno Jose-Moreno commented Jul 30, 2020

While this issue has been closed I'll link to this comment on the closing PR #1326 (comment)

A follow up on this PR: I have tested this on Windows and it does improve audio playback. Unfortunately, there are still two issues (both exclusive to Windows):

1. There still a ~400-800 ms delay for me upon playing a clip for the first time. I have no idea what could be causing this because the resource manager clearly shows that the sound is already in memory.
2. There is a subtle fade-in when playing a sound clip, whether from the start or from the middle of the clip.

@scribblemaniac If there's still a delay then should we reopen this? I'm not sure how much the app has changed since then but If your account still holds If we're working at 30 fps a single frame it's ~33ms roughly, that means you are getting a 12 to 24 frame delay, which is somehow worse than the delay reported by other users and what is consigned here (1-2 measured frames).

That said, I tested a simple scene with an mp3 file and opening it with a video editor seems to position the sound at the start of the track unlike before, in fact now it's not pushing the track 2-3 frames after, but pushing it 1-2 frames before the start of the track, so this is how it looks when it's over:

image

Could you retest later, even after the upcoming 0.6.5 release, to see if we should pursue afterwards?

Edit: There's also a comment that i'd like you to read form one of the related issues that the fix was meant to close #1298 (comment)

After converting it, it seems to work perfectly. When pausing and resuming quickly, no sound is repeated, and pausing and moving around seems to pick up at the correct part of the audio.
I noticed that when resuming audio, there is some audio that is skipped over due to the pause. This might mean that the way WAV files are directed to read/store the position of audio is handled differently than the case of .mp3, where perhaps mp3 is treated as a -1 while WAVs are treated as a +1. Just a guess from knowing bugs I have when I'm programming, I don't know anything about sound encoding/decoding or how the system is set up in pencil2d.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants