\ midi_plus
\
\ additional midi words and utilities.
\
\ Code: Han-earl Park
\ Copyright 2001 Buster & Friends C-ALTO Labs
\ (Valencia, July 1999 -
\ (Southampton, September 2000 -
\
\ MOD: HeP 07/30/99 Started project.
\ MOD: HeP 09/02/99 Fix midi.soft.pedal to accept flag.
\ MOD: HeP 10/04/99 Add (midi.fine.tune) (midi.coarse.tune) and midi.tune.
\ MOD: HeP 01/26/00 Add words for setting midi device id numbers.
\ MOD: HeP 02/26/00 Add midi.pan and midi.fx1 thru midi.fx5.
\ MOD: HeP 09/23/00 Define controller numbers as constants.
\ MOD: HeP 01/23/01 Add or sutract one to device id# before storing value.
\ MOD: HeP 01/27/01 Add MIDI.SUSTAIN.PEDAL.
\ MOD: HeP 02/03/01 Believe it or not, finally add MIDI.MODULATION.
\ MOD: HeP 03/13/01 Fix: midi expression controller number is hex 0b not 11.
anew task-midi_plus
\ device id#
00 value midi_device_id
: MIDI.DEVICE.ID! ( n -- , set device id number )
1- -> midi_device_id
;
: MIDI.DEVICE.ID@ ( -- n )
midi_device_id 1+
;
\ pitch bend utility
200 value midi_bend_range \ bend range in cents
: MIDI.BEND.RANGE! ( n -- , set bend range to +/- n semitones )
100 * -> midi_bend_range
;
: MIDI.BEND.RANGE@ ( -- n )
midi_bend_range 100 /
;
: MIDI.BEND->CENTS ( pBend -- cent )
midi_bend_range * $ 2000 /
;
: MIDI.CENTS->BEND ( cents -- pBend )
$ 2000 * midi_bend_range /
;
: MIDI.PITCH.OFFSET ( cents -- , send pitch bend message )
midi.cents->bend midi.pitch.bend
;
\ standard midi controllers
$ 01 constant midi_modulation
$ 07 constant midi_volume
$ 0b constant midi_expression
$ 02 constant midi_breath
$ 0a constant midi_pan
: MIDI.MODULATION ( n -- , general purpose "modulation" control )
midi_modulation swap midi.control
;
: MIDI.VOLUME ( n -- , midi channel volume )
midi_volume swap midi.control
;
: MIDI.EXPRESSION ( n -- , synthesizer "voice" volume )
midi_expression swap midi.control
;
: MIDI.BREATH ( n -- , breath controller )
midi_breath swap midi.control
;
: MIDI.PAN ( n -- , stereo pan control )
midi_pan swap midi.control
;
$ 41 constant midi_portamento
$ 05 constant midi_portamento_time
: MIDI.PORTAMENTO.ON ( -- )
midi_portamento $ 7f midi.control
;
: MIDI.PORTAMENTO.OFF ( -- )
midi_portamento $ 00 midi.control
;
: MIDI.PORTAMENTO ( flag -- )
IF midi.portamento.on ELSE midi.portamento.off
THEN
;
: MIDI.PORTAMENTO.TIME ( n -- , set portamento time )
midi_portamento_time swap midi.control
;
$ 40 constant midi_sustain_pedal
$ 43 constant midi_soft_pedal
: MIDI.SUSTAIN.PEDAL ( flag -- , susatain pedal switch )
IF midi_sustain_pedal $ 7f ELSE midi_sustain_pedal $ 00
THEN
midi.control
;
: MIDI.SOFT.PEDAL ( flag -- , damper pedal switch )
IF midi_soft_pedal $ 7f ELSE midi_soft_pedal $ 00
THEN
midi.control
;
\ semi-standard controllers
: MIDI.BEND.RANGE ( n -- , set pitch bend range to -n to +n semitones )
$ 64 $ 00 midi.control
$ 65 $ 00 midi.control
$ 06 swap midi.control
;
: (MIDI.FINE.TUNE) ( n -- , set fine tuning of device )
$ 64 $ 01 midi.control
$ 65 $ 00 midi.control
$ 06 swap midi.control
;
: (MIDI.COARSE.TUNE) ( n -- , set pitch transposition of device )
$ 64 $ 02 midi.control
$ 65 $ 00 midi.control
$ 06 swap midi.control
;
: MIDI.FINE.TUNE ( n -- , fine tune device by n cents )
$ 40 + (midi.fine.tune)
;
: MIDI.COARSE.TUNE ( n -- , transpose device by n semitones )
$ 40 + (midi.coarse.tune)
;
: MIDI.TUNE ( n -- , retune device by n cents )
100 /mod
midi.coarse.tune
midi.fine.tune
;
$ 47 constant midi_harmonic_content
$ 4a constant midi_brightness
: MIDI.HARMONIC.CONTENT ( n -- )
midi_harmonic_content swap midi.control
;
: MIDI.BRIGHTNESS ( n -- )
midi_brightness swap midi.control
;
$ 49 constant midi_attack_time
$ 48 constant midi_release_time
: MIDI.ATTACK.TIME ( n -- , amplitude envelope attack time )
midi_attack_time swap midi.control
;
: MIDI.RELEASE.TIME ( n -- , amplitude envelope release time )
midi_release_time swap midi.control
;
$ 5b constant midi_fx1
$ 5c constant midi_fx2
$ 5d constant midi_fx3
$ 5e constant midi_fx4
$ 5f constant midi_fx5
: MIDI.FX1 ( n -- , set audio effects send level )
midi_fx1 swap midi.control
;
: MIDI.FX2 ( n -- )
midi_fx2 swap midi.control
;
: MIDI.FX3 ( n -- )
midi_fx3 swap midi.control
;
: MIDI.FX4 ( n -- )
midi_fx4 swap midi.control
;
: MIDI.FX5 ( n -- )
midi_fx5 swap midi.control
;
: MIDI.REV.SEND ( n -- , set reverb fx send level )
midi.fx1
;
: MIDI.CHO.SEND ( n -- , set chorus fx send level )
midi.fx3
;
\ switch channel modes
: MIDI.MONO.MODE ( -- )
$ 7e $ 00 midi.control
;
: MIDI.POLY.MODE ( -- )
$ 7f $ 00 midi.control
;
: MIDI.OMNI.ON ( -- )
$ 7d $ 00 midi.control
;
: MIDI.OMNI.OFF ( -- )
$ 7c $ 00 midi.control
;
\ reset channel
: MIDI.RESET.CTRL ( -- , reset controllers to default state )
$ 79 $ 00 midi.control
;