Permalink
Browse files

adding chuck integration test

  • Loading branch information...
1 parent be54109 commit 3ffe9f989773bdb8da6a9e6f7f46807643e5d274 @aberant committed Apr 28, 2013
Showing with 63 additions and 0 deletions.
  1. +27 −0 integration-test/chuck/osc_frequency_test.rb
  2. +36 −0 integration-test/chuck/simple_osc_synth.ck
@@ -0,0 +1,27 @@
+system( "chuck --version &>/dev/null" )
+
+# why does chuck say it's a failure when it successfully outputs the version?
+if $?.exitstatus != 2
+ STDERR.puts "you must install ChucK for this test to work"
+ exit 1
+end
+chuck_file = File.join(File.dirname(__FILE__), "simple_osc_synth.ck")
+
+pid = fork do
+ puts "child process"
+ exec( "chuck #{chuck_file}" )
+ exit
+end
+puts pid
+
+# wait for chuck to wake up
+sleep(0.1)
+
+require 'osc-ruby'
+@client = OSC::Client.new( 'localhost', 3333 )
+(48..71).each do |midi_note|
+ @client.send( OSC::Message.new("/foo/notes", midi_note, 0.2))
+ sleep( 0.25 )
+end
+
+Process.kill("SIGTERM", pid)
@@ -0,0 +1,36 @@
+
+// the patch
+SinOsc s => JCRev r => dac;
+.5 => s.gain;
+.1 => r.mix;
+
+// create our OSC receiver
+OscRecv recv;
+// use port 3333 (or whatever)
+3333 => recv.port;
+// start listening (launch thread)
+recv.listen();
+
+// create an address in the receiver, store in new variable
+recv.event( "/foo/notes, i f" ) @=> OscEvent @ oe;
+
+// infinite event loop
+while( true )
+{
+ // wait for event to arrive
+ oe => now;
+
+ // grab the next message from the queue.
+ while( oe.nextMsg() )
+ {
+ int i;
+ float f;
+
+ // getFloat fetches the expected float (as indicated by "i f")
+ oe.getInt() => i => Std.mtof => s.freq;
+ oe.getFloat() => f => s.gain;
+
+ // print
+ <<< "got (via OSC):", i, f >>>;
+ }
+}

0 comments on commit 3ffe9f9

Please sign in to comment.