From 556bfb2cf8aee5240aedb8ea0916874c10f62823 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Wed, 6 Dec 2017 17:44:37 +0100 Subject: [PATCH] world: do not circumvent config XML check Fix #93 --- run/chuck.run | 41 ++------------ run/chuck_keyboard.run | 65 ++-------------------- run/chuck_mouse.run | 99 ++------------------------------- run/jitterentropy_testu01.inc | 3 - src/test/chuck/demo.ck | 31 +++++++++++ src/test/chuck/demo_keyboard.ck | 55 ++++++++++++++++++ src/test/chuck/demo_mouse.ck | 89 +++++++++++++++++++++++++++++ 7 files changed, 190 insertions(+), 193 deletions(-) create mode 100644 src/test/chuck/demo.ck create mode 100644 src/test/chuck/demo_keyboard.ck create mode 100644 src/test/chuck/demo_mouse.ck diff --git a/run/chuck.run b/run/chuck.run index d239ef7..7ad63bd 100644 --- a/run/chuck.run +++ b/run/chuck.run @@ -1,8 +1,5 @@ assert_spec x86 -# Xmllint throws errors on inline chuck code -proc check_xml_with_schema {xml_file} { } - # # Build # @@ -21,6 +18,8 @@ build $build_components create_boot_directory +exec cp [genode_dir]/repos/world/src/test/chuck/demo.ck bin/test-chuck-demo.ck + # # Config # @@ -60,40 +59,9 @@ append config { - -// another candidate for lamest demo - -// patch -SinOsc s => JCRev r => dac; -.5 => r.gain; -.075 => r.mix; - -// note number -20 => float note; - -// go up to 127 -while( note < 128 ) -{ - // convert MIDI note to hz - Std.mtof( note ) => s.freq; - // turn down the volume gradually - .5 - (note/256.0) => s.gain; - - // move up by whole step - note + 2 => note; - - // advance time - .125::second => now; -} - -// turn off s -0 => s.gain; -// wait a bit -2::second => now; - - + - + @@ -119,6 +87,7 @@ append boot_modules { stdcxx.lib.so libc.lib.so libm.lib.so + test-chuck-demo.ck } [audio_drv_binary] { } diff --git a/run/chuck_keyboard.run b/run/chuck_keyboard.run index 96990ff..cdd074f 100644 --- a/run/chuck_keyboard.run +++ b/run/chuck_keyboard.run @@ -1,8 +1,5 @@ assert_spec x86 -# Xmllint throws errors on inline chuck code -proc check_xml_with_schema {xml_file} { } - # # Build # @@ -24,6 +21,8 @@ build $build_components create_boot_directory +exec cp [genode_dir]/repos/world/src/test/chuck/demo_keyboard.ck bin/test-chuck-demo_keyboard.ck + # # Config # @@ -93,64 +92,9 @@ append config { - -// HID -Hid hi; -HidMsg msg; - -// which keyboard -0 => int device; -// get from command line -if( me.args() ) me.arg(0) => Std.atoi => device; - -// open keyboard (get device number from command line) -if( !hi.openKeyboard( device ) ) me.exit(); -<<< "keyboard '" + hi.name() + "' ready", "" >>>; - -// patch -BeeThree organ => JCRev r => Echo e => Echo e2 => dac; -r => dac; - -// set delays -240::ms => e.max => e.delay; -480::ms => e2.max => e2.delay; -// set gains -.6 => e.gain; -.3 => e2.gain; -.05 => r.mix; -0 => organ.gain; - -// infinite event loop -while( true ) -{ - // wait for event - hi => now; - - // get message - while( hi.recv( msg ) ) - { - // check - if( msg.isButtonDown() ) - { - Std.mtof( msg.which + 45 ) => float freq; - if( freq > 20000 ) continue; - - freq => organ.freq; - .5 => organ.gain; - 1 => organ.noteOn; - - 80::ms => now; - } - else - { - 0 => organ.noteOff; - } - } -} - - + - + @@ -176,6 +120,7 @@ append boot_modules { stdcxx.lib.so libc.lib.so libm.lib.so + test-chuck-demo_keyboard.ck } [audio_drv_binary] { } diff --git a/run/chuck_mouse.run b/run/chuck_mouse.run index 0a7318d..17dc2ac 100644 --- a/run/chuck_mouse.run +++ b/run/chuck_mouse.run @@ -1,8 +1,5 @@ assert_spec x86 -# Xmllint throws errors on inline chuck code -proc check_xml_with_schema {xml_file} { } - # # Build # @@ -24,6 +21,8 @@ build $build_components create_boot_directory +exec cp [genode_dir]/repos/world/src/test/chuck/demo_mouse.ck bin/test-chuck-demo_mouse.ck + # # Config # @@ -93,98 +92,9 @@ append config { - -// name: mouse-fm.ck -// desc: uses first X/Y axes of a mouse to control mf and index for FM -// author: Spencer Salazar - -// which mouse -0 => int device; -// get from command line -if( me.args() ) me.arg(0) => Std.atoi => device; - -// modulator to carrier -SinOsc m => SinOsc c => Envelope e => dac; - -// carrier frequency -220 => c.freq; -// modulator frequency -550 => m.freq; -// index of modulation -1000 => m.gain; - -// phase modulation is FM synthesis (sync is 2) -2 => c.sync; - -// attack -10::ms => e.duration; -.5 => e.gain; -// variables -int base; -float a0; -float a1; -float a2; -int count; - -// start things -set( base, a0, a1, a2 ); - -// hid objects -Hid hi; -HidMsg msg; - -// try -if( !hi.openMouse( device ) ) me.exit(); -<<< "mouse '" + hi.name() + "' ready...", "" >>>; - -// infinite time loop -while( true ) -{ - // wait on event - hi => now; - // loop over messages - while( hi.recv( msg ) ) - { - if( msg.isMouseMotion() ) - { - msg.deltaX * .001 + a0 => a0; - //else if( msg.which == 1 ) msg.fdata => a1; - msg.deltaY * .001 + a1 => a1; - set( base, a0, a1, a2 ); - } - - else if( msg.isButtonDown() ) - { - msg.which => base; - count++; - if( count == 1 ) e.keyOn(); - set( base, a0, a1, a2 ); - } - - else if( msg.isButtonUp() ) - { - msg.which => base; - count--; - if( !count ) e.keyOff(); - } - } -} - -// mapping function -fun void set( int base, float v0, float v1, float v2 ) -{ - // modulator frequency - ( 500 + 5*base + ( 500 * v0) ) => m.freq; - // carrier frequency - ( 220 + (220 * v2) ) => c.freq; - // index of modulation - ( 1000 * (v1+1) ) => m.gain; - <<< "carrier:", c.freq(), "modulator:", m.freq(), "index:", m.gain() >>>; -} - - + - + @@ -210,6 +120,7 @@ append boot_modules { stdcxx.lib.so libc.lib.so libm.lib.so + test-chuck-demo_mouse.ck } [audio_drv_binary] { } diff --git a/run/jitterentropy_testu01.inc b/run/jitterentropy_testu01.inc index 0f7a25f..70bb87a 100644 --- a/run/jitterentropy_testu01.inc +++ b/run/jitterentropy_testu01.inc @@ -10,9 +10,6 @@ # $test_name # -# Skip schema check -proc check_xml_with_schema {xml_file} { } - set build_components { core init drivers/timer lib/vfs/jitterentropy diff --git a/src/test/chuck/demo.ck b/src/test/chuck/demo.ck new file mode 100644 index 0000000..2f4cff7 --- /dev/null +++ b/src/test/chuck/demo.ck @@ -0,0 +1,31 @@ +// another candidate for lamest demo + +// patch +SinOsc s => JCRev r => dac; +.5 => r.gain; +.075 => r.mix; + +// note number +20 => float note; + +// go up to 127 +while( note < 128 ) +{ + // convert MIDI note to hz + Std.mtof( note ) => s.freq; + // turn down the volume gradually + .5 - (note/256.0) => s.gain; + + // move up by whole step + note + 2 => note; + + // advance time + .125::second => now; +} + +// turn off s +0 => s.gain; +// wait a bit +2::second => now; + + diff --git a/src/test/chuck/demo_keyboard.ck b/src/test/chuck/demo_keyboard.ck new file mode 100644 index 0000000..c5889ad --- /dev/null +++ b/src/test/chuck/demo_keyboard.ck @@ -0,0 +1,55 @@ +// HID +Hid hi; +HidMsg msg; + +// which keyboard +0 => int device; +// get from command line +if( me.args() ) me.arg(0) => Std.atoi => device; + +// open keyboard (get device number from command line) +if( !hi.openKeyboard( device ) ) me.exit(); +<<< "keyboard '" + hi.name() + "' ready", "" >>>; + +// patch +BeeThree organ => JCRev r => Echo e => Echo e2 => dac; +r => dac; + +// set delays +240::ms => e.max => e.delay; +480::ms => e2.max => e2.delay; +// set gains +.6 => e.gain; +.3 => e2.gain; +.05 => r.mix; +0 => organ.gain; + +// infinite event loop +while( true ) +{ + // wait for event + hi => now; + + // get message + while( hi.recv( msg ) ) + { + // check + if( msg.isButtonDown() ) + { + Std.mtof( msg.which + 45 ) => float freq; + if( freq > 20000 ) continue; + + freq => organ.freq; + .5 => organ.gain; + 1 => organ.noteOn; + + 80::ms => now; + } + else + { + 0 => organ.noteOff; + } + } +} + + diff --git a/src/test/chuck/demo_mouse.ck b/src/test/chuck/demo_mouse.ck new file mode 100644 index 0000000..3aec292 --- /dev/null +++ b/src/test/chuck/demo_mouse.ck @@ -0,0 +1,89 @@ +// name: mouse-fm.ck +// desc: uses first X/Y axes of a mouse to control mf and index for FM +// author: Spencer Salazar + +// which mouse +0 => int device; +// get from command line +if( me.args() ) me.arg(0) => Std.atoi => device; + +// modulator to carrier +SinOsc m => SinOsc c => Envelope e => dac; + +// carrier frequency +220 => c.freq; +// modulator frequency +550 => m.freq; +// index of modulation +1000 => m.gain; + +// phase modulation is FM synthesis (sync is 2) +2 => c.sync; + +// attack +10::ms => e.duration; +.5 => e.gain; +// variables +int base; +float a0; +float a1; +float a2; +int count; + +// start things +set( base, a0, a1, a2 ); + +// hid objects +Hid hi; +HidMsg msg; + +// try +if( !hi.openMouse( device ) ) me.exit(); +<<< "mouse '" + hi.name() + "' ready...", "" >>>; + +// infinite time loop +while( true ) +{ + // wait on event + hi => now; + // loop over messages + while( hi.recv( msg ) ) + { + if( msg.isMouseMotion() ) + { + msg.deltaX * .001 + a0 => a0; + //else if( msg.which == 1 ) msg.fdata => a1; + msg.deltaY * .001 + a1 => a1; + set( base, a0, a1, a2 ); + } + + else if( msg.isButtonDown() ) + { + msg.which => base; + count++; + if( count == 1 ) e.keyOn(); + set( base, a0, a1, a2 ); + } + + else if( msg.isButtonUp() ) + { + msg.which => base; + count--; + if( !count ) e.keyOff(); + } + } +} + +// mapping function +fun void set( int base, float v0, float v1, float v2 ) +{ + // modulator frequency + ( 500 + 5*base + ( 500 * v0) ) => m.freq; + // carrier frequency + ( 220 + (220 * v2) ) => c.freq; + // index of modulation + ( 1000 * (v1+1) ) => m.gain; + <<< "carrier:", c.freq(), "modulator:", m.freq(), "index:", m.gain() >>>; +} + +