-
-
Notifications
You must be signed in to change notification settings - Fork 882
miscalculated Sound.duration()
(non-standard sample rate)
#6673
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
Comments
Even after #4273, miscalculated |
Although tagged as MP3 11Khz 16Bit mono in the SWF file, the actual sample rate is 16kHz. |
As a workaround, why not modify the SWF file so the sound sample rate is tagged correctly? |
Many thanks for your reply, @n0samu. Well, in that case I’d have to modify the MP3 file itself. According to the SWF File Format Specification:
In theory, 16kHz would be an invalid value. But in practice, the official player from Adobe had no problem with it. If Many thanks for your help. |
Ah that makes sense, I agree with what you're saying then |
I think this may be an easy fix, but I’m afraid I cannot code (in almost any programing language known to humankind 😅). So, I will have to wait for the fix. |
BTW, this prevents having a timer with total time in sound. |
This is what I meant in my previous comment: Total playing time is wrong, see bellow: Buttons are also missing in Ruffle, because of indirect reference (#5492). Many thanks for your help and happy holidays. |
Just in case this might help to fix this issue. In 3dfa5ad, @Herschel fixed distorted playing in MP3 with non-standard sample rates. The sample rate is read from MP3 itself for This might be where it is defined ruffle/core/src/backend/audio.rs Line 177 in eb35d62
I wonder whether it should be something similar to: let sample_rate: f64 = sound.decoder.sample_rate.into(); Of course, this is probably wrong, since all of this is totally Greek to me. But I wonder whether this might help to advance a PR to fix Many thanks for your help. |
As far as I can tell, there is no change that simple that could fix this problem. Oh, and the reason why And regarding the commit from Herschel that you linked, it's true that Ruffle's audio decoder now uses the correct sample rate, but reporting it to ActionScript is a different matter entirely. The ActionScript values are set when the SWF tag is read, not when the sound is streamed. None of this means that the task is impossible or even very difficult, but it's not as simple as it sounds. |
@n0samu, many thanks for your explanation.
I thought the same logic could be applied to Many thanks for your help again. |
Out of topic but I can't use a 16kHz MP3 stream in a Flash file (it simply doesn't play on the original Flash Player), can you tell me how can you do that while keeping the original Flash Player able to play it @ousia ? |
Be warned that sound quality is not great. I only reported this issue to be able to handle already generated animations. Are you interested in fixing the issue? Many thanks for your help. |
Thanks @ousia , I don't have enough knowledge to solve this problem. I could not run SWFC but I detected that the original Flash Player can't play 16kbps 16kHz MP3's those encoded by MP3Enc. Do you know why the original Flash Player is unable to play 16kbps 16kHz MP3's those encoded by MP3Enc (it's the MP3 encoder that is included in the original SWF creating programs)? By the way, I did not detect any degrade on the sound quality, what do you mean by "sound quality is not great"? |
I use A binary for Win64 may be obtained from https://www.rarewares.org/mp3-lame-bundle.php. Depending in your actual recorded sound, 16kbps may be too low quality. I hope it helps. |
I thought you were talking about the quality of playing 16kHz content at 11025Hz, I understand now. But 16kbps is actually pretty standard in Flash (many Flash movies use it) and I think it's pretty good when it's encoded by MP3Enc at 11025Hz, thanks. |
The attached image shows how Flash Player and Ruffle display the
Sound.duration()
of the audio contained in https://www.free-culture.tk/lfc-presentation.swf:As @Herschel has explained many times, the problem here is that the sound file has a non-standard sample rate 16kHz (although it is tagged in the SWF animation as being 11kHz).
For both
Sound.position()
andSound.duration()
, sample rate should be read from theMP3 file itself (not from SWF tagging).BTW, I think there is no need to attach a sample file (it’s over 5MB). Let me know, if you need it.
Many thanks for your excellent work.
The text was updated successfully, but these errors were encountered: