David Richards | 7 Feb 2011 23:31
Picon
Gravatar

Resampling Output Levels

Hello.

I am using libsamplerate to both do resampling and pitch scaling, and
it really sounds great. Of course, as it says in the FAQ, the output
is higher than the input in many cases. From my testing, if I drop the
output from libsamplerate by -2.0db my final output doesn't seem to
clip.

So this is probably somewhat of a n00bie question, but just point me
to the right reading materials and I will educate myself :p  Is it
possible to predict what the highest possible samples will be given an
input and output rate? Or is it possible to predict an average higher
output level, beyond which only a few samples would clip and you could
just brickwall them? (that sounds a bit sloppy)

Basically what I am trying to do with music in real time is to  a)
resample if needed  b) pitch scale if desired   (In the sense of just
resampling and playing back at the original sample rate for the same
effect as pitch on a vinyl record player)

And I'm doing this in real time as opposed to generating a file, so
normalization wont' work, but I'd rather not use a limiter in this
particular signal path if possible. (or if it is on the path, it is
very rarely hit) .. So if I am pushing through music that is not being
resampled or pitch scaled, then its verbatim output, but if it is
resampled or pitch scaled then I am dropping -2.0 db...  thats
probably not good, I could have it drop -2.0 db all of the time, but
that seems like a mistake too as the stream I am generating would be a
bit quieter than everything else.

(Continue reading)

Erik de Castro Lopo | 7 Feb 2011 23:49
Favicon

Re: Resampling Output Levels

David Richards wrote:

> I am using libsamplerate to both do resampling and pitch scaling, and
> it really sounds great. Of course, as it says in the FAQ, the output
> is higher than the input in many cases.

Ok, you found the FAQ.

> From my testing, if I drop the
> output from libsamplerate by -2.0db my final output doesn't seem to
> clip.
> 
> So this is probably somewhat of a n00bie question, but just point me
> to the right reading materials and I will educate myself :p  Is it
> possible to predict what the highest possible samples will be given an
> input and output rate?

Unfortunately, its highly signal dependent and would probably also
be different for each of the SRC_SINC_* converters.

The worst case would probably be a signal like:

   -1,-1, ... -1,-1, 1, 1, ... 1, 1, -1, -1 ...

but I've never really bothered to figure out what the worst case is.

Sorry I can't be of more help.

Erik
--

-- 
(Continue reading)


Gmane