[haiku-bugs] Re: [Haiku] #9438: Mixer not resampling very well

  • From: "Pete" <trac@xxxxxxxxxxxx>
  • Date: Thu, 11 Feb 2016 03:11:39 -0000

#9438: Mixer not resampling very well
-----------------------------------+----------------------------
   Reporter:  Pete                 |      Owner:  nobody
       Type:  bug                  |     Status:  reopened
   Priority:  normal               |  Milestone:  R1
  Component:  Add-Ons/Media/Mixer  |    Version:  R1/Development
 Resolution:                       |   Keywords:
 Blocked By:                       |   Blocking:  9704
Has a Patch:  0                    |   Platform:  All
-----------------------------------+----------------------------

Comment (by Pete):

 Replying to [comment:21 tangobravo]:


The Nyquist Theorem means you can perfectly reproduce an analog signal
 as long as your sampling rate is at least double the maximum frequency of
 the signal. Linear resampling introduces steps in the gradient of the
 signal (drop/repeat is much worse as it introduces steps in the value of
 the signal). Those steps will introduce higher-frequency components into
 the signal, harmonics of which will probably occur at audible frequencies.
 I could be wrong, but I have a strong suspicion there would be a pattern
 to these harmonics that would be particularly noticeable with a sweep - a
 little like how you get "beats" when there are two nearby frequencies.

Could test for sure by writing something to do the simple linear
 resampling offline to a wav, and then play that through the mixer (or on
 any other "known good" audio platform).

 I don't think I want to go to that length right now (:-/), but I did
 another experiment that pretty well indicates you are right.

 I realized that sox has all sorts of resampling options, so I tried the
 dirtiest one it provides -- the 'q' option => cubic interpolation -- and
 sure enough there are almost the same ghosts there.  No crackles though,
 which are definitely still in the mixer.  If I let sox do the resampling
 in higher quality, there are no artefacts.

 Another test was to generate a sweep from 10k to 15k for the mixer to
 resample, and the ghosts (and the crackles) are the same and just as
 prominent, even though the 'base' frequencies aren't.  The crackles show
 up even if I use a fixed high frequency sine, but not if I use a very low
 amplitude or silence.


The float/int discussion is relatively separate; the speexdsp code I
 posted has both floating point and integer resamplers. I believe this is
 the code that is used by Audacity too. The key point is instead of just
 linearly filling in the new samples, it actually finds the frequencies
 present in the original signal and then interpolates using them.

 That sounds expensive!  I suppose the problem can be minimized otherwise,
 anyway. I always do live music generation at the system sample rate, so
 there's no difficulty.  And if I have a recorded sample which is bad, I
 can always resample it with one of sox's high-quality options to get a
 usable version.

--
Ticket URL: <https://dev.haiku-os.org/ticket/9438#comment:22>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: