\ io
\
\ io_matrix
\ stimulus-response control matrix component of io.
\
\
\ io_input ====> io_matrix ===> io_hp io_output io_top
\ ^^^^^^^^ ^^^^^^^^^ ^^^^^
\
\ this is the 'dumbest' and (as a result?) the most subjective part of io.
\ What you consider to be 'good' or 'bad' behavior of the system can be
\ specified here. But go gentle on it, you might hurt io's feelings ;-)
\
\
\ see the file io_top for more information.
\
\
\ constructor: Han-earl Park
\ copyright 2008 buster & friends' C-ALTO Labs
\
\ www.busterandfriends.com/io
\
\ (Edinburgh, November 1996 -
\ (London, August 1997 -
\ (Den Haag, October 1997 -
\ (Valencia, March 1999 -
\ (Southampton, May 2000 -
\ (Cork, April 2006 -
\
\ (Cork, October 2008 -
\
\ REV: 0.0.1 alpha (Southampton, October 2000)
\ REV: 0.0.1 beta (Southampton, November 2000)
\ REV: 0.0.1 alpha++ (Southampton, July 2004)
\ REV: 0.0.1 beta++ (Cork, May 2010)
\
\
\ MOD: HeP 03/05/99 Started project afresh!
\ This version keeps most of the "intelligence" in the
\ objects, while the piece specific elements are kept to a
\ minimum. It is also a test for the "laurie" project.
\ MOD: HeP 01/21/00 Start initial version sans the matrix component.
\ MOD: HeP 02/21/00 Add the global control word IO.STANDBY and corresponding
\ words to each component.
\ MOD: HeP 05/31/00 Implement scrambling and modification of the matrix.
\ MOD: HeP 06/08/00 Add cfa.elmnts class for use as the matrix.
\ MOD: HeP 10/18/00 Current version uses a single static.particle.
\ MOD: HeP 10/19/00 Use EXEC.STACK? instead of STACK.MARK...STACK.CHECK in the
\ cfa.elmnts' EXECUTE: method. STACK.CHECK is used
\ internally by hmsl, and this used to confuse the system.
\ REV: 0.0.1 alpha __________________________________________________________
\ MOD: HeP 10/26/00 Add PUT.#ARGUMENTS: and }STUFF: methods to ob.cfa.elmnts
\ (rewrite NEW: etc) which allows for more dynamic (lazy)
\ specification of the matrix objects.
\ MOD: HeP 11/02/00 Update doc and comments.
\ MOD: HeP 11/09/00 Minor additions to the matrix: Experimental.
\ MOD: HeP 11/18/00 Add a null function (i.e. 0 0 'c 2DROP) to the on and off
\ matrix objects.
\ REV: 0.0.1 beta __________________________________________________________
\ MOD: HeP 07-03-04 Each component's .INIT function no longer calls the
\ corresponding .DEFAULT function. Instead these are all
\ called at the end of IO.INIT. See file io_top.
\ REV: 0.0.1 a ++ __________________________________________________________
\ MOD: HeP 11-08-08 Call words to alter the conversion of hp_ coordinates to
\ midi. See the file modules:io_interp_table for more info.
\ MOD: HeP 03-21-09 Add meta-alert-matrix.
\ REV: 0.0.1 b ++ __________________________________________________________
\ Version for performance at Blackrock Castle Observatory,
\ Cork, Ireland, May 25, 2010.
\
\
\ ToDo: Since parsers and banalyzers sent ELEMENT.ON: and ELEMENT.OFF:
\ messages, why not call the matrix via these?
\ ToDo: Couple static.particles with parsers? Use current-parser?
anew task-io_matrix
\ cfa elmnts class
method PUT.#ARGUMENTS:
:class OB.CFA.ELMNTS iv-cfa-#arguments
;m
:m PUT.#ARGUMENTS: ( #arg -- , self number of arguments )
iv=> iv-cfa-#arguments
;m
:m ?NEW: ( #elm -- addr | 0 )
iv-cfa-#arguments 1+ ?new: super
;m
:m NEW: ( #elm -- )
?new: self
;m
:m }STUFF: ( stuff... -- )
stuff.depth
iv-cfa-#arguments 1+ / \ number of elements needed
\
dup many: self >
IF dup new: self
THEN
dup set.many: self
1+ 1
DO many: self i - put: self
LOOP
;m
: CFA.ELM.SWAP { elm1 elm2 -- }
elm1 get: self
elm2 get: self
\
elm1 put: self
elm2 put: self
;
:m SCRAMBLE: ( n -- , scramble n times )
dup 0<
IF drop
many: self
THEN
0
DO many: self choose
many: self choose CFA.ELM.SWAP
LOOP
;m
\ the name of the EXECUTE: method is generic as to facillitate easy calling.
:m EXECUTE: ( elm# -- , arguments with last dim as cfa )
many: self mod
\
get: self
dimension: self 1- negate exec.stack?
;m
:m PRINT.ELEMENT: ( elm# -- )
dimension: self 1- 0
DO dup i ed.at: self 7 .r space
LOOP
dimension: self 1- ed.at: self cfa.
;m
;class
02 constant matrix_#arguments
ob.cfa.elmnts meta-alert-matrix
ob.cfa.elmnts alert-matrix
ob.cfa.elmnts on-matrix
ob.cfa.elmnts off-matrix
\ shuffle matrix
: SCRAMBLE.MATRIX ( -- )
-1 scramble: meta-alert-matrix
\
-1 scramble: alert-matrix
-1 scramble: on-matrix
-1 scramble: off-matrix
;
: MODIFY.MATRIX ( -- , a "soft" scramble )
-1 scramble: meta-alert-matrix
\
many: alert-matrix choose choose scramble: alert-matrix
many: on-matrix choose choose scramble: on-matrix
many: off-matrix choose choose scramble: off-matrix
;
\ meta-alert-matrix functions
defer MODIFY.TIME.ADVANCE \ defined in io_glob
defer MODIFY.INTERP \ defined in io_interp
defer MODIFY.PATCH \ defined in io_output
'c noop is MODIFY.TIME.ADVANCE
'c noop is MODIFY.INTERP
'c noop is MODIFY.PATCH
: MAYBE.MODIFY.MATRIX ( -- )
2 choose
IF modify.matrix
THEN
;
: MODIFY.PATCH+ ( -- , change patch and maybe modify matrix )
modify.patch
maybe.modify.matrix
;
: MODIFY.INTERP+ ( -- , change patch and maybe modify matrix )
modify.interp
maybe.modify.matrix
;
: MODIFY.AHEAD.TIME+ ( -- , change patch and maybe modify matrix )
modify.time.advance
maybe.modify.matrix
;
\ matrix functions
: MODIFY.STATIC.MASS ( elm# sel# -- )
modify.mass: static-particle-holder
;
: MODIFY.STATIC.POS ( elm# sel# -- )
modify.position: static-particle-holder
;
: MODIFY.MASS ( elm# sel# -- )
modify.mass: particle-holder
;
: MODIFY.VEL ( elm# sel# -- )
modify.velocity: particle-holder
;
: MODIFY.POS ( elm# sel# -- )
modify.position: particle-holder
;
: META.ALERT.MATRIX.INIT ( -- )
sub" meta.alert.matrix.init"
\
0 put.#arguments: meta-alert-matrix
\
STUFF{
'c modify.patch+
'c modify.interp+
'c modify.interp+
'c modify.ahead.time+
'c modify.matrix
}STUFF: meta-alert-matrix
;
: ALERT.MATRIX.INIT ( -- )
sub" alert.matrix.init"
\
matrix_#arguments put.#arguments: alert-matrix
\
STUFF{
\
\ 0 hp_norm 'c modify.static.mass
\ 0 hp_incr 'c modify.static.mass
\ 0 hp_decr 'c modify.static.mass
\ 0 hp_rand 'c modify.static.mass
\ 0 hp_flip 'c modify.static.mass
\
0 hp_norm 'c modify.static.pos
\ *** 0 hp_incr 'c modify.static.pos \ ***
\ *** 0 hp_decr 'c modify.static.pos \ ***
\ 0 hp_rand 'c modify.static.pos
\ 0 hp_flip 'c modify.static.pos
\
\ hp_every_elm hp_norm 'c modify.mass
\ hp_every_elm hp_incr 'c modify.mass
\ hp_every_elm hp_decr 'c modify.mass
\ hp_every_elm hp_rand 'c modify.mass
\ hp_every_elm hp_flip 'c modify.mass
\
hp_every_elm hp_norm 'c modify.vel
\ hp_every_elm hp_incr 'c modify.vel
hp_every_elm hp_decr 'c modify.vel
hp_every_elm hp_rand 'c modify.vel
hp_every_elm hp_flip 'c modify.vel
\
\ hp_every_elm hp_norm 'c modify.pos
\ hp_every_elm hp_incr 'c modify.pos
\ hp_every_elm hp_decr 'c modify.pos
\ hp_every_elm hp_rand 'c modify.pos
\ hp_every_elm hp_flip 'c modify.pos
\
}STUFF: alert-matrix
;
: ON.MATRIX.INIT ( -- )
sub" on.matrix.init"
\
matrix_#arguments put.#arguments: on-matrix
\
STUFF{
\ hp_rand_elm hp_norm 'c modify.mass
\ hp_rand_elm hp_incr 'c modify.mass
\ hp_rand_elm hp_decr 'c modify.mass
\ hp_rand_elm hp_rand 'c modify.mass
\ hp_rand_elm hp_flip 'c modify.mass
\
\ hp_rand_elm hp_norm 'c modify.vel
\ hp_rand_elm hp_incr 'c modify.vel
hp_rand_elm hp_decr 'c modify.vel
\ hp_rand_elm hp_rand 'c modify.vel
\ hp_rand_elm hp_flip 'c modify.vel
\
\ hp_rand_elm hp_norm 'c modify.pos
\ hp_rand_elm hp_incr 'c modify.pos
\ hp_rand_elm hp_decr 'c modify.pos
\ hp_rand_elm hp_rand 'c modify.pos
hp_rand_elm hp_flip 'c modify.pos
\
0 0 'c 2drop
\
}STUFF: on-matrix
;
: OFF.MATRIX.INIT ( -- )
sub" off.matrix.init"
\
matrix_#arguments put.#arguments: off-matrix
\
STUFF{
\
\ hp_rand_elm hp_norm 'c modify.mass
\ hp_rand_elm hp_incr 'c modify.mass
\ hp_rand_elm hp_decr 'c modify.mass
\ hp_rand_elm hp_rand 'c modify.mass
\ hp_rand_elm hp_flip 'c modify.mass
\
\ hp_rand_elm hp_norm 'c modify.vel
\ hp_rand_elm hp_incr 'c modify.vel
hp_rand_elm hp_decr 'c modify.vel
\ hp_rand_elm hp_rand 'c modify.vel
\ hp_rand_elm hp_flip 'c modify.vel
\
\ hp_rand_elm hp_norm 'c modify.pos
\ hp_rand_elm hp_incr 'c modify.pos
\ hp_rand_elm hp_decr 'c modify.pos
\ hp_rand_elm hp_rand 'c modify.pos
hp_rand_elm hp_flip 'c modify.pos
\
0 0 'c 2drop
\
}STUFF: off-matrix
;
\ system control
: IO.MATRIX.DEFAULT ( -- )
;
: IO.MATRIX.RESET ( -- )
test" IO.MATRIX.RESET"
\
scramble.matrix
;
: IO.MATRIX.UPDATE ( -- )
;
: IO.MATRIX.PANIC ( -- )
;
: IO.MATRIX.STANDBY ( -- )
modify.matrix
;
: IO.MATRIX.START ( -- )
;
: MATRIX.IMBNF ( -- , it must be nearly finished )
;
: IO.MATRIX.STOP ( -- )
;
: IO.MATRIX.PAUSE ( -- )
;
: IO.MATRIX.RESUME ( -- )
;
\ setup & clearup
: IO.MATRIX.INIT ( -- )
test" IO.MATRIX.INIT"
\
meta.alert.matrix.init
\
alert.matrix.init
on.matrix.init
off.matrix.init
\
scramble.matrix
\
\ io.matrix.default \ removed MOD: 07-03-04
;
: IO.MATRIX.TERM ( -- )
test" IO.MATRIX.TERM"
\
free: meta-alert-matrix
\
free: alert-matrix
free: on-matrix
free: off-matrix
;
if.forgotten io.matrix.term
io_test? .IF
: IO.MATRIX.PRINT ( -- )
>newline
." IO_MATRIX" cr
>newline ." Print objects?" y/n
IF print: alert-matrix ?pause >newline
print: on-matrix ?pause >newline
print: off-matrix ?pause >newline
THEN
;
.THEN