srconv utility performs high-quality sample rate conversion on audio files using Kaiser-windowed sinc interpolation. It can perform fixed or time-varying rate conversion with adjustable quality settings.
Syntax
Required options
| Option | Description |
|---|---|
-r <rate> | Output sample rate in Hz (required) |
-R <rate> | Input sample rate in Hz (required if not in header) |
Rate control options
One of these must be specified:| Option | Description |
|---|---|
-P <ratio> | Pitch transposition ratio (input_rate / output_rate) |
-r <rate> | Output sample rate |
Quality and processing options
| Option | Description |
|---|---|
-Q <factor> | Quality factor from 1 (low) to 8 (high), default: 2 |
-i <filename> | Time-varying ratio control breakpoint file |
Output format options
| Option | Description |
|---|---|
-o <filename> | Output sound filename |
-A | Create AIFF format output |
-W | Create WAV format output |
-J | Create IRCAM format output |
-h | No header (raw output) |
Sample format options
| Option | Description |
|---|---|
-c | 8-bit signed char |
-8 | 8-bit unsigned char |
-a | A-law encoded |
-u | μ-law encoded |
-s | 16-bit short int (default) |
-l | 32-bit long int |
-f | 32-bit float |
Additional options
| Option | Description |
|---|---|
-K | Do not generate PEAK chunks |
-R | Continuously rewrite header during processing |
-H <n> | Heartbeat display: 1=spinner, 2=dots, 3=numeric |
-N | Ring bell when complete |
-- <file> | Log output to file |
Examples
Basic sample rate conversion
Convert 48kHz to 44.1kHz:Downsample with quality control
Upsample to higher rate
Conversion with explicit input rate
Using pitch ratio
High-quality conversion
Time-varying conversion
ratio.brk containing:
Quality factor
The-Q parameter controls interpolation quality:
| Q value | Filter length | CPU usage | Quality |
|---|---|---|---|
| 1 | Shortest | Lowest | Low (audible artifacts) |
| 2 | Short | Low | Standard (default) |
| 3-4 | Medium | Medium | Good (transparent) |
| 5-6 | Long | High | Very good |
| 7-8 | Longest | Highest | Excellent (archival) |
Choosing quality
- Q=1-2: Real-time processing, low CPU
- Q=3-4: General purpose, good quality/speed balance
- Q=5-6: Professional audio production
- Q=7-8: Mastering, archival conversion
Sample rate combinations
Common conversions
| From | To | Ratio | Use case |
|---|---|---|---|
| 48000 | 44100 | 0.91875 | Video to CD |
| 44100 | 48000 | 1.08844 | CD to video |
| 44100 | 22050 | 0.5 | Downsampling by 2 |
| 22050 | 44100 | 2.0 | Upsampling by 2 |
| 48000 | 96000 | 2.0 | Standard to high-res |
| 96000 | 48000 | 0.5 | High-res to standard |
Upsampling vs downsampling
Upsampling (increasing sample rate):- Adds high-frequency space (initially empty)
- Minimal quality loss
- Larger output files
- Removes high frequencies
- Requires good anti-aliasing filter (higher Q)
- Smaller output files
Time-varying conversion
The-i breakpoint file format:
- Times in seconds
- Ratios specify input_rate/output_rate at each time
- Linear interpolation between breakpoints
- Variable-speed playback effects
- Pitch glides
- Time stretching with pitch change
Technical details
Interpolation method
srconv uses Kaiser-windowed sinc interpolation:
- Sinc function provides ideal low-pass filter
- Kaiser window reduces ripple and ringing
- Window length determined by quality factor
- Fractional delay achieved by sinc interpolation
Anti-aliasing
For downsampling:- Low-pass filter at new Nyquist frequency
- Filter prevents aliasing artifacts
- Higher Q provides sharper cutoff
- Transition band width decreases with Q
Passband and stopband
- Passband: Frequencies preserved (less than 0.45 × output_rate)
- Transition: Roll-off region (depends on Q)
- Stopband: Frequencies rejected (greater than 0.5 × output_rate)
Performance considerations
Processing time
Factors affecting speed:- Quality factor (Q): Higher Q = slower
- File duration: Linear scaling
- Sample rate change: Upsampling slower than downsampling
Memory usage
Typical: 4096-8192 samples per buffer Memory = buffer_size × channels × 4 bytes × 2 (input + output)Common issues
Aliasing artifacts
If downsampled audio has harsh, inharmonic artifacts:- Increase quality factor (
-Q 6or higher) - Ensure input sample rate is correct
Slow processing
If conversion is too slow:- Reduce quality factor (try
-Q 3) - Process in smaller segments
- Use batch processing overnight
Incorrect pitch
If output pitch is wrong:- Verify input sample rate (
-Rvalue) - Check output rate (
-rvalue) - Ensure ratio calculation is correct