| Summary: | [Patch] Fixed bad resampling recently implemented in the SDL_ResampleAudioSimple (revision 938218064f67) | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Vitaly Novichkov <admin> |
| Component: | audio | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | CC: | admin |
| Version: | HG 2.1 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
A script to generate a testing files from one (it will generate various WAV files of various sample sizes and rates)
Demo of bug (source and recorded result) Experimental SDL_audiocvt.c whith my attempt to implement a fix Fixed resampler Fixed resampler Fixed resampler |
||
Created attachment 2671 [details]
Demo of bug (source and recorded result)
This is my snapshot of buggy result. Source file (Unsigned 8-bit, 11025 hz Stereo), and resampled result (Signed 16-bit, 44100 hz Stereo)
EDIT: Bug is reproducing on ANY sound output, no matter bits. "Fine" result I got because in my player still be used my custom side resampler (which working for the 16-bit sound only) which now I disabled and just found that bug is no matter to source sample size. Created attachment 2672 [details]
Experimental SDL_audiocvt.c whith my attempt to implement a fix
I have to implement a working resampler which is based on the old code of arbitrary resampler, but with the (rate_incr < 1.0) condition to choose to upsample or downsample, but I still need to fix an invalid code to have one "while" loop for both directions.
Created attachment 2674 [details]
Fixed resampler
I finally implemented the working two-direction resampler. Also, I made a small optimization and "consumed" variable is not needed.
P.S. Why you choose the "libsamplerate" instead of the "libsoxr"? Audacity team are choose the libsoxr for their purposes: http://wiki.audacityteam.org/wiki/Libsoxr Created attachment 2676 [details]
Fixed resampler
Just been updated patch to fit into recent change (adding two spaes) Comment on attachment 2676 [details]
Fixed resampler
Ouch, typo (forgot to add some space, and result is rejecting patch)
Created attachment 2677 [details]
Fixed resampler
Now it's finally compatible with latest 938218064f67 revision
(In reply to Vitaly Novichkov from comment #9) > Created attachment 2677 [details] > Fixed resampler > > Now it's finally compatible with latest 938218064f67 revision This patch looks reasonable; I'll try it today and hopefully apply it! --ryan. (In reply to Ryan C. Gordon from comment #10) > (In reply to Vitaly Novichkov from comment #9) > > Created attachment 2677 [details] > > Fixed resampler > > > > Now it's finally compatible with latest 938218064f67 revision > > This patch looks reasonable; I'll try it today and hopefully apply it! > > --ryan. Okay, your patch is now https://hg.libsdl.org/SDL/rev/efc103e60c5b Thanks! --ryan. |
Created attachment 2670 [details] A script to generate a testing files from one (it will generate various WAV files of various sample sizes and rates) Just got review new changes in SDL Audio, and I though you are finally implemented right resampler and no more need to patch it, but a bug appears again... Just my small gift for you - I made a small script which I used to quickly generate various WAV files (by using SoX utility) of various frequencies and bit sizes to test the resampling better. Use it (or any similar thing). A Bug is same on both ways (up-sample and down-sample) and appears with 8-bit source samples. With 16-bit samples is fine (finally!). Today I have no time to work, I hope you can fix this bug, or I'll try to fix it myself. Some research: - I tried to dump U8-to-F32, result seems fine. - I tried to dump F32-to-U16, result is broken, but chain is going after SDL_ResampleAudioSimple function. Is very weird that this happen with 8-bit sound, mayby you forgot to update some length and in result a broken result?