6
6
Secret Rabbit Code (aka libsamplerate)
8
8
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
9
<META NAME="Version" CONTENT="libsamplerate-0.1.4">
9
<META NAME="Version" CONTENT="libsamplerate-0.1.7">
10
10
<META NAME="Description" CONTENT="The Secret Rabbit Code Home Page">
11
11
<META NAME="Keywords" CONTENT="libsamplerate sound resample audio dsp Linux">
12
12
<LINK REL=StyleSheet HREF="SRC.css" TYPE="text/css" MEDIA="all">
74
74
<A HREF="#Q006">Q6 : I'm use the SRC_SINC_* converters and up-sampling by a ratio of
75
75
2. I reset the converter and put in 1000 samples and I expect to get 2000
76
76
samples out, but I'm getting less than that. Why?</A><BR><BR>
77
<A HREF="#Q007">Q7 : I have input and output sample rates that are integer
78
values, but the API wants me to divide one by the other and put the result
79
in a floating point number. Won't this case problems for long running
80
conversions?</A><BR><BR>
79
83
<!-- ========================================================================= -->
115
PKG_CHECK_MODULES(SAMPLERATE, samplerate >= 0.0.15,
120
PKG_CHECK_MODULES(SAMPLERATE, samplerate >= 0.1.3,
116
121
ac_cv_samplerate=1, ac_cv_samplerate=0)
118
123
AC_DEFINE_UNQUOTED([HAVE_SAMPLERATE],${ac_cv_samplerate},
288
297
call to src_process() and deal with these values appropriately.
301
<!-- ========================================================================= -->
303
<H2><BR><B>Q7 : I have input and output sample rates that are integer
304
values, but the API wants me to divide one by the other and put the result
305
in a floating point number. Won't this case problems for long running
306
conversions?</B></H2>
308
The short answer is no, the precision of the ratio is many orders of magnitude
309
more than is really needed.
312
For the long answer, lets do come calculations.
313
Firstly, the <tt>src_ratio</tt> field is double precision floating point number
315
<a href="http://en.wikipedia.org/wiki/Double_precision">
316
53 bits of precision</a>.
319
That means that the maximum error in your ratio converted to a double is one
320
bit in 2^53 which means the the double float value would be wrong by one sample
321
after 9007199254740992 samples have passed or wrong by more than half a sample
322
wrong after half that many (4503599627370496 samples) have passed.
325
Now if for example our output sample rate is 96kHz then
328
4503599627370496 samples at 96kHz is 46912496118 seconds
329
46912496118 seconds is 781874935 minutes
330
781874935 minutes is 13031248 hours
331
13031248 hours is 542968 days
332
542968 days is 1486 years
335
So, after 1486 years, the input will be wrong by more than half of one sampling
339
All this assumes that the crystal oscillators uses to sample the audio stream
341
This is not the case.
343
<a href="http://www.ieee-uffc.org/freqcontrol/quartz/vig/vigcomp.htm">
345
the accuracy of standard crystal oscillators (XO, TCXO, OCXO) is at best
347
The <tt>src_ratio</tt> is therefore 45035996 times more accurate than the
348
crystal clock source used to sample the original audio signal and any potential
349
problem with the <tt>src_ratio</tt> being a floating point number will be
350
completely swamped by sampling inaccuracies.
291
353
<!-- <A HREF="mailto:aldel@mega-nerd.com">For the spam bots</A> -->