downsamp — Modify a signal by down-sampling.
iwlen (optional) -- window length in samples over which the audio signal is averaged to determine a downsampled value. Maximum length is ksmps; 0 and 1 imply no window averaging. The default value is 0.
downsamp converts an audio signal to a control signal by downsampling. It produces one kval for each audio control period. The optional window invokes a simple averaging process to suppress foldover.
Here is an example of the downsamp opcode. It uses the file downsamp.csd.
Example 121. Example of the downsamp opcode.
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 ; Audio out Audio in No messages -odac -iadc -d ;;;RT audio I/O ; For Non-realtime ouput leave only the line below: ; -o downsamp.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> ; Initialize the global variables. sr = 44100 kr = 4410 ksmps = 10 nchnls = 1 ; Instrument #1. instr 1 ; Create a noise signal at a-rate. anoise noise 20000, 0.2 ; Downsample the noise signal to k-rate. knoise downsamp anoise ; Use the noise signal at k-rate. a1 oscil 30000, knoise, 1 out anoise endin </CsInstruments> <CsScore> ; Table #1, a sine wave. f 1 0 16384 10 1 ; Play Instrument #1 for one second. i 1 0 1 e </CsScore> </CsoundSynthesizer>