\ io \ \ io_hp \ "henri poincare" component (space, particles, etc) of io. \ \ \ the hp_ objects act fairly autonomously within io. The input components \ (see file io_input) alter the behavior of these objects via the matrix \ (see file io_matrix). The hp_ objects themselves only send data and \ messages to the io_output components. \ \ io_input io_matrix ===> io_hp =======> io_output io_top \ ^^^^^^^^^ ^^^^^ ^^^^^^^^^ \ parser ----------------------> hp.noteon \ -----> hp.noteoff \ \ \ note the io specific hp_ classes are defined in the files \ modules:io_particle and modules:io_space. \ \ \ 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 10/08/99 Only load task-hp_screen if io_test? is true. \ MOD: HeP 02/21/00 Add the global control word IO.STANDBY and corresponding \ words to each component. \ MOD: HeP 02/25/00 hp_dur is set relative to io_rtc_rate due to the vl70m \ locking up at higher midi data rates! \ MOD: HeP 03/14/00 Dynamically instantiate particles. \ MOD: HeP 03/20/00 Fix bug in IO.PARTICLE.TERM by setting all elements of \ io-space to zero once the particles are deinstantiated. \ MOD: HeP 04/17/00 Move the constant hp_range to io_config. \ MOD: HeP 04/19/00 Add io_particle component. \ MOD: HeP 04/26/00 No longer load myt:hp_input_particle since we define an \ equivalent class in modules:io_particle. \ Add io_player component. \ MOD: HeP 04/30/00 Hierarchy is built up in the io_top file, thus no longer \ need the intermediate hp-coll collection. \ MOD: HeP 05/02/00 Move players to io_output. \ Also move the hp_ graphics from io_hp since these qualify \ as 'side effects' of the system. \ MOD: HeP 05/25/00 Base particle coord around 0 (the "origin"). This \ simplifies mirror transformation of position. \ MOD: HeP 05/31/00 Assume that the static.particle will be held in the first \ element of the space. \ MOD: HeP 06/02/00 Use particle.list class instead of ob.objlist. \ MOD: HeP 06/22/00 Simpler particle.term by using the particle.list class' \ clearup methods. \ There's a bug related to START: or STOP:ing io-space. \ As far as I can work out this has to do with OPEN: and \ CLOSE:ing the gr.particles -- these objects don't check if \ window is open before drawing! \ MOD: HeP 06/23/00 Bug fix (see modules:io_interp). \ MOD: HeP 10/01/00 Delete some code from IO.PARTICLE.TERM, and rewrite \ IO.PARTICLE.RESET to use methods of the ob.partcile.list \ class (e.g. MODIFY.POSITION:). \ MOD: HeP 10/18/00 static.particle's mass is normalized when a note on is \ recieved. \ Current version uses a single static.particle. \ REV: 0.0.1 alpha __________________________________________________________ \ MOD: HeP 11/02/00 Update doc and comments. \ MOD: HeP 11/14/00 Implement HP.ALERT to regulate output volume. \ REV: 0.0.1 beta __________________________________________________________ \ MOD: HeP 03-19-04 First experiments with floating point calculations. \ MOD: HeP 03-21-04 Speedup floating point code. Old floating point would drag \ the system by 30% (35 ticks or so instead of the 26 ticks \ set by hp_dur). New code gets us back to speed. \ 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 ++ __________________________________________________________ \ REV: 0.0.1 b ++ __________________________________________________________ \ Version for performance at Blackrock Castle Observatory, \ Cork, Ireland, May 25, 2010. \ \ \ ToDo: The number of static particles should be dependent on the number of \ input parsers. \ ToDo: Couple static.particles with parsers? Use current-parser? \ ToDo: More consistent and comprehensive error reporting. anew task-io_hp io_rtc_rate 15 / 4 MAX constant hp_dur 10 constant hp_gravconst \ *** unused! *** 300 constant min_mass \ *** should these be defined in *** 900 constant max_mass \ *** modules:io_particle? *** 600 constant default_mass \ *** Are these used here at all? *** \ io_#input constant #static_particles \ max number of static particles 1 constant #static_particles \ max number of static particles 5 constant min_#particles \ corresponds to the output "voices" 8 constant max_#particles \ max number of non-static particles ob.io.space io-space ob.fpgravity io-force ob.particle.list particle-holder \ for players and interpreters ob.particle.list static-particle-holder \ for banalyzers \ particles : IO.PARTICLE.INIT ( -- ) sub" io.particle.init" \ \ initialize static particle... \ #static_particles new: static-particle-holder \ instantiate ob.io.static.particle dup IF dup add: io-space dup add: static-particle-holder \ 3 over new: [] \ max_mass over put.mass: [] \ >r hp_range/2 negate hp_range -1 r> put.range: [] ELSE drop " Sorry, an error occurred while trying to create static.particles. Quit and try restarting the program." init.error THEN \ \ initialize dynamic particles... \ max_#particles #static_particles - new: particle-holder \ max_#particles #static_particles - 0 DO instantiate ob.io.particle dup IF dup add: io-space dup add: particle-holder \ 3 over new: [] \ default_mass over put.mass: [] \ >r hp_range/2 negate hp_range -1 r> put.range: [] ELSE drop " Sorry, an error occurred while trying to create particles. Quit and try restarting the program." init.error THEN LOOP ; : IO.PARTICLE.TERM ( -- ) sub" io.particle.term" \ freeall: static-particle-holder deinstantiate: static-particle-holder \ freeall: particle-holder deinstantiate: particle-holder ; : RESET.PARTICLES ( -- ) -1 hp_norm modify.mass: static-particle-holder -1 hp_norm modify.position: static-particle-holder \ -1 hp_rand modify.mass: particle-holder -1 hp_rand modify.position: particle-holder -1 hp_norm modify.velocity: particle-holder ; : IO.PARTICLE.RESET ( -- ) sub" io.particle.reset" \ reset.particles ; \ for input parser : HP.NOTEON ( note# vel -- , normalize static.particle's mass ) 2drop 0 hp_norm modify.mass: static-particle-holder ; : HP.NOTEOFF ( note# vel -- , slow things down ) 2drop hp_every_elm hp_decr modify.velocity: particle-holder ; : HP.ALERT ( vel -- , reposition static.particle ) vel->hp hp_position vel_dim# 0 get: static-particle-holder ed.to: [] ; \ system control : IO.HP.DEFAULT ( -- ) ; : IO.HP.RESET ( -- ) test" IO.HP.RESET" \ io.particle.reset ; : IO.HP.UPDATE ( -- ) ; : IO.HP.PANIC ( -- ) ; : IO.HP.STANDBY ( -- ) start: io-space ; : IO.HP.START ( -- ) ; : HP.IMBNF ( -- , it must be nearly finished ) ; : IO.HP.STOP ( -- ) stop: io-space \ hp_every_elm hp_norm modify.mass: static-particle-holder hp_every_elm hp_norm modify.velocity: particle-holder ; : IO.HP.PAUSE ( -- ) stop: io-space ; : IO.HP.RESUME ( -- ) start: io-space ; \ setup & clearup : IO.HP.INIT ( -- ) test" IO.HP.INIT" \ FPINIT \ initialise floating point \ 3 new: io-force \ max_#particles new: io-space io-force put.force: io-space hp_dur put.duration: io-space \ io.particle.init RESET.PARTICLES \ \ io.hp.default \ removed MOD: 07-03-04 ; : IO.HP.TERM ( -- ) test" IO.HP.TERM" \ free: io-space \ io.particle.term \ FPTERM \ clearup floating point ; if.forgotten io.hp.term io_test? .IF : IO.HP.PRINT ( -- ) >newline ." IO_HP" cr ." Constants" cr ." duration =" hp_dur 6 .r cr ." grav constant =" hp_gravconst 6 .r cr ." range =" hp_range 6 .r cr ." mass minimum =" min_mass 6 .r cr ." maximum =" max_mass 6 .r cr ." default =" default_mass 6 .r cr >newline ." Print objects?" y/n IF print: io-space ?pause >newline print: io-force ?pause >newline \ many: io-space 0 DO i get: io-space print: [] ?pause >newline LOOP THEN ; .THEN