Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Secret Rabbit Code resampler (Read 32055 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Secret Rabbit Code resampler

I was asked to make Secret Rabbit Code resampler component for foobar2000 now that its license isn't restrictive GPL anymore.

Its quality has also been improved since the earlier days.

First version of the component is ready and can be downloaded from http://www.foobar2000.org/components/view/foo_dsp_src_resampler.

Re: Secret Rabbit Code resampler

Reply #1
I wonder why this component is so slow even in fastest sinc mode.
Maybe you changed config.h so that HAVE_LRINT and HAVE_LRINTF are defined? These functions are awfully slow in MSVC, it's better to use inline asm.

Re: Secret Rabbit Code resampler

Reply #2
Thanks for looking after me. Indeed I had disabled those when debugging a problem and forgot to enable them. Faster versions uploaded.

Re: Secret Rabbit Code resampler

Reply #3
Rollin's post about resampling ruining gaplessness has been bothering me ever since reading it. I implemented the extrapolation used in Vorbis and Opus to SRC resampler v1.0.2 and it appears to perform quite well. At least those sample files from the linked post can be resampled without glitches.

Edit: added two comparison screenshots of the transition position. One is resampled with SoX using hiqhest quality and the other one is SRC with extrapolation.

Re: Secret Rabbit Code resampler

Reply #4
Quote
1.0.3 (2018-01-21): Added resampler service entry. Priority of the service can be configured in advanced preferences
Some things about resampler's service priority are unclear for me.
In what situations priority of resampler's service is used? Replaygain scanning with upsampling, replaygain scanning with downsampling (BTW: to what samplerate is downsamling performed on Replaygain scanning when option "Use downsampling" is enabled?), playing files with high samplerates to directsound or something else?
Also, i did some testing that lead me to next conclusions (please correct me if i'm wrong):
1)If there are no 3rd party resamplers, then built-in dBpoweramp/SSRC is used (at least when playing files with high samplerates to directsound)
2)Resampler with priority 100 will be used over built-in resampler
But i still have some questions:
1)What priority should resampler have not to be used over built-in resampler or is this not possible?
2)If there are 2 (or more) 3rd party resamplers with the same priority, which one will be used?

Re: Secret Rabbit Code resampler

Reply #5
Please delete. I quote myself instead of editing.

Re: Secret Rabbit Code resampler

Reply #6
If there are no 3rd party resamplers, then built-in dBpoweramp/SSRC is used (at least when playing files with high samplerates to directsound)
Correction: PPHS (not in ultra mode) is used

Re: Secret Rabbit Code resampler

Reply #7
My understanding is that the core sorts resamplers by priority but the order between services with the same priority is random as the component loading order is randomized on each launch.

Priority affects all the situations where a component requests resampling. Highest priority is preferred and lower priority resampler services only get used if the requested ratio isn't supported by the earlier contenders.

I'm not sure about priorities of all the resamplers bundled in the standard DSP component but I know SSRC at least has the highest priority. I have suggested Peter to make internal resampler priorities configurable too or extend the priority concept to allow taking resampler qualities and speeds into account. For example SoX offers fastest high quality resampling speeds and it would make sense to prefer it in those conversions. ReplayGain's peak scanner requests lowest quality and SRC's linear mode would be sufficient. It works several times faster than SoX's lowest quality mode so it might make sense to be in use there.

(BTW: to what samplerate is downsamling performed on Replaygain scanning when option "Use downsampling" is enabled?)
44.1 kHz. The most common sample rate without too much inaudible content present.

Edit: I thought about defaulting SRC component's priority a little lower than the max, but it's still faster than SSRC component and quality is sufficiently good. Also the lower quality modes are faster than anything. But if someone wishes to have Secret Rabbit installed but not utilize it in resampler services, the priority can be lowered and other resamplers will be used instead.

Re: Secret Rabbit Code resampler

Reply #8
I'm not sure about priorities of all the resamplers bundled in the standard DSP component but I know SSRC at least has the highest priority.
But it means that it's not possible to always prefer external resamplers to internal. If SRC or SoX priority is 99 or lower then internal resampler is used, and if it's equal to 100 then the winner is randomly chosen at each fb2k start.
(and if Rollin is right then PPHS has max. priority, not SSRC. Or they have the same priority, but PPHS is always preferred).

ReplayGain's peak scanner requests lowest quality and SRC's linear mode would be sufficient.
But how?? Peak scanner oversamples to detect intersample overflows, and these don't exist with linear or ZOH resampling: values of new samples can't be higher than values of existing samples.

But if someone wishes to have Secret Rabbit installed but not utilize it in resampler services, the priority can be lowered
By the way: the name of the setting is "Resampler service priority (0-100)" but its minimum possible value is actually 1, not 0 (not that it matters much...)

Re: Secret Rabbit Code resampler

Reply #9
I'm not sure about priorities of all the resamplers bundled in the standard DSP component but I know SSRC at least has the highest priority.
But it means that it's not possible to always prefer external resamplers to internal. If SRC or SoX priority is 99 or lower then internal resampler is used, and if it's equal to 100 then the winner is randomly chosen at each fb2k start.
Indeed. Needs clarification/fixing.

ReplayGain's peak scanner requests lowest quality and SRC's linear mode would be sufficient.
But how?? Peak scanner oversamples to detect intersample overflows, and these don't exist with linear or ZOH resampling: values of new samples can't be higher than values of existing samples.
Good point. I hadn't thought it through and I think neither had Peter. I requested highest quality resampling in the old True Peak scanner I made before core implemented the feature. I have lost the ability to think since then apparently.
Not sure whether to convince Peter to request higher quality resampling in the peak scanner or disable the ability to use the non-sinc modes in my component. At least the fastest sinc mode in Rabbit is still faster than SSRC.

By the way: the name of the setting is "Resampler service priority (0-100)" but its minimum possible value is actually 1, not 0 (not that it matters much...)
Oh damn. I mixed up config order priority and the minimum value on the parameters. Thanks.

Re: Secret Rabbit Code resampler

Reply #10
The just released foobar2000 v1.4 beta 4 has a solution for the resampler priority mess. ReplayGain scanner now has special configuration to decide which resamplers and settings to use. And under Tools section of Advanced Preferences there's configuration for resampler service order.

Re: Secret Rabbit Code resampler

Reply #11
I suppose there is no way to just resample certain frequencies or exclude certain frequencies.  Any chance of a mod version?

FWIW,  on a low powered N3700 the highest quality setting caused audio to skip when resampling to 352800.  I guess it's too much for my puny Pentium.  Medium quality worked, although with much higher CPU usage than SOX.  However, still not enough load to cause the fan to ramp up to audible levels.

Re: Secret Rabbit Code resampler

Reply #12
I just released a new version that allows excluding frequencies. The edit field in the configuration accepts both individual frequencies and ranges. Values are separated with commas or semicolons. For example to exclude everything below and including 44.1 kHz and 48 kHz you could type: "0-44100, 48000".

Re: Secret Rabbit Code resampler

Reply #13
I just released a new version that allows excluding frequencies. The edit field in the configuration accepts both individual frequencies and ranges. Values are separated with commas or semicolons. For example to exclude everything below and including 44.1 kHz and 48 kHz you could type: "0-44100, 48000".

Yay, thanks!

Re: Secret Rabbit Code resampler

Reply #14
I took 10-second audio (44100 Hz, 441000 samples) and converted to 96 kHz (Best Sinc). The resulting file has duration 9.98 seconds (958482 samples instead of 960000).
I have only 1.0.4 and 1.0.5 versions on my computer, and both versions are affected.

Re: Secret Rabbit Code resampler

Reply #15
Nice find, thanks. Stupid bug in the extrapolation clipping code and I had only tested it with downsampling. Fixed versions uploaded.

Re: Secret Rabbit Code resampler

Reply #16
I get an error message when I seek. The message is displayed when I seek a minute ahead, when it's less than a minute left on the track.
"Unrecoverable playback error: SRC_DATA->data_out or SRC_DATA->data_in is NULL."

I'm using foobar2000 v1.3.17 on Windows 7 x64.

Please ignore this message, it was foo_dsp_nogaps causing the problem.

Re: Secret Rabbit Code resampler

Reply #17
My foo_dsp_nogaps or Acropolis' modification? If my component has a bug I'd very much like to fix it.

Re: Secret Rabbit Code resampler

Reply #18
My foo_dsp_nogaps or Acropolis' modification? If my component has a bug I'd very much like to fix it.

Hello Case. I am using you version of foo_dsp_nogaps (v0.4). I have not tried Acropolis' version.
The error message also when I seek on the end of the track.
Let's say ther's 8 seconds left and I seek 10 seconds ahead or 1 minute ahead (scrolling with the mouse courser over the seek bar).
The error massage appears as posted above.

Code: [Select]
Core (2017-11-24 08:00:06 UTC)
    foobar2000 core 1.3.17
foo_ac3.dll (2018-01-26 15:55:06 UTC)
    AC3 decoder 0.9.10
foo_albumlist.dll (2017-11-24 07:58:40 UTC)
    Album List 4.5
foo_audioscrobbler.dll (2016-08-23 18:35:02 UTC)
    Audioscrobbler 1.4.7
foo_cdda.dll (2017-11-24 07:58:36 UTC)
    CD Audio Decoder 3.0
foo_converter.dll (2017-11-24 07:58:34 UTC)
    Converter 1.5
foo_cuefilter.dll (2016-08-28 20:29:01 UTC)
    CUE Playlist Filter 0.1.7.0
foo_dsp_centercut.dll (2017-01-01 21:04:57 UTC)
    Center Cut 1.0.1u
foo_dsp_delta.dll (2018-02-05 16:25:25 UTC)
    Noise Sharpening DSP 1.0.0
foo_dsp_effect.dll (2017-11-27 00:40:52 UTC)
    Effect DSP 0.22
foo_dsp_eq.dll (2017-11-24 07:58:56 UTC)
    Equalizer 1.2
foo_dsp_nogaps.dll (2018-01-09 21:24:40 UTC)
    Gap Killer DSP 0.4
foo_dsp_skip_silence.dll (2018-01-09 21:24:41 UTC)
    Skip Silence 1.0.2
foo_dsp_src_resampler.dll (2018-03-18 13:52:16 UTC)
    SRC Resampler 1.0.6
foo_dsp_std.dll (2017-11-24 07:58:42 UTC)
    Standard DSP Array 1.3.1
foo_fileops.dll (2017-11-24 07:57:40 UTC)
    File Operations 2.2.2
foo_freedb2.dll (2017-11-24 07:57:34 UTC)
    Online Tagger 0.7
foo_input_std.dll (2017-11-24 08:23:10 UTC)
    FFmpeg Decoders 3.2.4
    Standard Input Array 1.0
foo_keep_queue.dll (2016-08-23 18:35:17 UTC)
    Keep Queue 0.3.5
foo_midi.dll (2018-02-10 19:37:42 UTC)
    MIDI Player 2.0.22
foo_openmpt54.dll (2018-02-05 16:25:25 UTC)
    OpenMPT component (kode54 fork) 0.3.6
foo_out_wasapi.dll (2017-08-01 09:38:09 UTC)
    WASAPI output support 3.3
foo_playcount.dll (2016-08-23 18:35:22 UTC)
    Playback Statistics 3.0.2
foo_r128norm.dll (2017-02-05 10:43:31 UTC)
    EBU R128 Normalizer 1.12
foo_rgscan.dll (2017-11-24 08:03:34 UTC)
    ReplayGain Scanner 2.2.2
foo_skip.dll (2016-08-23 18:35:33 UTC)
    Skip Track 1.9.8
foo_ui_std.dll (2017-11-24 07:58:50 UTC)
    Default User Interface 0.9.5
foo_verifier.dll (2017-12-07 10:13:39 UTC)
    File Integrity Verifier 1.2.1

Re: Secret Rabbit Code resampler

Reply #19
I don't see anything wrong in the foo_dsp_nogaps source. It never sends empty audio chunks out. Also I have tried my best to replicate the error but I fail.
But if it's only Rabbit resampler erroring out I can add more checks against invalid audio chunks. Can you see if everything works properly with the attached version?

Edit: attachment removed. Changes included in the new release.

Re: Secret Rabbit Code resampler

Reply #20
I don't see anything wrong in the foo_dsp_nogaps source. It never sends empty audio chunks out. Also I have tried my best to replicate the error but I fail.
But if it's only Rabbit resampler erroring out I can add more checks against invalid audio chunks. Can you see if everything works properly with the attached version?

That fixed it, thank you very much :)

Re: Secret Rabbit Code resampler

Reply #21
After some testing I have come to prefer SRC over the SOX and very much appreciatre the work by @Case.
Overall I'm finding the sound more clearer than SRX.

Is there a way to specify only 44100Hz to be sampled up ?

I would like my Hi Res 24/96-192 tracks to remain untouched.

EDIT-Upgraded to version 1.07 and now see an Exclude option.

Will the Excluded rates be left untouched and what should be used to seperate more than one value ?

Re: Secret Rabbit Code resampler

Reply #22
Will the Excluded rates be left untouched and what should be used to seperate more than one value ?
Excluded rates will be left completely untouched. Same as when the input sample rate matches the target sample rate. You separate multiple exclusions with comma (,) or semicolon (;), whichever you prefer. Note that it supports ranges too so to exlude rates between 96 kHz and 192 kHz just enter 96000-192000.

Re: Secret Rabbit Code resampler

Reply #23
Ivqcl, I am currently using your excellent Sox resampler mod2, and have noted your comments here about Case's improved SRC.  Am wondering as to how you would compare the two as to performance..  We've got two geniuses at work here who respect each other, so I'm very curious as to both of their impressions!

Re: Secret Rabbit Code resampler

Reply #24
Well, first, the algorithms of SoX resampler and Secret Rabbit Code were written by Rob Sykes and Erik de Castro Lopo, so kudos to them.

Second, not sure what you mean by performance. Speed-wise, SoX is faster than SRC (mostly because of their algorithms). Quality-wise, they are mostly the same. All high quality resamplers are the same: transparent.

The feature with signal extrapolation is neat though.