Skip to main content

Topic: Resampler plugin (Read 301446 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • bandpass
  • [*][*][*][*]
Resampler plugin
Reply #25
Hi, I know it's a little offtopic, but I wanted to ask lvqcl  to something, because I suppose he knows SOX internal routines quiet good yet.

I think bandpass knows them much more 


It's just a simple (but accurate) biquad; coefficients in the freqz line below.  So if there's already a foobar biquad plug-in, just plug-in  the numbers.

  -bandpass

% GNU Octave file (may also work with MATLAB® )
Fs=44100;minF=10;maxF=Fs/2;
sweepF=logspace(log10(minF),log10(maxF),200);
[h,w]=freqz([0.460351 -0.284408 0.0338888],[1 -1.05429 0.264123],sweepF,Fs);
semilogx(w,20*log10(h))
title('SoX effect: deemph gain=-9.477 frequency=5283 slope=0.4845 (rate=44100)')
xlabel('Frequency (Hz)')
ylabel('Amplitude Response (dB)')
axis([minF maxF -35 25])
grid on
disp('Hit return to continue')
pause



  • jaro1
  • [*][*]
Resampler plugin
Reply #26
Thanks to both lvqcl, bandpass for your comments, it was very helpfull for me.
  • Last Edit: 11 March, 2009, 06:11:07 AM by jaro1

  • bandpass
  • [*][*][*][*]
Resampler plugin
Reply #27
Just a thought: to be on the safe side, here are the coefs printed out for double precision (single precision can sometimes cause problems with IIRs):

[4.603507788631885e-01 -2.844082119124985e-01 3.388877229118695e-02]
[1 -1.054291462785692e+00 2.641228020275685e-01]

  -bandpass

  • a3aan
  • [*][*][*]
Resampler plugin
Reply #28
May I suggest a configuration option to only resample sample rates that are not supported by the (ASIO) audio card in use? Perhaps ideally just by doubling the rate until a supported rate is found?

Cheers,
Adriaan.

  • kode54
  • [*][*][*][*][*]
  • Administrator
Resampler plugin
Reply #29
May I suggest a configuration option to only resample sample rates that are not supported by the (ASIO) audio card in use? Perhaps ideally just by doubling the rate until a supported rate is found?

Cheers,
Adriaan.


Sounds like something that can be done with a separate DSP filter and the resampler_entry (resampler.h) class could be useful. An ideal solution would have a configurable list of supported sample rates, then upsample to the nearest supported rate as necessary.

  • lvqcl
  • [*][*][*][*][*]
  • Developer
Resampler plugin
Reply #30
May I suggest a configuration option to only resample sample rates that are not supported by the (ASIO) audio card in use? Perhaps ideally just by doubling the rate until a supported rate is found?

I thought about it, but ~99% of files in my music library have sample rate 44.1 kHz, so if I were to use ASIO, I'd stick with resampling all to 44 
I'll think about adding this feature.

  • a3aan
  • [*][*][*]
Resampler plugin
Reply #31
Thanks a lot for considering. I'm ready to help with some testing .

Are you saying that if I choose 44.1 kHz as a target rate then 44.1 kHz files are being sent to the card untouched? Sorry if I'm ignorant here.

May I suggest a configuration option to only resample sample rates that are not supported by the (ASIO) audio card in use? Perhaps ideally just by doubling the rate until a supported rate is found?

I thought about it, but ~99% of files in my music library have sample rate 44.1 kHz, so if I were to use ASIO, I'd stick with resampling all to 44 
I'll think about adding this feature.


  • lvqcl
  • [*][*][*][*][*]
  • Developer
Resampler plugin
Reply #32
Quote
Are you saying that if I choose 44.1 kHz as a target rate then 44.1 kHz files are being sent to the card untouched?

Sure. PPHS and SSRC do the same, though.

Resampler plugin
Reply #33
I wonder what are the difference and therefore ten different plugins to choose from? Regards

  • lvqcl
  • [*][*][*][*][*]
  • Developer
Resampler plugin
Reply #34
I wonder what are the difference and therefore ten different plugins to choose from? Regards

Sorry, didn't mention your question. They are all essentially the same. Foobar2000 prior to 0.9.6.4 didn't allow to put the same DSP plugin into its DSP chain twice, so as a workaround (and for testing purposes!) I made 10 resampler dlls.

  • lvqcl
  • [*][*][*][*][*]
  • Developer
Resampler plugin
Reply #35
Sounds like something that can be done with a separate DSP filter and the resampler_entry (resampler.h) class could be useful. An ideal solution would have a configurable list of supported sample rates, then upsample to the nearest supported rate as necessary.

What's the purpose of resampler_entry class?
(for example, when is_conversion_supported() or get_priority() functions can be useful?)

  • Yirkha
  • [*][*][*][*][*]
  • Moderator
Resampler plugin
Reply #36
[font= "Courier New"]is_conversion_supported()[/font] - some resamplers are able to convert only between certain sample rates (e.g. 44100 and 48000), so call that if you want to know before trying to instantiate it.
[font= "Courier New"]get_priority()[/font] - to differentiate resamplers with poor quality (but fast operation, e.g. for playback) and resamplers with high quality (but maybe even sub-realtime speed, e.g. for conversion).
Full-quoting makes you scroll past the same junk over and over.

  • lvqcl
  • [*][*][*][*][*]
  • Developer
Resampler plugin
Reply #37
Thanks, but what if my component doesn't have them?  I took foo_dsp_tutorial source code and used it as an example of how my component can be written. So I didn't implement anything related to resampler_entry class.

SSRC resampler has a class derived from resampler_entry but these 2 functions are never called.  Are they intended for 3rd party components and not for fb2k itself?

  • Yirkha
  • [*][*][*][*][*]
  • Moderator
Resampler plugin
Reply #38
[font= "Courier New"]dsp[/font] is a generic DSP service.

[font= "Courier New"]resampler_entry[/font] service is a special interface for resampler DSPs, so that when someone wants to resample audio data (not necessarily during/for playback), he can use one of the existing resamplers easily, providing just source and destination sample rate. That's not possible with plain DSP, because the preset format is private and configuration is set in user interface.

If foobar2000 core don't seem to be calling those two methods, it doesn't matter. It just means that the interface has been made flexible, they can naturally be useful in some scenarios (see my previous post).
Full-quoting makes you scroll past the same junk over and over.

  • lvqcl
  • [*][*][*][*][*]
  • Developer
Resampler plugin
Reply #39
Thanks again. I will use resampler_entry class (and WTL, too  ) in future versions.

Resampler plugin
Reply #40
Uploaded here

Good quality, fast resampler (~2 times faster than PPHS Ultra, although ~2.5 times slower than regular PPHS). Minimum / intermediate / linear phase.
Any comments?


Hey everyone, I upsample music with noise sharpening at 56 percent and utilize the advanced limiter to prevent clipping..

I replaced the built in foobar resampler with this one, and upsample to 48000...

I see options for a type of phase response, also steep filter and allow aliasing...

My question is, what does those settings do?I'm going for the highest quality crispest sound here, can anyone suggest settings or direct me to where i can find out more?

  • Mr.Duck
  • [*][*]
Resampler plugin
Reply #41
Thanks, lvqcl. A really excelent plugin. Must be the best resampler available for foobar. Thanks to SoX as well of course! Excelent job.

  • lvqcl
  • [*][*][*][*][*]
  • Developer
Resampler plugin
Reply #42
Quote
My question is, what does those settings do?


http://sox.sourceforge.net/Docs/FAQ  --  "What are the best 'rate' settings to resample a file and retain the highest quality?"

Resampler plugin
Reply #43
Quote
My question is, what does those settings do?


http://sox.sourceforge.net/Docs/FAQ  --  "What are the best 'rate' settings to resample a file and retain the highest quality?"



Thank you, that was very helpful, but my other questions I didn't see on the website; What is 'Allow Aliasing', and 'Steep Filter'?

  • lvqcl
  • [*][*][*][*][*]
  • Developer
Resampler plugin
Reply #44
From help file of standalone SoX program (ver. 14.4.0):

Code: [Select]
              The simple quality selection described above  provides  settings
              that satisfy the needs of the vast majority of resampling tasks.
              Occasionally, however, it may  be  desirable  to  fine-tune  the
              resampler's  filter  response;  this can be achieved using over‐
              ride options, as detailed in the following table:

              -M/-I/-L     Phase response = minimum/intermediate/linear
              -s           Steep filter (band-width = 99%)
              -a           Allow aliasing/imaging above the pass-band
              -b 74-99.7   Any band-width %
              -p 0-100     Any phase response (0 = minimum, 25 = intermediate,
                           50 = linear, 100 = maximum)

              All resamplers use filters  that  can  sometimes  create  `echo'
              (a.k.a.   `ringing')  artefacts  with  transient signals such as
              those that occur with `finger snaps' or other highly  percussive
              sounds.   Such  artefacts  are much more noticeable to the human
              ear if they occur before the transient (`pre-echo') than if they
              occur  after  it (`post-echo').  Note that frequency of any such
              artefacts is related to the smaller of the original and new sam‐
              pling rates but that if this is at least 44.1kHz, then the arte‐
              facts will lie outside the range of human hearing.

              A phase response setting may be used to control the distribution
              of  any  transient  echo  between `pre' and `post': with minimum
              phase, there is no pre-echo but the longest post-echo; with lin‐
              ear  phase,  pre  and  post echo are in equal amounts (in signal
              terms, but not audibility terms); the intermediate phase setting
              attempts to find the best compromise by selecting a small length
              (and level) of pre-echo and a medium lengthed post-echo.

              Minimum, intermediate, or  linear  phase  response  is  selected
              using  the  -M, -I, or -L option; a custom phase response can be
              created with the -p option.  Note that phase  responses  between
              `linear' and `maximum' (greater than 50) are rarely useful.

              A resampler's band-width setting determines how much of the fre‐
              quency content of the original signal (w.r.t. the original  sam‐
              ple rate when up-sampling, or the new sample rate when down-sam‐
              pling) is preserved during conversion.  The term `pass-band'  is
              used  to  refer  to  all  frequencies up to the band-width point
              (e.g. for 44.1kHz sampling rate, and a resampling band-width  of
              95%,  the  pass-band  represents  frequencies from 0Hz (D.C.) to
              circa 21kHz).  Increasing the resampler's band-width results  in
              a  slower  conversion  and can increase transient echo artefacts
              (and vice versa).

              The -s `steep filter' option changes resampling band-width  from
              the default 95% (based on the 3dB point), to 99%.  The -b option
              allows the band-width to be  set  to  any  value  in  the  range
              74-99.7  %, but note that band-width values greater than 99% are
              not recommended for normal use as they can cause excessive tran‐
              sient echo.

              If the -a option is given, then aliasing/imaging above the pass-
              band is allowed.  For example, with 44.1kHz sampling rate, and a
              resampling  band-width of 95%, this means that frequency content
              above 21kHz can be distorted; however, since this is  above  the
              pass-band  (i.e.   above the highest frequency of interest/audi‐
              bility), this may not be a problem.  The  benefits  of  allowing
              aliasing/imaging  are  reduced  processing time, and reduced (by
              almost half) transient echo artefacts.
  • Last Edit: 17 June, 2012, 04:23:27 AM by lvqcl

Resampler plugin
Reply #45

Thank you for your great support, one last question, is my setup for it good?

I use 4800hz, very best quality, disabled steep filter and allow aliasing, with a  linear phaser option, is this optimal for aac music files?

other dsp's i use...

noise sharpening 34%
advanced limiter
  • Last Edit: 06 April, 2009, 03:37:12 PM by Canar

  • lvqcl
  • [*][*][*][*][*]
  • Developer
Resampler plugin
Reply #46
Quote
Thank you for your great support, one last question, is my setup for it good?

I use 4800hz, very best quality, disabled steep filter and allow aliasing, with a linear phaser option, is this optimal for aac music files?


Yes. (I think you mean 48000 Hz?)

  • esa372
  • [*][*][*][*]
  • Members (Donating)
Resampler plugin
Reply #47
I just found this thread...

Thanks, lvqcl - It's just what i needed.

Clowns love haircuts; so should Lee Marvin's valet.

Resampler plugin
Reply #48
I do not understand.... What about "allow aliasing"? How does it affects the quality for 44.1=>48kHz resampling??? And what phase response may I use for better sound???
  • Last Edit: 09 July, 2009, 03:26:00 PM by Steve Forte Rio

  • lvqcl
  • [*][*][*][*][*]
  • Developer
Resampler plugin
Reply #49
Quote
I do not understand.... What about "allow aliasing"?

A picture is worth a thousand words:

Original test signal (44.1 kHz):


Resampled to 48 kHz (bandwith = 90%, aliasing = no):


Resampled to 48 kHz (bandwith = 90%, aliasing = yes):


(I used bandwith = 90% instead of default value (95%) to make pics more illustrative)


Quote
And what phase response may I use for better sound???

I'm sure you can find some info about linear-phase vs. minimum-phase filters here on HA.

But 44.1kHz -> 48kHz conversion introduces artifacts in ~22kHz region. So chances are high that you won't hear any difference between different settings.
  • Last Edit: 10 July, 2009, 11:38:10 AM by lvqcl