downsamp

downsamp — Modify a signal by down-sampling.

Description

Modify a signal by down-sampling.

Syntax

kres downsamp asig [, iwlen]

Initialization

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.

Performance

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.

Examples

Here is an example of the downsamp opcode. It uses the file downsamp.csd.

Example 246. 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
-odac     ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o downsamp.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1

instr	1

ifrq	= cpspch(p4)
ain	diskin2 "drumsMlp.wav", 1
aenv	follow	ain, .001	;take the amplitude every 1/1000th of a second
alow	tone	aenv, 25	;lowpass-filter (25 Hz) for a clean signal
kenv	downsamp alow
asig    pluck   kenv, ifrq, 15, 0, 1
	outs	asig, asig
	endin

</CsInstruments>
<CsScore>

i 1 0 2	 9
i 1 + .	 7
i 1 + .	 5

e
</CsScore>
</CsoundSynthesizer>


See also

Sample Level Operators