world: do not circumvent config XML check

Fix #93
This commit is contained in:
Martin Stein
2017-12-06 17:44:37 +01:00
committed by Norman Feske
parent 6d2f2c8a31
commit 556bfb2cf8
7 changed files with 190 additions and 193 deletions

View File

@@ -1,8 +1,5 @@
assert_spec x86 assert_spec x86
# Xmllint throws errors on inline chuck code
proc check_xml_with_schema {xml_file} { }
# #
# Build # Build
# #
@@ -21,6 +18,8 @@ build $build_components
create_boot_directory create_boot_directory
exec cp [genode_dir]/repos/world/src/test/chuck/demo.ck bin/test-chuck-demo.ck
# #
# Config # Config
# #
@@ -60,40 +59,9 @@ append config {
<config dac_channels="2" adc_channels="0"> <config dac_channels="2" adc_channels="0">
<libc stdout="/log" stderr="/log"/> <libc stdout="/log" stderr="/log"/>
<vfs> <log/> <vfs> <log/>
<inline name="test"> <rom name="test-chuck-demo.ck"/>
// 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;
</inline>
</vfs> </vfs>
<file path="/test"/> <file path="/test-chuck-demo.ck"/>
</config> </config>
<route> <route>
<any-service><parent/><any-child/></any-service> <any-service><parent/><any-child/></any-service>
@@ -119,6 +87,7 @@ append boot_modules {
stdcxx.lib.so stdcxx.lib.so
libc.lib.so libc.lib.so
libm.lib.so libm.lib.so
test-chuck-demo.ck
} [audio_drv_binary] { } [audio_drv_binary] {
} }

View File

@@ -1,8 +1,5 @@
assert_spec x86 assert_spec x86
# Xmllint throws errors on inline chuck code
proc check_xml_with_schema {xml_file} { }
# #
# Build # Build
# #
@@ -24,6 +21,8 @@ build $build_components
create_boot_directory create_boot_directory
exec cp [genode_dir]/repos/world/src/test/chuck/demo_keyboard.ck bin/test-chuck-demo_keyboard.ck
# #
# Config # Config
# #
@@ -93,64 +92,9 @@ append config {
<config dac_channels="2" adc_channels="0"> <config dac_channels="2" adc_channels="0">
<libc stdout="/log" stderr="/log"/> <libc stdout="/log" stderr="/log"/>
<vfs> <log/> <vfs> <log/>
<inline name="test"> <rom name="test-chuck-demo_keyboard.ck"/>
// 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;
}
}
}
</inline>
</vfs> </vfs>
<file path="/test"/> <file path="/test-chuck-demo_keyboard.ck"/>
</config> </config>
<route> <route>
<any-service><parent/><any-child/></any-service> <any-service><parent/><any-child/></any-service>
@@ -176,6 +120,7 @@ append boot_modules {
stdcxx.lib.so stdcxx.lib.so
libc.lib.so libc.lib.so
libm.lib.so libm.lib.so
test-chuck-demo_keyboard.ck
} [audio_drv_binary] { } [audio_drv_binary] {
} }

View File

@@ -1,8 +1,5 @@
assert_spec x86 assert_spec x86
# Xmllint throws errors on inline chuck code
proc check_xml_with_schema {xml_file} { }
# #
# Build # Build
# #
@@ -24,6 +21,8 @@ build $build_components
create_boot_directory create_boot_directory
exec cp [genode_dir]/repos/world/src/test/chuck/demo_mouse.ck bin/test-chuck-demo_mouse.ck
# #
# Config # Config
# #
@@ -93,98 +92,9 @@ append config {
<config dac_channels="2" adc_channels="0"> <config dac_channels="2" adc_channels="0">
<libc stdout="/log" stderr="/log"/> <libc stdout="/log" stderr="/log"/>
<vfs> <log/> <vfs> <log/>
<inline name="test"> <rom name="test-chuck-demo_mouse.ck"/>
// 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() >>>;
}
</inline>
</vfs> </vfs>
<file path="/test"/> <file path="/test-chuck-demo_mouse.ck"/>
</config> </config>
<route> <route>
<any-service><parent/><any-child/></any-service> <any-service><parent/><any-child/></any-service>
@@ -210,6 +120,7 @@ append boot_modules {
stdcxx.lib.so stdcxx.lib.so
libc.lib.so libc.lib.so
libm.lib.so libm.lib.so
test-chuck-demo_mouse.ck
} [audio_drv_binary] { } [audio_drv_binary] {
} }

View File

@@ -10,9 +10,6 @@
# $test_name # $test_name
# #
# Skip schema check
proc check_xml_with_schema {xml_file} { }
set build_components { set build_components {
core init drivers/timer core init drivers/timer
lib/vfs/jitterentropy lib/vfs/jitterentropy

31
src/test/chuck/demo.ck Normal file
View File

@@ -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;

View File

@@ -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;
}
}
}

View File

@@ -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() >>>;
}