notnum
Prev | Orchestra Opcodes and Operators | Next

## notnum

notnum — Get a note number from a MIDI event.

## Description

Get a note number from a MIDI event.

## Syntax

    ival notnum

## Performance

Get the MIDI byte value (0 - 127) denoting the note number of the current event.

## Examples

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

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

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

    ; Instrument #1.
    instr 1
      i1 notnum

      print i1
    endin

    </CsInstruments>
    <CsScore>

    ; Play Instrument #1 for 12 seconds.
    i 1 0 12
    e

    </CsScore>
    </CsoundSynthesizer>

Here is an example of the notnum opcode used to produce audio output. It uses the file notnum_complex.csd

Example 317. Complex example of the notnum opcode.

    <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
    </CsOptions>
    <CsInstruments>

    sr      =       44100
    ksmps   =       10
    nchnls  =       2

    ; Set MIDI channel 1 to play instr 1.
            massign 1, 1

                    instr   1

    ; Returns MIDI note number - an integer in range (0-127)
    iNum    notnum

    ; Convert MIDI note number to Hz
    iHz     = (440.0*exp(log(2.0)*((iNum)-69.0)/12.0))

    ; Generate audio by indexing a table; fixed amplitude.
    aosc    oscil   10000, iHz, 1

    ; Since there is no enveloping, there will be clicks.
            outs    aosc, aosc

                    endin

    </CsInstruments>
    <CsScore>

    ; Generate a Sine-wave to be indexed at audio rate
    ;  by the oscil opcode.
    f1      0       16384   10      1

    ; Keep the score "open" for 1 hour so that MIDI
    ;  notes can allocate new note events, arbitrarily.
    f0      3600

    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

aftouch, ampmidi, cpsmidi, cpsmidib, midictrl, octmidi, octmidib, pchbend, pchmidi, pchmidib, veloc

## Credits

Author: Barry L. Vercoe - Mike Berry
MIT - Mills
May 1997

Examples written by Kevin Conder and David Akbari.

Prev | Up | Next
noteondur2 | Home | nreverb