pcount — Returns the number of pfields belonging to a note event.
icount - stores the number of pfields for the current note event.
Note | |
---|---|
Note that the reported number of pfields is not necessarily what's explicitly written in the score, but the pfields available to the instrument through mechanisms like pfield carry. |
Here is an example of the pcount opcode. It uses the file pcount.csd.
Example 311. Example of the pcount 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 pcount.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> ;Example by Anthony Kozar Dec 2006 instr 1 inum pcount print inum endin </CsInstruments> <CsScore> i1 0 3 4 5 ; has 5 pfields i1 1 3 ; has 5 due to carry i1 2 3 4 5 6 7 ; has 7 e </CsScore> </CsoundSynthesizer>
The example will produce the following output:
SECTION 1: new alloc for instr 1: WARNING: instr 1 uses 3 p-fields but is given 5 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 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 instr 1: inum = 7.000
The warnings occur because pfields are not used explicitly by the instrument.