ziwm
Prev | Orchestra Opcodes and Operators | Next

## ziwm

ziwm — Writes to a zk variable to an i-rate variable with mixing.

## Description

Writes to a zk variable to an i-rate variable with mixing.

## Syntax

    ziwm isig, indx [, imix]

## Initialization

isig -- initializes the value of the zk location.

indx -- points to the zk location location to which to write.

imix (optional, default=1) -- indicates if mixing should occur.

## Performance

ziwm is a mixing opcode, it adds the signal to the current value of the variable. If no imix is specified, mixing always occurs. imix = 0 will cause overwriting like ziw, zkw, and zaw. Any other value will cause mixing.

Caution: When using the mixing opcodes ziwm, zkwm, and zawm, care must be taken that the variables mixed to, are zeroed at the end (or start) of each k- or a-cycle. Continuing to add signals to them, can cause their values can drift to astronomical figures.

One approach would be to establish certain ranges of zk or za variables to be used for mixing, then use zkcl or zacl to clear those ranges.

## Examples

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

Example 1172. Example of the ziwm 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           -iadc    ;;;RT audio I/O
    ; For Non-realtime ouput leave only the line below:
    ; -o ziwm.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    ; Initialize the global variables.
    sr = 44100
    kr = 4410
    ksmps = 10
    nchnls = 1

    ; Initialize the ZAK space.
    ; Create 1 a-rate variable and 1 k-rate variable.
    zakinit 1, 1

    ; Instrument #1 -- a simple instrument.
    instr 1
      ; Add 20.5 to zk variable #1.
      ziwm 20.5, 1
    endin

    ; Instrument #2 -- another simple instrument.
    instr 2
      ; Add 15.25 to zk variable #1.
      ziwm 15.25, 1
    endin

    ; Instrument #3 -- prints out zk variable #1.
    instr 3
      ; Read zk variable #1 at i-rate.
      i1 zir 1

      ; Print out the value of zk variable #1.
      ; It should be 35.75 (20.5 + 15.25)
      print i1
    endin

    </CsInstruments>
    <CsScore>

    ; Play Instrument #1 for one second.
    i 1 0 1
    ; Play Instrument #2 for one second.
    i 2 0 1
    ; Play Instrument #3 for one second.
    i 3 0 1
    e

    </CsScore>
    </CsoundSynthesizer>

## See Also

zaw, zawm, ziw, zkw, zkwm

## Credits

Author: Robin Whittle
Australia
May 1997

New in version 3.45

Example written by Kevin Conder.

Prev | Up | Next
ziw | Home | zkcl