' Include file for Lites - included by robodomi.inc '******************************** ' Namuda study #22 - Lites ' 02.2012 '******************************** ' Gesture controlled lites mostly. ' musical robots: Bomi-Spiro on Edgy-Smooth ' Music is for the viola! %NamLit0 = 17 %NamLit1 = 18 %NamLit2 = 19 %NamLit3 = 20 DECLARE SUB NamLit0 () DECLARE SUB NamLit1 () DECLARE SUB NamLit2 () DECLARE SUB NamLit3 () SUB Init_Lites () ClearTasks ' Namuda Study #22 - lites Task(%NamLit0).naam = "Lites0" ' white Task(%NamLit0).freq = 130 Task(%NamLit0).cptr = CODEPTR(NamLit0) Task(%NamLit0).flags = %PERTIM_Task Task(%NamLit1).naam = "Lites1" ' blue Task(%NamLit1).freq = 120 Task(%NamLit1).cptr = CODEPTR(NamLit1) Task(%NamLit1).flags = %PERTIM_Task Task(%NamLit2).naam = "Lites2" ' red Task(%NamLit2).freq = 110 Task(%NamLit2).cptr = CODEPTR(NamLit2) Task(%NamLit2).flags = %PERTIM_Task Task(%NamLit3).naam = "Lites3" ' yellow/green & spiro-bomi Task(%NamLit3).freq = 8 Task(%NamLit3).cptr = CODEPTR(NamLit3) Task(%NamLit3).flags = %False END SUB SUB NamLit0 () 'started with copy van IcyLite. %vbt7 - white lites 'collision trigger @ white strobo's STATIC xtrig, ytrig, ztrig, strig, lites AS LONG STATIC sens AS SINGLE IF ISFALSE Task(%NamLit0).tog THEN 'start gesture analyser!!! IF ISFALSE Task(%Gesture_analyser).tog THEN starttask %Gesture_Analyser MM_Thunderwood_On MM_Heli_On MM_Ob_On RESET lites sens = 1.4 '14/10 Task(%NamLit0).tog = %True END IF ' on collision, flash white lites... IF Gesture.collision(0) > sens THEN IF ISFALSE xtrig THEN mPlay Vibi.channel, 121, 127 KeyPress Vibi.channel, 121, MIN(Gesture.impact(0) * 255, 127) 'white LED mPlay Vibi.channel, 123, 127 KeyPress Vibi.channel, 123, MIN(Gesture.impact(0) * 255, 127) 'white LED MM_Bono_On %MM_White xtrig = %True END IF ELSE IF xtrig THEN MM_Vibi_Off %MM_White MM_Bono_Off %MM_White RESET xtrig END IF END IF IF Gesture.collision(1) > sens THEN IF ISFALSE ytrig THEN MM_Bomi_On %MM_White MM_Korn_On %MM_White ytrig = %true END IF ELSE IF ytrig THEN RESET ytrig MM_Bomi_Off %MM_Lights MM_Korn_Off %MM_White END IF END IF IF Gesture.collision(2) > sens THEN IF ISFALSE ztrig THEN MM_Puff_On %MM_White MM_Ob_On %MM_White MM_HarmO_On %MM_White ztrig = %True END IF ELSE IF ztrig THEN MM_Puff_Off %MM_White MM_Ob_Off %MM_White MM_HarmO_Off %MM_White RESET ztrig END IF END IF IF gesture.collision(3) THEN IF ISFALSE lites THEN 'licht MM_So_On %MM_White MM_Troms_On %MM_Lights MM_Heli_On %MM_Lights mPlay Thunderwood.channel, 0, 127 lites = %True END IF ELSE IF lites THEN 'licht uit. MM_So_Off %MM_White MM_Troms_Off %MM_Lights MM_Heli_Off %MM_Lights mPlay Thunderwood.channel, 0, %False RESET lites END IF IF strig THEN IF gesture.collision(3) > sens THEN RESET strig END IF END IF END IF END SUB SUB NamLit1 () ' based on: Domi_SpeedUp_Trig () - mapping on blue lites. ' here we look only into the frequency data in order to detect accelerating gesture ' this is an experiment only sofar... ' this code works but not too well. The mapping on Llor was not very good neither. (way too loud) ' code adapted to fourstep recognition 06.04.2010 ' retested, with better ambitus mapping ' rescaling done 09.04.2010 ' 13.04.2010 works very well now with algo 1, but scaling should be enlarged. ' 15.04.2010: fine tuning. ' 11.02.2012: Blue lites on speedup, red on slowdown STATIC xtrig, ytrig, ztrig, xnoot, ynoot, znoot AS LONG STATIC sens AS SINGLE IF ISFALSE Task(%NamLit1).tog THEN sens = 18 'in Hz units MM_Korn_On MM_Autosax_On MM_Ob_On IF ISFALSE Task(%Gesture_Analyser).tog THEN starttask %Gesture_Analyser Task(%NamLit1).tog = %True END IF ' on accelerating body speed, do something... ' X-vektor: 'IF gesture.speedup(0) > sens and gesture.speedup(0) > gesture.slowdown(0) THEN ' frequency is unipolar data, not normalized IF gesture.speedup(0) > gesture.slowdown(0) + sens THEN IF ISFALSE xtrig THEN xnoot = MIN(Ob.lowtes - sens + (gesture.speedup(0)* 1.5), Ob.Hightes) 'mPlay Ob.channel,xnoot, MIN(gesture.speedup_val(0) * 2, 127) MM_Qt_On %MM_Blue MM_Spiro_On %MM_Blue xtrig = %True END IF ELSE RESET xtrig IF xnoot THEN IF ISFALSE gesture.speedup_dur(0) THEN 'mPlay Ob.channel, xnoot, %False MM_Qt_Off %MM_Blue MM_Spiro_Off %MM_Blue RESET xnoot END IF END IF END IF ' IF gesture.speedup(1) > sens THEN IF gesture.speedup(1) > gesture.slowdown(1) + sens THEN IF ISFALSE ytrig THEN ynoot = MIN(Korn.lowtes - sens + (gesture.speedup(1)* 1.5), Korn.Hightes) 'mPlay Korn.channel,ynoot , MIN(gesture.speedup_val(1) * 2, 127) MM_Korn_On %MM_Blue MM_Fa_On %MM_Blue MM_HarmO_On %MM_Blue ytrig = %true END IF ELSE IF ynoot THEN IF ISFALSE gesture.speedup_dur(1) THEN 'mPlay Korn.channel, ynoot, %False MM_Korn_Off %MM_Blue MM_Fa_Off %MM_Blue MM_HarMO_Off %MM_Blue RESET ynoot END IF END IF RESET ytrig END IF IF gesture.speedup(2) > gesture.slowdown(2) + sens THEN IF ISFALSE ztrig THEN znoot = MIN(Autosax.lowtes - sens + (gesture.speedup(2)* 1.5), Autosax.Hightes) 'mPlay Autosax.channel, znoot, MIN(gesture.speedup_val(2) * 3, 127) MM_Snar_On %MM_Blue MM_Thunderwood_On %MM_Blue MM_Llor_On %MM_Blue MM_Toypi_On %MM_Blue ztrig = %True END IF ELSE IF znoot THEN IF ISFALSE gesture.speedup_dur(2) THEN 'mPlay Autosax.channel, znoot, %False MM_Snar_Off %MM_Blue MM_Thunderwood_Off %MM_Blue MM_Llor_Off %MM_Blue MM_Toypi_Off %MM_Blue RESET znoot END IF END IF RESET ztrig END IF IF Gesture.speedup(3) > (sens * 3) THEN IF gesture.speedup(3) > (gesture.slowdown(3) + (sens * 4)) THEN MM_Psch_On %MM_Blue END IF END IF END SUB SUB NamLit2 () ' based on: Domi_Slowdown_Trig () - mapping on red lites ' here we look only into the frequency data on order to detect sudden slowdown gesture ' original version in Butoh_010.inc (was not working well anyway...) ' now using the new Gesture_Classify procedure (Fourstep) ' mapped on piperola - should give very short notes only. ' 06.04.2010 : using gesture_analyser ' 09.04.2010: rescaled ' 15.04.2010: extended testing under algo1: FIR. Works very reliably now STATIC xtrig, ytrig, ztrig AS LONG STATIC xnoot, ynoot, znoot, lites AS WORD STATIC sens AS SINGLE IF ISFALSE Task(%NamLit2).tog THEN sens = 12 'MM_Piperola_On 'MM_Bourdonola_On 'Controller Bourdonola.channel, 1, 50 'low wind pressure ! IF ISFALSE Task(%Gesture_Analyser).tog THEN starttask %Gesture_Analyser Task(%NamLit2).tog = %True END IF IF Gesture.slowdown(0) > sens THEN ' frequency is unipolar data! - under algo1, can go up to 230 IF ISFALSE xtrig THEN xnoot = MIN(Piperola.lowtes - sens + 2+ (gesture.slowdown_val(0)/2), Piperola.hightes) 'independent from sens 15.04 'mPlay Piperola.channel, xnoot, 64 MM_Harma_On %MM_Red MM_So_On %MM_Red MM_Xy_On %MM_Red xtrig = %True END IF ELSE IF xtrig THEN IF xnoot THEN 'mPlay Piperola.channel, xnoot, %False MM_Harma_Off %MM_Red MM_So_Off %MM_Red MM_Xy_Off %MM_Red RESET xnoot END IF END IF RESET xtrig END IF IF Gesture.slowdown(1) > sens THEN IF ISFALSE ytrig THEN ynoot = MIN(Piperola.lowtes - sens + 2+ (gesture.slowdown_val(1)/2), Piperola.hightes) 'mPlay Piperola.channel, ynoot, 64 MM_Thunderwood_On %MM_Red 'MM_Autosax_On %MM_Red MM_Vibi_On %MM_Red ytrig = %true END IF ELSE IF ytrig THEN IF ynoot THEN 'mPlay Piperola.channel, ynoot, %False MM_Thunderwood_Off %MM_Red 'MM_Autosax_Off %MM_Red MM_Vibi_On %MM_Red RESET ynoot END IF END IF RESET ytrig END IF IF Gesture.slowdown(2) > sens THEN IF ISFALSE ztrig THEN ' avoiding multiple triggers znoot = MIN(Piperola.lowtes - sens + 2+(gesture.slowdown_val(2)/2), Piperola.hightes) 'mPlay Piperola.channel, znoot, 64 MM_Puff_On %MM_Red MM_Fa_On %MM_Red ztrig = %True END IF ELSE IF ztrig THEN IF znoot THEN 'mPlay Piperola.channel, znoot , %False MM_Puff_Off %MM_Red MM_Fa_Off %MM_Red RESET znoot END IF END IF RESET ztrig END IF IF (gesture.slowdown(3) > sens) AND (gesture.slowdown(3) > gesture.speedup(3)) THEN 'add piperola percussion here... 'mPlay Piperola.channel, 120 + (gesture.slowdown(3) MOD 8), MIN(@pDoppler.xf, 127) ' is this the culprit? 'bug goes away when we rem this.. pic error on piperola?? IF ISFALSE lites THEN 'MM_Piperola_On %MM_Lights MM_AllLightsOn %MM_Red lites = %True END IF ELSE IF lites THEN 'MM_Piperola_Off %MM_Lights MM_AllLightsOff %MM_Red RESET lites END IF END IF END SUB SUB NamLit3 () ' based on: Domi_Edgy_Trig () 'evaluation for gesture.edgy and gesture.smooth properties '06.05.2010 - piano - harmo '09.05.2010 - instrumentation changed to pp - qt, because we cannot startup harmo... '17.05.2010 - qt wind controll added. ' now edgy= yellow, smooth = Green ' instrum. changed to bomi and spiro STATIC noot1, noot2, noot3, tog AS INTEGER STATIC wind AS SINGLE IF ISFALSE Task(%Edgy_Trigger).tog THEN wind = Bomi.ctrl(7) MM_Bomi_On MM_Spiro_On Task(%Edgy_Trigger).tog = %True END IF IF gesture.edgy_dur(3) THEN 'if edgy, we select spiro noot1 = MIN(spiro.lowtes + (gesture.edgy(0) * 127), spiro.hightes) noot2 = MIN(spiro.lowtes + (gesture.edgy(1) * 127), spiro.hightes) noot3 = MIN(spiro.lowtes + (gesture.edgy(2) * 127), spiro.hightes) addnote2har spiro.har(1), noot1, (@pDoppler.xa * 127) addnote2har spiro.har(1), noot2, (@pDoppler.ya * 127) addnote2har spiro.har(1), noot3, (@pDoppler.za * 127) Instrumplay Spiro MM_HarmO_On %MM_Yellow MM_Fa_On %MM_Yellow MM_Vibi_On %MM_Yellow MM_Belly_On %MM_Yellow MM_Bono_On %MM_Yellow ELSE IF noot1 THEN Instrumplay Spiro noot1 = %False MM_HarmO_Off %MM_Yellow MM_Fa_Off %MM_Yellow MM_Vibi_Off %MM_Yellow MM_Belly_Off %MM_Yellow MM_Bono_Off %MM_Yellow END IF END IF IF gesture.smooth_dur(3) THEN 'íf smooth, we select Bomi addnote2har bomi.har(1), MIN(bomi.lowtes + (gesture.smooth(0) * 127), bomi.hightes), @pDoppler.xa * 127 addnote2har bomi.har(1), MIN(bomi.lowtes + (gesture.smooth(1) * 127), bomi.hightes), @pDoppler.ya * 127 addnote2har bomi.har(1), MIN(bomi.lowtes + (gesture.smooth(2) * 127), bomi.hightes), @pDoppler.za * 127 instrumplay Bomi MM_Thunderwood_On %MM_Green tog = %True ELSE IF tog THEN MM_Thunderwood_Off %MM_Green instrumplay Bomi tog = %False END IF END IF wind = (wind * 0.9375) + (gesture.smooth_val(3) * 7.9375) IF bomi.ctrl(7) <> INT(wind * 3) THEN controller bomi.channel, 7, MAX(MIN(wind * 3, %MM_Bomi_Motor), 20) qt.ctrl(7) = INT(wind * 3) END IF END SUB