This short manual show how to use the smarc program.
First, get help with the -h option:
> smarc -h smarc resamples audio files using multi stage polyphase filters Usage: smarc [-hv] [--verbose] -r int --nbits=int [-c s|d|1|2|..] / [-b 0..1] [--rp=0.1] [--rs=100] [--tol=0.000001] / [--ratios=L1/M1 L2/M2 ...] audiofile audiofile -h, --help print this help and exit -v, --version print version information and exit --verbose more logs -r, --rate=int samplerate of output file --nbits=int force output sample format to 16|24|32 bits. If not defined, use the input format. -c, --channels=s|d|1|2|.. used when input file has more than 1 channel 's' resample each channels separately (default) 'd' downmix using mean of channels '1' keep only first channel '2' keep only second channel '<N>' keep only Nth channel -b, --bandwidth=0..1 define the bandpass filter bandwidth, in relation with maximum possible bandwidth (default=0.95) --rp=0.1 ripple factor of pass band filter, in dB --rs=140 ripple factor of stop band filter, in dB --tol=0.000001 converter samplerate tolerance (default=0.000001) --ratios=L1/M1 L2/M2 ... multistage ratios definitions. If not given, smarc will try to find appropriate ratios --fast search for fastest conversion stages.
The most straightforward way to resample an audio file is:
> smarc -r <targetrate> <inputfile> <outputfile>
This will produced an outputfile similar to inputfile (same number of channels, same sample format) with a samplerate equals to ‘’targetrate’‘.
The --nbits option can control the output sample format (16|24|32 bits).
The -c option can be used when input file has more than 1 channel. See help for details
Several option affects the conversion process and let the caller emphasize speed or quality. The default options leads to a safe and quite fast conversion with very good quality. But the expert user may tune some parameters to obtain higher quality or faster processing.
The sample rate conversion process requires a low-pass filter to remove frequency aliasing. The output quality is highly tied with the low-pass filter quality. Smarc builds this low-pass filter on demand (using the Remez algorithm), depending on 3 parameters:
Smarc is a ‘’‘multi-stage’‘’ sample rate converter. For example, consider the 48000Hz to 44100Hz conversion:
A one-stage converter have to perform a conversion, but depending on parameters the low-pass filter for this stage will be very large or impossible to synthesize.In order to reduce this complexity, smarc automatically cuts the conversion into multiple stages. For example :
The default behavior of smarc is to use predefined stage decomposition for standard conversions, and a basic stategy for non-standard conversions (build ratios with small primes and order them to build a coherent sequence: interpolations stages before decimation ones).
To see which decomposition stages are used, use the --verbose option:
> smarc -r 44100 input48k.wav output.wav --verbose multi-stage polyphase resample from 48000Hz to 44100Hz passband to 20947.50Hz, passband ripple factor 0.10dB stopband from 22050.00Hz, stopband ripple factor 140.00dB successive resample stages are : 7 / 5 : filter length = 391, delay = 39 7 / 4 : filter length = 113, delay = 14 1 / 2 : filter length = 45, delay = 11 3 / 4 : filter length = 913, delay = 114 resample mono audio file
Some options can alterate the stage decomposition:
The tolerance option allow smarc to convert to a sample rate which is close to the desired one. This is usefull for complex conversions, i.e. conversion that cannot be expressed by a ratio of small prime numbers.
If a non-exact conversion is acceptable, this may be a solution in complex situations.