\ ob.interpreter \ \ interpreter \ Class of device that allows several players (morphs) to use a single \ instrument (device driver) while using seperate interpreters. \ \ Code: Han-earl Park \ Copyright 2000 Buster & Friends C-ALTO Labs \ (Valencia, November 1999 - \ (Southampton, October 2000 - \ \ MOD: HeP 11/12/99 Started project. \ A simplification of the vl.interpreter class. \ MOD: HeP 04/15/00 Add the variable current-interpreter. \ MOD: HeP 10/10/00 Check if interpreter was assigned as its own instrument. include? task-device myt:device anew task-interpreter variable current-interpreter :class OB.INTERPRETER iv-interp-instrument ;m :m DEFAULT: ( -- ) iv-interp-instrument IF iv-interp-instrument default: [] THEN ;m :m UPDATE: ( -- ) iv-interp-instrument IF iv-interp-instrument update: [] THEN ;m :m RESET: ( -- ) iv-interp-instrument IF iv-interp-instrument reset: [] THEN ;m :m FREE: ( -- ) iv-interp-instrument IF iv-interp-instrument free: [] THEN ;m :m RAW.OPEN: ( -- ) iv-interp-instrument IF iv-interp-instrument open: [] THEN ;m :m RAW.CLOSE: ( -- ) iv-interp-instrument IF iv-interp-instrument close: [] THEN ;m \ assign instrument :m PUT.INSTRUMENT: ( instr -- ) dup self = IF drop " put.instrument:" " attempted to assign interpreter to itself" er_return ob.report.error ELSE iv=> iv-interp-instrument THEN ;m :m GET.INSTRUMENT: ( -- instr | 0 ) iv-interp-instrument ;m \ use the object's on or off interpreter function, but pass the instrument \ or device driver's address to the on or off interpreter function. :m ELEMENT.ON: ( elm# sh -- ) iv-interp-instrument iv-dev-on-cfa AND IF self current-interpreter ! \ iv-interp-instrument \ -- elm# sh instr iv-dev-on-cfa -3 exec.stack? ELSE 2drop THEN ;m :m ELEMENT.OFF: ( elm# sh -- ) iv-interp-instrument iv-dev-off-cfa AND IF self current-interpreter ! \ iv-interp-instrument \ -- elm# sh instr iv-dev-off-cfa -3 exec.stack? ELSE 2drop THEN ;m :m PRINT: ( -- ) print: super ." Instrument = " iv-interp-instrument ob.name cr ;m ;class \ test false .IF ob.interpreter test-interp-1 ob.interpreter test-interp-2 ob.interpreter test-interp-3 : ON.FUNC.1 { elm# sh instr -- } elm# 1 ed.at: sh elm# 2 ed.at: sh on.time note.on.for: instr ; : ON.FUNC.2 { elm# sh instr -- } elm# 1 ed.at: sh 2 choose + elm# 2 ed.at: sh on.time note.on.for: instr ; : ON.FUNC.3 { elm# sh instr -- } elm# 1 ed.at: sh choose 12 + 127 005 note.on.for: instr ; : DUR.FUNC.1 { elm# sh -- dur } elm# 0 ed.at: sh ; : DUR.FUNC.2 { elm# sh -- dur } elm# 0 ed.at: sh 1+ ; : DUR.FUNC.3 { elm# sh -- dur } 30 choose 1+ ; : TEST.INTERP.INIT ( -- ) prefab: shape-1 \ clear: shape-holder shape-1 add: shape-holder \ ins-midi-1 put.instrument: test-interp-1 ins-midi-1 put.instrument: test-interp-2 ins-midi-1 put.instrument: test-interp-3 'c on.func.1 put.on.function: test-interp-1 'c on.func.2 put.on.function: test-interp-2 'c on.func.3 put.on.function: test-interp-3 \ shape-1 test-interp-1 build: player-1 shape-1 test-interp-2 build: player-2 shape-1 test-interp-3 build: player-3 'c dur.func.1 put.dur.function: player-1 'c dur.func.2 put.dur.function: player-2 'c dur.func.3 put.dur.function: player-3 1000 put.repeat: player-1 1000 put.repeat: player-2 1000 put.repeat: player-3 \ stuff{ player-1 player-2 player-3 }stuff: coll-p-1 ; : TEST.INTERP.TERM ( -- ) free.hierarchy: coll-p-1 ; if.forgotten test.interp.term : TEST.INTERP ( -- ) test.interp.init coll-p-1 hmsl.play test.interp.term ; cr cr ." Enter TEST.INTERP to run a simple demo of the interpreter class." cr cr .THEN