midi-program-change

[Class]
  `midi-program-change`

A MIDI control change or mode change event. See General MIDI Level 1 Sound Set for a table listing General MIDI (GM) program change messages.

`midi-program-change` supports the following slot initializations:

`:time` number
  The start time of the object.
`:channel` integer
  A MIDI channel number, defaults to 0.
`:program` integer
  A MIDI program change value from 0-127. Note that most MIDI documentation lists program changes starting with 1. You must subtract 1 from these values. For example, Grand Piano is 0 (not 1).

#### Examples:

Example 1. Creating a "Multi" setup.

    (define multi (time multi)
      (new seq :time time
         :subobjects
         (loop for x in multi
               collect
               (new midi-program-change :time 0
                   :channel (first x) :program (second x)))))

    (define (squeek reps)
      ;; assign random notes to instrument channels
      (process repeat reps
               for key = (between 40 80)
               for dur = (pick .5 1 1.5 2)
               for chan = (if (scale<= key 'c4)
                              (pick 0 1)
                              (pick 2 3))
               output (new midi :time (now)
                           :duration .2
                           :keynum key :channel chan)
               wait (pick 0 .25 .5 .75 1)))

    ;;; chan 0=bass, chan 1=trombone, 2=violin, 3=flute
    (define myins '((0 32) (1 57) (2 40) (3 73)))

    (events (list (multi 0 myins) (squeek 30))
            "test.mid")
    ⇒ "test.mid"

#### See also:

- MIDI event classes [Topic]