1 Here are some helper programs for checking filter and rate conversion
2 accuracy of sox. The programs in the test subdirectory which I
3 (Stanley J. Brooks) wrote are covered by the GPL. See the
4 ../LICENSE.GPL file for details. Sox is also covered by the GPL.
6 To use this stuff, first cd to this test subdirectory and run make,
7 which should produce the corr, model, and lmodel executables.
9 Now to test something...
11 Say you want to compare the 'band' effect to the 'filter' effect...
13 ./ltest.pl band 800 200 >A
14 ./ltest.pl filter 600-1000 >B
17 plots the response curves with y being power-gain in dB,
20 For another, say to compare response and error of resample
21 rate conversion from 8000 ->22050 samples per second,
22 with linear (default) interpolation versus -qs quadratic
23 interpolation with Nuttall window...
25 ./ltest.pl -l resample >A
26 ./ltest.pl -l resample -qs 0.80 0 >B
29 The script wtest.pl is for testing sox's adpcm and gsm wav support.
31 It accepts one of these options:
32 -t Use 'toast' gsm for compress/decompress
35 -g Use sox wav-gsm6.10
36 If using sox, you may also append an optional effect, eg:
37 ./wtest -g filter 0-3500 >A
38 will apply a lowpass filter with 6dB corner at 3500 Hz before the
41 Then, as above, 'gnuplot plotA' will graph dB gain and dB error-level
44 -------------------------------------------------------------------
48 -l means use 32-bit signed samples, otherwise 16-bit signed is used.
50 The other parameters are fed into sox as the 'effect' with parameters.
52 The rates 8000:22050 are in the script, but you can edit a perl script,
53 I hope. just change the ($rate0,$rate1)=(8000,22050) line near the top.
57 It uses sox to synthesize a sineusoid input file for the
58 frequencies 0.01 ... 0.99 of the Nyquist frequency. This input
60 400 samples samples of silence,
61 4000 samples with smooth envelope rising to volume -v0.5
62 16000 samples at -v0.5
63 4000 samples with smooth envelope falling to 0,
64 400 sample more of silence.
66 The rising/falling envelopes are shaped like rising, falling portions
67 of the (1-cos(x)) function.
69 Then the filter or rate-change effect is applied to this i0.xx.xx file
70 to give an output file.
72 The output file is examined by the 'model' or 'lmodel' program to analyse
73 response level and error level.
75 model works as follows:
77 step 1: the entire sample file is read in, and the center-of-gravity of
78 the squared samples is found. This is the time offset which should
79 correspond to the center of the filtered/resampled tone-pulse.
81 step 2: let N = 16000*(rate1/rate0) be the number of samples at output rate
82 which would correspond to the 16000 sample duration at max volume.
83 We focus on the samples between
84 (center - 0.3*N) and (center + 0.9*N)
85 where the transient effects of attack/release envelope should be
87 We do a least-squares fit of a sinusoid at the adjusted frequency
88 to this segment of 0.6*N samples, and print out the component
89 s2max which can be explained, and also the rms level of the 'error'
92 That's pretty much it... the ltest perl-script glues it together and outputs
93 adjusted data which the gnuplot will like.
95 Modify the perl and gnuplot scripts to suit your needs.