src_conv
Prev | File Conversion (HET_IMPORT, HET_EXPORT, PVLOOK, PV_EXPORT, PV_IMPORT, SDIF2AD, SRC_CONV) | Next

## src_conv

src_conv — Converts the sample rate of an audio file.

## Description

Converts the sample rate of an audio file at sample rate Rin to a sample rate of Rout. Optionally the ratio (Rin / Rout) may be linearly time-varying according to a set of (time, ratio) pairs in an auxiliary file.

## Syntax

    src_conv [flags] infile

## Initialization

Flags:

- -P num = pitch transposition ratio (srate / r) [don't specify both P and r]

- -Q num =quality factor (1, 2, 3, 4 or 5: default = 3)

- -i filnam = auxiliary breakpoints file (no breakpoint by default. i.e. No ratio change)

- -r num = output sample rate (must be specified if no P)

- -o fnam = sound output filename (default: test.wav)

- -A = create an AIFF format output soundfile

- -J = create an IRCAM format output soundfile

- -W = create a WAV format output soundfile (default after Csound version 6.15)

- -h = no header on output soundfile

- -c = 8-bit signed_char sound samples

- -a = alaw sound samples

- -8 = 8-bit unsigned_char sound samples

- -u = ulaw sound samples

- -s = short_int (16 bit) sound samples (default)

- -3 = 24-bit sound samples

- -l = long_int sound samples

- -f = float sound samples

- -r N = orchestra srate override

- -K = Do not generate PEAK chunks

- -R = continually rewrite header while writing soundfile (WAV/AIFF)

- -H# = print a heartbeat style 1, 2 or 3 at each soundfile write

- -N = notify (ring the bell) when done

This program performs arbitrary sample-rate conversion with high fidelity using the libsamplerate library.

The five levels of accuracy are:

- 1: A linear converter. The quality is poor, but the conversion speed is blindingly fast.
- 2: A Zero Order Hold converter (interpolated value is equal to the last value). The quality is poor but the conversion speed is blindingly fast.
- 3: This is the fastest bandlimited interpolator and has an SNR of 97dB and a bandwidth of 80%.
- 4: This is another bandlimited interpolator much like the previous one. It has an SNR of 97dB and a bandwidth of 90%. The speed of the conversion is much faster than the next one. Blindingly fast.
- 5: This is a bandlimited interpolator derived from the mathematical sinc function and this is the highest quality sinc based converter, providing a worst case Signal-to-Noise Ratio (SNR) of 97dB at a bandwidth of 97%.

## Examples

Here is an example of src_conv. It uses the file src_conv.csd.

Example 1337. Example of src_conv.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac
    ; For Non-realtime ouput leave only the line below:
    ; -o src_conv.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 48000  ; sample rate of beats.wav = 44100
    ksmps = 32  ; and will be resampled to 48000
    nchnls = 2
    0dbfs  = 1

    ; by Menno Knevel 2021

    ; resample in the highest qualty, name the new sample 'beats48.wav'
    gires system_i 1,{{ src_conv -r48000 -Q5 beats.wav -o beats48.wav }}

    instr 1
    ires system_i 1,{{ sndinfo -i beats48.wav }} ; check sample rate
    aout    diskin2 "beats48.wav", 1
    outs    aout, aout
    endin

    </CsInstruments>
    <CsScore>
    i1 0 2

    e
    </CsScore>
    </CsoundSynthesizer>

## Credits

Author: John ffitch based on code by Erik de Castro Lopo

May 2015

Prev | Up | Next
sdif2ad | Home | Other Csound Utilities (CS, CSB64ENC, ENVEXT, EXTRACTOR, MAKECSD, MIXER, SCALE)