\ io \ \ io_player \ particle.player classes for the piece io. \ \ \ usage: \ \ methods: \ \ PRIMARY: ( -- , set as "primary" player ) \ ?PRIMARY: ( -- flag , true if player is the "primary" player ) \ \ PUT.PULSE: ( ticks -- , set pulse value ) \ GET.PULSE: ( -- ticks , retrieve pulse value ) \ \ \ see the file io_output for the use of this component. \ \ see the file io_top for more information on io itself. \ \ \ 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 04/26/00 Add the io_player component. \ MOD: HeP 06/04/00 Replace the complicated system of voice/player "priority" \ with a simpler "primary" flag. \ REV: 0.0.1 alpha __________________________________________________________ \ REV: 0.0.1 beta __________________________________________________________ \ MOD: HeP 05-01-04 Move all includes (and conditional includes) from the \ individual files to load_io. \ REV: 0.0.1 a ++ __________________________________________________________ \ REV: 0.0.1 b ++ __________________________________________________________ \ Version for performance at Blackrock Castle Observatory, \ Cork, Ireland, May 25, 2010. \ \ \ ToDo: How do the banalyzers communicate with the players? Is the variable \ primary-player enough? Should we implement an ALERT: method? anew task-io_player variable primary-player method PRIMARY: method ?PRIMARY: method PUT.PULSE: method GET.PULSE: :class OB.IO.PLAYER iv-iopl-pulse ;m :m FREE: ( -- ) free: super \ primary-player @ self = IF 0 primary-player ! THEN ;m \ primary player :m PRIMARY: ( -- , set as "primary" player ) self primary-player ! ;m :m ?PRIMARY: ( -- flag , true if player is the "primary" player ) primary-player @ self = ;m \ pulse :m PUT.PULSE: ( ticks -- , set pulse value ) iv=> iv-iopl-pulse ;m :m GET.PULSE: ( -- ticks , retrieve pulse value ) iv-iopl-pulse ;m \ duration & on time :m DURATION: ( -- ticks ) iv-prtpl-dur-cfa IF iv-prtpl-element# iv-prtpl-particle-addr iv-prtpl-dur-cfa -1 exec.stack? ELSE iv-jb-duration THEN ;m :m GET.ON.TIME: ( -- ticks ) get.on.time: super 1 choose+/- + ;m \ print :m PRINT: ( -- ) print: super ." primary = " ?primary: self IF ." Yes" ELSE ." No" THEN cr ." pulse = " iv-iopl-pulse 4 .r cr ;m ;class \ utility words : PRIMARY.PULSE! ( ticks -- , set primary player's pulse value ) primary-player @ dup IF put.pulse: [] ELSE 2drop THEN ; : PRIMARY.PULSE@ ( -- ticks | false ) primary-player @ dup IF get.pulse: [] ELSE drop FALSE THEN ; : PRIMARY.START.AT ( time -- , start primary player at given time ) primary-player @ dup IF start.at: [] ELSE 2drop THEN ; : PRIMARY.START ( -- , start primary player now ) primary-player @ ?dup IF start: [] THEN ;