peak

peak — Maintains the output equal to the highest absolute value received.

Description

These opcodes maintain the output k-rate variable as the peak absolute level so far received.

Syntax

kres peak asig
kres peak ksig

Performance

kres -- Output equal to the highest absolute value received so far. This is effectively an input to the opcode as well, since it reads kres in order to decide whether to write something higher into it.

ksig -- k-rate input signal.

asig -- a-rate input signal.

Examples

Here is an example of the peak opcode. It uses the file peak.csd, and drumsMlp.wav.

Example 761. Example of the peak 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
-odac      ;;;RT audio out
; For Non-realtime ouput leave only the line below:
; -o peak.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

instr 1 ; Capture the highest amplitude in the "drumsMlp.wav" file.

asig soundin "drumsMlp.wav"
kp peak asig
printk .5, kp    ; Print out the peak value once per second.
outs asig, asig
endin

</CsInstruments>
<CsScore>
i 1 0 3
e
</CsScore>
</CsoundSynthesizer>


Its output should include lines like this:

 i   1 time     0.00000:     0.00118
 i   1 time     0.50068:     0.71418
 i   1 time     1.00136:     0.80155
 i   1 time     1.50204:     0.89209
 i   1 time     2.00272:     0.89209
 i   1 time     2.50340:     0.89209
      

Credits

Author: Robin Whittle
Australia
May 1997

Example written by Kevin Conder.