Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MAUI examples

  • Loading branch information...
commit 96f04a23dc13dae8e1cdbeae8d54302e17bca374 1 parent ac7edc4
@spencersalazar authored
View
11 MAUI/examples/gauge01.ck
@@ -0,0 +1,11 @@
+SinOsc s => blackhole;
+.125 => s.freq;
+
+MAUI_Gauge gauge;
+gauge.display();
+
+while( true )
+{
+ ( s.last() + 1.0 ) / 2.0 => gauge.value;
+ 20::ms => now;
+}
View
33 MAUI/examples/gauge02.ck
@@ -0,0 +1,33 @@
+// SIMPLE ENVELOPE FOLLOWER, by P. Cook
+// slight modifications and MAUI_Gauge addition by Spencer Salazar
+
+// change to adc, dac, or whatever
+adc @=> UGen source;
+// adjust as needed
+1000.0 => float scale;
+//adjust as needed
+20::ms => dur update_period;
+
+// patch
+source => Gain g => OnePole p => blackhole;
+// square the input
+source => g;
+// multiply
+3 => g.op;
+
+// set pole position
+0.9999 => p.pole;
+
+// create the gauge
+MAUI_Gauge gauge;
+// display it
+gauge.display();
+
+// loop forever
+while( true )
+{
+ // update gauge value
+ p.last() * scale => gauge.value;
+ // wait
+ update_period => now;
+}
View
48 MAUI/examples/led01.ck
@@ -0,0 +1,48 @@
+// led objects
+MAUI_LED a, b, c;
+
+// view object
+MAUI_View v;
+
+// set the view size
+v.size( 150, 50 );
+
+// initialize color, size position of first led
+a.color( a.red );
+a.size( 50, 50 );
+a.position( 0, 0 );
+
+// initialize color, size position of second led
+b.color( b.green );
+b.size( 50, 50 );
+b.position( 50, 0 );
+
+// initialize color, size position of third led
+c.color( c.blue );
+c.size( 50, 50 );
+c.position( 100, 0 );
+
+// add to view
+v.addElement( a );
+v.addElement( b );
+v.addElement( c );
+
+// display view
+v.display();
+
+while( true )
+{
+ // probabilistically light each led
+
+ if( maybe ) a.light();
+ else a.unlight();
+
+ if( maybe ) b.light();
+ else b.unlight();
+
+ if( maybe ) c.light();
+ else c.unlight();
+
+ // let time pass
+ .51::second => now;
+}
View
203 MAUI/examples/mand-o-ui.ck
@@ -0,0 +1,203 @@
+// name: mand-o-ui.ck
+// desc: STK mandolin demo using MAUI elements
+// (run in miniAudicle)
+//
+// author: Ge Wang (gewang@cs.princeton.edu)
+// Spencer Salazar (ssalazar@cs.princeton.edu)
+// Ananya Misra (amisra@cs.princeton.edu)
+
+
+// our patch
+Mandolin m => JCRev reverb => Gain master => dac;
+
+// set master gain
+.75 => master.gain;
+.1 => reverb.mix;
+
+// maui elements
+MAUI_View control_view;
+MAUI_LED on_led; MAUI_LED latch_led;
+MAUI_Button on_button; MAUI_Button latch;
+MAUI_Slider midi_note_slider;
+MAUI_Slider volume_slider;
+MAUI_Slider reverb_mix_slider;
+MAUI_Slider body_size_slider;
+MAUI_Slider pluck_pos_slider;
+MAUI_Slider damping_slider;
+MAUI_Slider detune_slider;
+
+// set view
+control_view.size( 400, 275 );
+control_view.name( "Real-time Mandolin Model" );
+
+// button (noteOn)
+on_button.pushType();
+on_button.size( 100, 80 );
+on_button.position( 0, 0 );
+on_button.name( "pluck!!" );
+control_view.addElement( on_button );
+
+// led
+on_led.size( 100, on_led.height() );
+on_led.position( 200, 8 );
+on_led.unlight();
+control_view.addElement( on_led );
+latch_led.size( 100, on_led.height() );
+latch_led.position( 300, 8 );
+latch_led.light();
+control_view.addElement( latch_led );
+
+// latch button
+latch.toggleType();
+latch.size( on_button.width(), on_button.height() );
+latch.position( on_button.x() + on_button.width(), on_button.y() );
+latch.name( "latch" );
+control_view.addElement( latch );
+
+// note
+midi_note_slider.range( 30, 127 );
+midi_note_slider.size( 200, midi_note_slider.height() );
+midi_note_slider.position( 0, 200 );
+midi_note_slider.value( 60 );
+midi_note_slider.name( "Note" );
+Std.mtof( midi_note_slider.value() ) => m.freq;
+control_view.addElement( midi_note_slider );
+
+// volume
+volume_slider.range( 0, 1 );
+volume_slider.size( 200, volume_slider.height() );
+volume_slider.position( 200, 200 );
+volume_slider.value( master.gain() );
+volume_slider.name( "Gain" );
+control_view.addElement( volume_slider );
+
+// body size
+body_size_slider.range( 0, 1 );
+body_size_slider.size( 200, body_size_slider.height() );
+body_size_slider.position( 0, 135 );
+body_size_slider.value( master.gain() );
+body_size_slider.name( "body size" );
+control_view.addElement( body_size_slider );
+
+// pluck pos
+pluck_pos_slider.range( 0, 1 );
+pluck_pos_slider.size( 200, volume_slider.height() );
+pluck_pos_slider.position( 200, 135 );
+pluck_pos_slider.value( master.gain() );
+pluck_pos_slider.name( "pluck position" );
+control_view.addElement( pluck_pos_slider );
+
+// damping
+damping_slider.range( 0, 1 );
+damping_slider.size( 200, volume_slider.height() );
+damping_slider.position( 0, 70 );
+damping_slider.value( master.gain() );
+damping_slider.name( "string damping" );
+control_view.addElement( damping_slider );
+
+// detune
+detune_slider.range( 0, 1 );
+detune_slider.size( 200, volume_slider.height() );
+detune_slider.position( 200, 70 );
+detune_slider.value( master.gain() );
+detune_slider.name( "string detune" );
+control_view.addElement( detune_slider );
+
+control_view.display();
+
+function void controlNoteOn()
+{
+ while( true )
+ {
+ // wait for the button to be pushed down
+ on_button => now;
+ on_led.light();
+ 1 => m.noteOn;
+
+ // wait for button to be released
+ on_button => now;
+ on_led.unlight();
+ }
+}
+
+function void controlLatch()
+{
+ while( true )
+ {
+ // wait for button to be pushed down
+ latch => now;
+ //on_led.light();
+ on_button.toggleType();
+
+ // wait for button to be pushed up
+ latch => now;
+ //on_led.unlight();
+ on_button.pushType();
+ }
+}
+
+function void controlMIDINote()
+{
+ while( true )
+ {
+ midi_note_slider => now;
+ Std.mtof( midi_note_slider.value() ) => m.freq;
+ }
+}
+
+function void controlGain()
+{
+ while( true )
+ {
+ volume_slider => now;
+ volume_slider.value() => master.gain;
+ }
+}
+
+function void controlBodySize()
+{
+ while( true )
+ {
+ body_size_slider => now;
+ body_size_slider.value() => m.bodySize;
+ }
+}
+
+function void controlPluckPos()
+{
+ while( true )
+ {
+ pluck_pos_slider => now;
+ pluck_pos_slider.value() => m.pluckPos;
+ }
+}
+
+function void controlDamping()
+{
+ while( true )
+ {
+ damping_slider => now;
+ damping_slider.value() => m.stringDamping;
+ }
+}
+
+function void controlDetune()
+{
+ while( true )
+ {
+ detune_slider => now;
+ detune_slider.value() => m.stringDetune;
+ }
+}
+
+spork ~ controlNoteOn();
+spork ~ controlLatch();
+spork ~ controlMIDINote();
+spork ~ controlGain();
+spork ~ controlBodySize();
+spork ~ controlPluckPos();
+spork ~ controlDamping();
+spork ~ controlDetune();
+
+while( true )
+ 1::day => now;
View
292 MAUI/examples/mode-o-ui.ck
@@ -0,0 +1,292 @@
+// name: mode-o-ui.ck
+// desc: modal bar demo using MAUI elements
+// (need miniAudicle)
+//
+// author: Ananya Misra (amisra@cs.princeton.edu)
+// Ge Wang (gewang@cs.princeton.edu)
+// Spencer Salazar (ssalazar@cs.princeton.edu)
+
+
+// our patch
+ModalBar m => JCRev reverb => Gain master => dac;
+
+// set master gain
+.75 => master.gain;
+.1 => reverb.mix;
+
+// maui elements
+MAUI_View control_view;
+MAUI_LED on_led;
+MAUI_Button on_button; MAUI_Button latch;
+MAUI_Slider midi_note_slider;
+MAUI_Slider volume_slider;
+MAUI_Slider reverb_mix_slider;
+MAUI_Slider strike_vigor_slider;
+MAUI_Slider strike_pos_slider;
+MAUI_Slider stick_hardness_slider;
+MAUI_Slider stick_mix_slider;
+
+// array of buttons
+MAUI_Button buttons[9];
+
+// set view
+control_view.size( 420, 450 );
+control_view.name( "Real-time ModalBar Model" );
+
+// button (noteOn)
+on_button.pushType();
+on_button.size( 125, 75 );
+on_button.position( 0, 0 );
+on_button.name( "on!!" );
+control_view.addElement( on_button );
+
+// led
+on_led.size( 100, on_led.height() );
+on_led.position( 215, 8 );
+on_led.unlight();
+control_view.addElement( on_led );
+
+// latch button
+latch.toggleType();
+latch.size( on_button.width(), on_button.height() );
+latch.position( on_button.x() + 100, on_button.y() );
+latch.name( "crash" );
+control_view.addElement( latch );
+
+// presets
+for( 0 => int b; b < 9; b++ )
+{
+ buttons[b].toggleType();
+ buttons[b].size( 125, 75 );
+}
+
+// position
+70 => int y;
+
+// marimba
+buttons[0].position( 0, y );
+buttons[0].name( "marimba" );
+control_view.addElement( buttons[0] );
+
+// vibraphone
+buttons[1].position( 100, y );
+buttons[1].name( "vibraphone" );
+control_view.addElement( buttons[1] );
+
+// agogo
+buttons[2].position( 200, y );
+buttons[2].name( "agogo" );
+control_view.addElement( buttons[2] );
+
+// wood1
+buttons[3].position( 300, y );
+buttons[3].name( "wood1" );
+control_view.addElement( buttons[3] );
+
+// change y
+50 +=> y;
+
+// reso
+buttons[4].position( 0, y );
+buttons[4].name( "reso" );
+control_view.addElement( buttons[4] );
+
+// wood2
+buttons[5].position( 100, y );
+buttons[5].name( "wood2" );
+control_view.addElement( buttons[5] );
+
+// beats
+buttons[6].position( 200, y );
+buttons[6].name( "beats" );
+control_view.addElement( buttons[6] );
+
+// clump
+buttons[8].position( 300, y );
+buttons[8].name( "clump" );
+control_view.addElement( buttons[8] );
+
+// two fixed
+buttons[7].position( 0, y + 50 );
+buttons[7].name( "two fixed" );
+control_view.addElement( buttons[7] );
+
+// note
+midi_note_slider.range( 30, 127 );
+midi_note_slider.size( 200, midi_note_slider.height() );
+midi_note_slider.position( 0, 370 );
+midi_note_slider.value( 60 );
+midi_note_slider.name( "Note" );
+Std.mtof( midi_note_slider.value() ) => m.freq;
+control_view.addElement( midi_note_slider );
+
+// sliders
+// volume
+volume_slider.range( 0, 1 );
+volume_slider.size( 200, volume_slider.height() );
+volume_slider.position( 200, 370 );
+volume_slider.value( master.gain() );
+volume_slider.name( "Gain" );
+control_view.addElement( volume_slider );
+
+// strike_vigor (strike)
+strike_vigor_slider.range( 0, 1 );
+strike_vigor_slider.size( 200, strike_vigor_slider.height() );
+strike_vigor_slider.position( 0, 305 );
+strike_vigor_slider.value( master.gain() );
+strike_vigor_slider.name( "strike vigor" );
+control_view.addElement( strike_vigor_slider );
+
+// strike pos
+strike_pos_slider.range( 0, 1 );
+strike_pos_slider.size( 200, strike_pos_slider.height() );
+strike_pos_slider.position( 200, 305 );
+strike_pos_slider.value( master.gain() );
+strike_pos_slider.name( "strike position" );
+control_view.addElement( strike_pos_slider );
+
+// stick hardness
+stick_hardness_slider.range( 0, 1 );
+stick_hardness_slider.size( 200, stick_hardness_slider.height() );
+stick_hardness_slider.position( 0, 240 );
+stick_hardness_slider.value( master.gain() );
+stick_hardness_slider.name( "stick hardness" );
+control_view.addElement( stick_hardness_slider );
+
+// stick mix (direct gain)
+stick_mix_slider.range( 0, 1 );
+stick_mix_slider.size( 200, stick_mix_slider.height() );
+stick_mix_slider.position( 200, 240 );
+stick_mix_slider.value( master.gain() );
+stick_mix_slider.name( "direct stick mix" );
+control_view.addElement( stick_mix_slider );
+
+control_view.display();
+
+function void controlNoteOn()
+{
+ while( true )
+ {
+ // wait for the button to be pushed down
+ on_button => now;
+ on_led.light();
+ 1 => m.noteOn;
+
+ // wait for button to be released
+ on_button => now;
+ on_led.unlight();
+ }
+}
+
+function void controlLatch()
+{
+ while( true )
+ {
+ // wait for button to be pushed down
+ latch => now;
+ //on_led.light();
+ on_button.toggleType();
+
+ // wait for button to be pushed up
+ latch => now;
+ //on_led.unlight();
+ on_button.pushType();
+
+ // secret call
+ Machine.crash();
+ }
+}
+
+function void controlButton( int index )
+{
+ while( true )
+ {
+ // wait for the button to be pushed down
+ buttons[index] => now;
+
+ // change preset
+ index => m.preset;
+
+ // change other buttons
+ for( 0 => int i; i < 9; i++ )
+ {
+ if( i != index )
+ {
+ // hack
+ buttons[i].pushType();
+ buttons[i].toggleType();
+ }
+ }
+
+ // wait for button to be released
+ buttons[index] => now;
+ }
+}
+
+function void controlMIDINote()
+{
+ while( true )
+ {
+ midi_note_slider => now;
+ Std.mtof( midi_note_slider.value() ) => m.freq;
+ }
+}
+
+function void controlGain()
+{
+ while( true )
+ {
+ volume_slider => now;
+ volume_slider.value() => master.gain;
+ }
+}
+
+function void controlStrikeVigor()
+{
+ while( true )
+ {
+ strike_vigor_slider => now;
+ strike_vigor_slider.value() => m.strike;
+ }
+}
+
+function void controlStrikePos()
+{
+ while( true )
+ {
+ strike_pos_slider => now;
+ strike_pos_slider.value() => m.strikePosition;
+ }
+}
+
+function void controlStickHardness()
+{
+ while( true )
+ {
+ stick_hardness_slider => now;
+ stick_hardness_slider.value() => m.stickHardness;
+ }
+}
+
+function void controlStickMix()
+{
+ while( true )
+ {
+ stick_mix_slider => now;
+ stick_mix_slider.value() => m.directGain;
+ }
+}
+
+spork ~ controlNoteOn();
+spork ~ controlLatch();
+spork ~ controlMIDINote();
+spork ~ controlGain();
+spork ~ controlStrikeVigor();
+spork ~ controlStrikePos();
+spork ~ controlStickHardness();
+spork ~ controlStickMix();
+for( 0 => int i; i < 9; i++ )
+ spork ~ controlButton( i );
+
+while( true )
+ 1::day => now;
View
14 MAUI/examples/slide01.ck
@@ -0,0 +1,14 @@
+MAUI_Slider slider;
+"param" => slider.name;
+slider.display();
+slider.range( 1, 127 );
+60 => slider.value;
+
+Blit s => dac;
+4 => s.harmonics;
+
+while( true )
+{
+ slider.value() => Std.mtof => s.freq;
+ 10::ms => now;
+}
View
24 MAUI/examples/slide02.ck
@@ -0,0 +1,24 @@
+// instantiate slider
+MAUI_Slider freq;
+"midi note" => freq.name;
+freq.display();
+freq.irange( 1, 127 );
+
+// instantiate 2nd slider
+MAUI_Slider harm;
+"harmonics" => harm.name;
+harm.display();
+harm.irange( 1, 40 );
+
+// our patch
+Blit s => dac;
+int last;
+
+// infinite time loop
+while( true )
+{
+ freq.value() => Std.mtof => s.freq;
+ if( harm.value() != last )
+ harm.value() $ int => last => s.harmonics;
+ 10::ms => now;
+}
View
16 MAUI/examples/slide03.ck
@@ -0,0 +1,16 @@
+MAUI_Slider freq;
+"midi note" => freq.name;
+freq.display();
+freq.range( 1, 127 );
+
+Blit s => dac;
+4 => s.harmonics;
+freq.value() => Std.mtof => s.freq;
+
+while( true )
+{
+ // wait on change
+ freq => now;
+ // control
+ freq.value() => Std.mtof => s.freq;
+}
View
104 MAUI/examples/view01.ck
@@ -0,0 +1,104 @@
+PercFlut flute => JCRev reverb => Gain master => dac;
+
+0 => master.gain;
+0 => master.op;
+
+MAUI_View control_view;
+MAUI_LED on_led, latch_led;
+MAUI_Button on_button, latch;
+MAUI_Slider midi_note_slider, volume_slider, reverb_mix_slider;
+
+control_view.size( 200, 325 );
+
+on_button.pushType();
+on_button.size( 100, 100 );
+on_button.position( 0, 0 );
+on_button.name( "noteOn" );
+control_view.addElement( on_button );
+
+on_led.size( 100, on_led.height() );
+on_led.position( 0, on_button.x() + on_button.height() + 1);
+on_led.color( MAUI_LED.blue );
+control_view.addElement( on_led );
+
+latch.toggleType();
+latch.size( on_button.width(), on_button.height() );
+latch.position( on_button.x() + on_button.width(), on_button.y() );
+latch.name( "latch" );
+control_view.addElement( latch );
+
+midi_note_slider.range( 0, 127 );
+midi_note_slider.size( 200, midi_note_slider.height() );
+midi_note_slider.position( 0, on_led.height() + on_led.y() );
+midi_note_slider.value( 60 );
+midi_note_slider.name( "MIDI Note" );
+midi_note_slider.displayFormat( MAUI_Slider.integerFormat );
+Std.mtof( midi_note_slider.value() ) => flute.freq;
+control_view.addElement( midi_note_slider );
+
+volume_slider.range( 0, 1 );
+volume_slider.size( 200, volume_slider.height() );
+volume_slider.position( 0, midi_note_slider.height() + midi_note_slider.y() );
+volume_slider.value( master.gain() );
+volume_slider.name( "Gain" );
+control_view.addElement( volume_slider );
+
+control_view.display();
+
+function void controlNoteOn()
+{
+ while( true )
+ {
+ // wait for the button to be pushed down
+ on_button => now;
+ on_led.light();
+ 1 => master.op;
+
+ // wait for button to be released
+ on_button => now;
+ on_led.unlight();
+ 0 => master.op;
+ }
+}
+
+function void controlLatch()
+{
+ while( true )
+ {
+ // wait for button to be pushed down
+ latch => now;
+ //on_led.light();
+ on_button.toggleType();
+
+ // wait for button to be pushed up
+ latch => now;
+ //on_led.unlight();
+ on_button.pushType();
+ }
+}
+
+function void controlMIDINote()
+{
+ while( true )
+ {
+ midi_note_slider => now;
+ Std.mtof( midi_note_slider.value() ) => flute.freq;
+ }
+}
+
+function void controlGain()
+{
+ while( true )
+ {
+ volume_slider => now;
+ volume_slider.value() => master.gain;
+ }
+}
+
+spork ~ controlNoteOn();
+spork ~ controlLatch();
+spork ~ controlMIDINote();
+spork ~ controlGain();
+
+while( true )
+ 1::day => now;
Please sign in to comment.
Something went wrong with that request. Please try again.