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

[Patch] Fixed bad resampling recently implemented in the SDL_ResampleAudioSimple (revision 938218064f67) #2363

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.1
Reported for operating system, platform: All, All

Comments on the original bug report:

On 2017-01-09 21:45:58 +0000, Vitaly Novichkov wrote:

Created attachment 2670
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?

On 2017-01-09 21:48:01 +0000, Vitaly Novichkov wrote:

Created attachment 2671
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)

On 2017-01-09 21:52:58 +0000, Vitaly Novichkov wrote:

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.

On 2017-01-10 23:24:48 +0000, Vitaly Novichkov wrote:

Created attachment 2672
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.

On 2017-01-11 10:31:02 +0000, Vitaly Novichkov wrote:

Created attachment 2674
Fixed resampler

I finally implemented the working two-direction resampler. Also, I made a small optimization and "consumed" variable is not needed.

On 2017-01-11 20:18:11 +0000, Vitaly Novichkov wrote:

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

On 2017-01-15 16:34:02 +0000, Vitaly Novichkov wrote:

Created attachment 2676
Fixed resampler

On 2017-01-15 16:38:21 +0000, Vitaly Novichkov wrote:

Just been updated patch to fit into recent change (adding two spaes)

On 2017-01-15 16:59:59 +0000, Vitaly Novichkov wrote:

Comment on attachment 2676
Fixed resampler

Ouch, typo (forgot to add some space, and result is rejecting patch)

On 2017-01-15 17:00:41 +0000, Vitaly Novichkov wrote:

Created attachment 2677
Fixed resampler

Now it's finally compatible with latest 938218064f67 revision

On 2017-01-17 19:27:07 +0000, Ryan C. Gordon wrote:

(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.

On 2017-01-18 07:13:39 +0000, Ryan C. Gordon wrote:

(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.

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

1 participant