1Here are some helper programs for checking filter and rate conversion 2accuracy 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. 5 6To use this stuff, first cd to this test subdirectory and run make, 7which should produce the corr, model, and lmodel executables. 8 9Now to test something... 10 11Say you want to compare the 'band' effect to the 'filter' effect... 12 13./ltest.pl band 800 200 >A 14./ltest.pl filter 600-1000 >B 15gnuplot responseAB 16 17plots the response curves with y being power-gain in dB, 18and x the frequency. 19 20For another, say to compare response and error of resample 21rate conversion from 8000 ->22050 samples per second, 22with linear (default) interpolation versus -qs quadratic 23interpolation with Nuttall window... 24 25./ltest.pl -l resample >A 26./ltest.pl -l resample -qs 0.80 0 >B 27gnuplot plotAB 28 29The script wtest.pl is for testing sox's adpcm and gsm wav support. 30 31It accepts one of these options: 32 -t Use 'toast' gsm for compress/decompress 33 -a Use sox (MS) ADPCM 34 -i Use sox IMA ADPCM 35 -g Use sox wav-gsm6.10 36If using sox, you may also append an optional effect, eg: 37 ./wtest -g filter 0-3500 >A 38will apply a lowpass filter with 6dB corner at 3500 Hz before the 39compression phase. 40 41Then, as above, 'gnuplot plotA' will graph dB gain and dB error-level 42vs. freq for you. 43 44------------------------------------------------------------------- 45 46About ltest: 47 48-l means use 32-bit signed samples, otherwise 16-bit signed is used. 49 50The other parameters are fed into sox as the 'effect' with parameters. 51 52The rates 8000:22050 are in the script, but you can edit a perl script, 53I hope. just change the ($rate0,$rate1)=(8000,22050) line near the top. 54 55What ltest does: 56 57It uses sox to synthesize a sineusoid input file for the 58frequencies 0.01 ... 0.99 of the Nyquist frequency. This input 59has: 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. 65 66The rising/falling envelopes are shaped like rising, falling portions 67of the (1-cos(x)) function. 68 69Then the filter or rate-change effect is applied to this i0.xx.xx file 70to give an output file. 71 72The output file is examined by the 'model' or 'lmodel' program to analyse 73response level and error level. 74 75model works as follows: 76 77step 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. 80 81step 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 86 small. 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' 90 or unexplained part. 91 92That's pretty much it... the ltest perl-script glues it together and outputs 93adjusted data which the gnuplot will like. 94 95Modify the perl and gnuplot scripts to suit your needs. 96