peak
Prev | Orchestra Opcodes and Operators | Next

## 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 files peak.orc, peak.sco, and beats.wav.

Example 263. Example of the peak opcode.

    /* peak.orc */
    ; 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 soundin "beats.wav"
      kp peak asig

      ; Print out the peak value once per second.
      printk 1, kp

      out asig
    endin
    /* peak.orc */

    /* peak.sco */
    ; 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

Example written by Kevin Conder.

Prev | Up | Next
pconvolve | Home | peakk