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

kr peak asig

kr peak ksig

Performance

kr -- Output equal to the highest absolute value received so far. This is effectively an input to the opcode as well, since it reads kr 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 files peak.orc, peak.sco, and beats.wav.

Example 1. Example of the peak opcode.

/* peak.orc */
/* Written by Kevin Conder */
; Initialize the global variables.
sr = 44100
kr = 44100
ksmps = 1
nchnls = 1

; Instrument #1 - play an audio file.
instr 1
  ; Capture the highest amplitude in the "beats.wav" file.
  asig diskin "beats.wav", 1
  kp peak asig

  ; Print out the peak value once per second.
  printk 1, kp
  
  out asig
endin
/* peak.orc */
        
/* peak.sco */
/* Written by Kevin Conder */
; Play Instrument #1, the audio file, for three seconds.
i 1 0 3
e
/* peak.sco */
        
Its output should include lines like this:
 i   1 time     0.00002:  4835.00000
 i   1 time     1.00002: 29312.00000
 i   1 time     2.00002: 32767.00000
      

Credits

Author: Robin Whittle
Australia
May 1997