push

push — Pushes a value into the global stack. Deprecated.

Description

Plugin opcode in stackops.

Pushes a value into the global stack.

Syntax

push  xval1, [xval2, ... , xval31]
push  ival1, [ival2, ... , ival31]

Initialization

ival1 ... ival31 - values to be pushed into the stack.

Performance

xval1 ... xval31 - values to be pushed into the stack.

The given values are pushed into the global stack as a bundle. The global stack works in LIFO order: after multiple push calls, pop should be used in reverse order.

Each push or pop operation can work on a "bundle" of multiple variables. When using pop, the number, type, and order of items must match those used by the corresponding push. That is, after a 'push Sfoo, ibar', you must call something like 'Sbar, ifoo pop', and not e.g. two separate 'pop' statements.

push and pop opcodes can take variables of any type (i-, k-, a- and strings). Use of any combination of i, k, a, and S types is allowed. Variables of type 'a' and 'k' are passed at performance time only, while 'i' and 'S' are passed at init time only.

push/pop for a, k, i, and S types copy data by value. By contrast, push_f only pushes a "reference" to the f-signal, and then the corresponding pop_f will copy directly from the original variable to its output signal. For this reason, changing the source f-signal of push_f before pop_f is called is not recommended, and if the instrument instance owning the variable that was passed by push_f is deactivated before pop_f is called, undefined behavior may occur.

Any stack errors (trying to push when there is no more space, or pop from an empty stack, inconsistent number or type of arguments, etc.) are fatal and terminate performance.

Examples

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

Example 1355. Example of the push 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 push.wav -W ;;; for file output any platform
</CsOptions> 
<CsInstruments> 

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

stack 100000 

instr 1 

a1	oscils 0.7, 220, 0 
k1	line 0, p3, 1 
        push "blah", 123.45, a1, k1 
        push rnd(k1) 

k_rnd	pop 
S01, i01, a01, k01 pop 
        printf_i "S01 = '%s', i01 = %g\n", 1, S01, i01 
ktrig	metro 5.0 
        printf "k01 = %.3f, k_rnd = %.3f\n", ktrig, k01, k_rnd 
        outs a01, a01 

endin 
</CsInstruments> 
<CsScore> 

i 1 0 5 
e 
</CsScore> 
</CsoundSynthesizer> 


See also

Stacks

Using this opcode is somewhat hackish, as you can read here: http://csound.1045644.n5.nabble.com/passing-a-string-to-a-UDO-td1099284.html

Credits

By: Istvan Varga.

2006

Deprecated as of version 6.04.