ftp.nice.ch/pub/next/unix/audio/Srconv.N.s.tar.gz#/Srconv

Makefile
 
README
 
ioequ.asm
 
next.asm
 
rsmpl.asm
 
srconv.asm
 
srconv.c
[View srconv.c] 

README

{\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f1\fmodern Ohlfs;}
\paperw13040
\paperh9540
\margl120
\margr120
{\colortbl\red0\green0\blue0;}
\pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f0\b\i0\ul0\fs28 SRCONV 
\b0 	a Sampling Rate Converter by J. Laroche, June 1991.
\b \
\
\

\b0 To compile, type make.
\b \
\
\
srconv
\b0  is a real-time sampling rate converter implemented on the DSP.\
It can be used both to play sounds at different sampling rates, or to convert sounds from one sampling rate to another. If only one soundfile name is given, the soundfile is played at its original sampling rate (that is it is converted from its original sampling rate to 44.1 KHz and then played on the DACs). If a second soundfile name is given, the sound is converted and written into the second soundfile:\
\

\b srconv 
\b0  file1 			just plays file1\

\b srconv 
\b0  file1 file2	-S12000		converts file1 to 12KHz and writes it onto file2.\
\

\b\fc0 Srconv
\b0  uses a simple zero-filling + filtering scheme that runs in real time on the DSP, to perform conversions of the form P/Q with P and Q integers. This means arbitrary sampling rate conversions will be approximated by rational conversions. \
\

\b Srconv
\b0  can either be given P and Q, or you can precise the final sampling rate, the original one being read from the original soundfile header, and 
\b srconv
\b0  will calculate the best fraction P/Q approximating the conversion (via continued fractions.) This is done using the -P, -Q and -S flags. \
\
An important quality factor is the filter issue. The filter used in 
\b srconv
\b0  is just a FIR filter with impulse response sin(x)/x windowed by a Hamming window.\
Its length determines the quality of the resulting conversion. The longer the better. Two factors actually limit the length of the filter impulse response:\
- When playing sounds, too long a length will cause the conversion to fall off real-time.\
- When converting from one file to another, one is limited by the amount of the DSP private memory. \
\

\fs26\li1440 In the standard configuration, Only 8K words are available, which limits the filter length to about 200 lags. The value of max(P,Q) also influences the length of the filter. More precisely, one must make sure that max(P,Q) * K is less than the amount of memory available for the filter coefficients (where K is the filter's order.) \
\

\fs28\li0 In any case, 
\b srconv
\b0  tries to use a filter as long as possible considering the values of P and Q and the amount of free memory (if you have more DSP memory than standard, you should recompile 
\b srconv
\b0  after 
\pard\tx1152\tx2304\tx3456\tx4608\tx5760\tx6912\tx8064\tx9216\tx10368\tx11520\fc0 modifying
\pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0  certain parameters in the C code - see the C source.)\
The filter length can be set using the -K flag. When playing a sound, its default value is 33, to guaranty real-time in most situations. However, if 
\b srconv
\b0  creates clics and drop-outs, try to lower the filter length using the -K flag. This is likely to occur when converting from a high sampling rate to a low sampling rate.\
\
The cut-off frequency is equal to Fe/2 * (1/max(P,Q) - offset) The offset is here to prevent any aliasing, its 
\pard\tx1152\tx2304\tx3456\tx4608\tx5760\tx6912\tx8064\tx9216\tx10368\tx11520\fc0 default
\pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0  value is 0.02 and it can be set using the -o flag (not to be recommended!)\
The -v flag prints all interesting parameters, including values of P and Q, the filter order etc...\
\
\

\b\fs30 Weird Sampling rate conversions
\b0\fs28 .\
When using -P and -Q, the values of P and Q must be less than 100, and it is recommended not to use values above 30;\
When using the -S flag, it is not always possible to 
\pard\tx1152\tx2304\tx3456\tx4608\tx5760\tx6912\tx8064\tx9216\tx10368\tx11520\fc0 correctly
\pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0  approximate the desired sampling rate. 
\b Srconv
\b0  will do its best using values of P and Q below 30 and trying to match the output sampling rate within a threshold of 0.3% by default (this threshold can be adjusted using the -t flag.) 
\b Srconv
\b0  will signal it when this can't be achieved, and will also give ideal values for P and Q with respect to the current threshold. In this case, you should note these ideal values, decompose them into lower factors and perform a conversion in successive steps. For example, converting from 32000 to 44100 with a threshold of 0.001\
\

\b srconv
\b0  sound32 -S44100 -t0.001 sound441\
\
will produce  "Warning, difficult conversion: ideal factors P = 51, Q = 37", since the actual values of P = 11, Q = 8 result in a sample rate error of 0.23% > 0.001. \
Since 51 = 3*17, you can decompose the process in two steps, the first one with P=17 Q=37, the second with P=3 and Q=1. This way, a final sampling rate of 44107 can be attained instead of 44000 for a direct conversion. \
Note however that during the first step, we convert the original sound to a sampling rate of 14702Hz, therefore filtering out everything above 7351Hz in the original sound. For an upward conversion, intermediate sampling rates should always be higher than the original, to avoid loosing high frequencies. Similarly, for a downward conversion, intermediate sampling rates should be higher than the final sampling rate. Finding acceptable steps is not always easy.
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.