pindex
Prev | Orchestra Opcodes and Operators | Next

## pindex

pindex — Returns the value of a specified pfield.

## Description

pindex returns the value of a specified pfield.

## Syntax

    ivalue pindex ipfieldIndex

## Initialization

ipfieldIndex - pfield number to query.

ivalue - value of the pfield.

## Examples

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

Example 362. Example of the pindex 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   No messages  MIDI in
    -odac           -iadc    ; -d         -M0  ;;;RT audio I/O with MIDI in
    ; For Non-realtime ouput leave only the line below:
    ;-o pindex.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>
    ;Example by Anthony Kozar Dec 2006

    instr 1
        inum    pcount
        index   init 1
        loop1:
            ivalue pindex index
            printf_i "p%d = %f\n", 1, index, ivalue
            index   = index + 1
        if  (index <= inum) igoto loop1
        print inum
    endin

    </CsInstruments>
    <CsScore>
    i1  0 3 40 50         ; has 5 pfields
    i1  1 2 80            ; has 5 due to carry
    i1  2 1 40 50 60 70   ; has 7
    e
    </CsScore>
    </CsoundSynthesizer>

The example will produce the following output:

    new alloc for instr 1:
    WARNING: instr 1 uses 3 p-fields but is given 5
    p1 = 1.000000
    p2 = 0.000000
    p3 = 3.000000
    p4 = 40.000000
    p5 = 50.000000
    instr 1:  inum = 5.000
    B  0.000 ..  1.000 T  1.000 TT  1.000 M:      0.0
    new alloc for instr 1:
    WARNING: instr 1 uses 3 p-fields but is given 5
    p1 = 1.000000
    p2 = 1.000000
    p3 = 2.000000
    p4 = 80.000000
    p5 = 50.000000
    instr 1:  inum = 5.000
    B  1.000 ..  2.000 T  2.000 TT  2.000 M:      0.0
    new alloc for instr 1:
    WARNING: instr 1 uses 3 p-fields but is given 7
    p1 = 1.000000
    p2 = 2.000000
    p3 = 1.000000
    p4 = 40.000000
    p5 = 50.000000
    p6 = 60.000000
    p7 = 70.000000
    instr 1:  inum = 7.000

The warnings can be ignored, because the pfields are used indirectly through pindex instead of explicitly through p4, p5, etc.

## See Also

pcount

## Credits

Example by: Anthony Kozar

Dec. 2006

Prev | Up | Next
phasorbnk | Home | pinkish