<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>tag:www.local-guru.net,2005:/blog/tag/chuck</id>
  <link type="text/html" href="http://www.local-guru.net" rel="alternate"/>
  <link type="application/atom+xml" href="http://www.local-guru.net/blog/tag/chuck.atom" rel="self"/>
  <title>GuruBlog : Articles about chuck</title>
  <subtitle>local-guru.net</subtitle>
  <updated>2009-01-20T05:29:00+01:00</updated>
  <generator>GuruBlog engine</generator>
  <entry>
    <id>tag:www.local-guru.net,2005:Article/105</id>
    <published>2009-01-20T05:29:00+01:00</published>
    <updated>2009-01-20T05:29:00+01:00</updated>
    <link type="text/html" href="http://www.local-guru.net//blog/2009/1/20/osc-sequencer-in-ruby" rel="alternate"/>
    <author>
      <name>Nikolaus Gradwohl</name>
    </author>
    <title type="html">osc sequencer in ruby</title>
    <category term="ruby" scheme="http://www.local-guru.net/blog/tag/ruby"/>
    <category term="osc" scheme="http://www.local-guru.net/blog/tag/osc"/>
    <category term="chuck" scheme="http://www.local-guru.net/blog/tag/chuck"/>
    <content type="html">&lt;p&gt;I wrote a simple osc sequencer in ruby using &lt;a href="http://hans.fugal.net/src/rosc/"&gt;rosc&lt;/a&gt;. The script triggers the &lt;a href="http://www.local-guru.net/blog/2009/01/17/modularizing-chuck-files"&gt;drum-kit and the bass&lt;/a&gt; i implemented
last week.&lt;/p&gt;

&lt;p&gt;the pattern may also be of different length. This allows very interesting polyrythmic loops.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require 'osc'
Host = 'localhost'
Port = 3334

c = OSC::UDPSocket.new
hh = OSC::Message.new('/drum', 's', "hh" )
bd = OSC::Message.new('/drum', 's', "bd" )
sn = OSC::Message.new('/drum', 's', "sn" )

ba = OSC::Message.new('/bass', 'i', 64 )


#c.send sn, 0, Host, Port
bpm = 120
step = 1.0/8;
s = bpm * step / 60.0 ;

snd = [ bd, sn, hh ]
pattern = [
[1, 0, 0, 1, 0, 1, 0, 0 ],
[0, 0, 1, 0, 0, 0, 1, 1 ],
[1, 1, 1, 1, 1, 1, 1, 1 ]
]
bass = [
40, 40, 0, 40, 40, 0, 43, 0,
40, 40, 0, 40, 40, 0, 38, 0 ]

count = 0;
while(true)
    (0..2).each { |i|
        c.send(snd[i], 0, Host, Port) if pattern[i][count % pattern[i].length] == 1
    }

    ba.args = [bass[ count % bass.length]]
    c.send( ba, 0, Host, Port ) if bass[ count % bass.length ] != 0

    sleep s
    count+=1
end
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  <entry>
    <id>tag:www.local-guru.net,2005:Article/103</id>
    <published>2009-01-17T13:11:00+01:00</published>
    <updated>2009-01-17T13:11:00+01:00</updated>
    <link type="text/html" href="http://www.local-guru.net//blog/2009/1/17/modularizing-chuck-files" rel="alternate"/>
    <author>
      <name>Nikolaus Gradwohl</name>
    </author>
    <title type="html">modularizing chuck files</title>
    <category term="chuck" scheme="http://www.local-guru.net/blog/tag/chuck"/>
    <content type="html">&lt;p&gt;I wrote a simple chuck script that generates a drum loop and a bass-sequence. later i wanted to reuse
the sounds and started to search how to modularize the code.&lt;/p&gt;

&lt;p&gt;so i started to convert my instrument declarations in classes. The instrument classes don't get connected
to 'dac' directly. They have a "connect"-method that can be used by the main script.&lt;/p&gt;

&lt;p&gt;to run the loop all the scripts must be given on the commandline&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;chuck Bass.ck DrumSet.ck loop.ck
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The main script (loop.ck) instanciates a DrumSet and a Bass class and connects them to "dac". Than
it generates a walking bass and a simple electronic drum loop.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;DrumSet drm;
drm.connect( dac );

Bass bass;
bass.connect( dac );

[ 41, 41, 44, 46] @=&amp;gt; int bline[];
0 =&amp;gt; int pos;
0 =&amp;gt; int count;

while ( true ) {
    drm.hh();
    if ( count % 2 == 0 ) { drm.bd(); }
    if ( count % 4 == 2 ) { drm.sn(); }

    if ( count % 2 == 0 ) { spork ~ bass.bass( bline[ pos % 4 ]); }
    if ( count % 2 == 1 ) { spork ~ bass.bass( 12 + bline[ pos % 4 ]); }


    1 + count =&amp;gt; count;
    if ( count % 4 == 0 ) { 1 + pos =&amp;gt; pos; }
    250::ms =&amp;gt; now;
}
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  <entry>
    <id>tag:www.local-guru.net,2005:Article/51</id>
    <published>2008-07-14T06:46:00+02:00</published>
    <updated>2008-07-14T06:46:00+02:00</updated>
    <link type="text/html" href="http://www.local-guru.net//blog/2008/7/14/chuck-icontrol-projectpage" rel="alternate"/>
    <author>
      <name>Nikolaus Gradwohl</name>
    </author>
    <title type="html">Chuck iControl Projectpage</title>
    <category term="osc" scheme="http://www.local-guru.net/blog/tag/osc"/>
    <category term="chuck" scheme="http://www.local-guru.net/blog/tag/chuck"/>
    <category term="icontrol" scheme="http://www.local-guru.net/blog/tag/icontrol"/>
    <category term="midi" scheme="http://www.local-guru.net/blog/tag/midi"/>
    <content type="html">&lt;p&gt;as written &lt;a href="http://www.local-guru.net/blog/articles/2008/05/22/chuck-icontrol"&gt;before&lt;/a&gt;,
i have started writing a chuck script that mapps the
midi-data from my iControl to OSC events. I now have set up a proper
&lt;a href="/blog/pages/chuckicontrol"&gt;project page&lt;/a&gt; for the script.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <id>tag:www.local-guru.net,2005:Article/34</id>
    <published>2008-05-22T18:04:00+02:00</published>
    <updated>2008-05-22T18:04:00+02:00</updated>
    <link type="text/html" href="http://www.local-guru.net//blog/2008/5/22/chuck-icontrol" rel="alternate"/>
    <author>
      <name>Nikolaus Gradwohl</name>
    </author>
    <title type="html">chuck icontrol</title>
    <category term="osc" scheme="http://www.local-guru.net/blog/tag/osc"/>
    <category term="chuck" scheme="http://www.local-guru.net/blog/tag/chuck"/>
    <category term="icontrol" scheme="http://www.local-guru.net/blog/tag/icontrol"/>
    <content type="html">&lt;p&gt;I own a &lt;a href="http://createdigitalmusic.com/2005/04/08/m-audio-icontrol-new-hardware-for-garageband-analyzed/"&gt;m-audio icontrol&lt;/a&gt; and some time ago i started to play with
&lt;a href="http://chuck.cs.princeton.edu/"&gt;chuck&lt;/a&gt; a programming language for making electronic music. today
i managed to link them together and use my icontrol to start and stop
my chuck programms :-)&lt;/p&gt;

&lt;p&gt;next thing i will try is to convert the values from the "endless"-knobs to floats
and to pass messages to the sub programms&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;1 =&amp;gt; int device;

MidiIn min;
MidiOut mout;
MidiMsg msg;

// open the device
if( !min.open( device ) ) me.exit();
if( !mout.open( device ) ) me.exit();
[0,0,0,0,0,0,0,0] @=&amp;gt; int on[];
[-1, -1, -1, -1, -1, -1, -1, -1] @=&amp;gt; int ids[];
["beep.ck", "sing.ck", "autoloop.ck", "", "", "", "", "" ] @=&amp;gt; string names[];
while ( true ) {
    min =&amp;gt; now;

    // get the message(s)
    while( min.recv(msg) ) {
        // print out midi message
        &amp;lt;&amp;lt;&amp;lt; msg.data1, msg.data2, msg.data3 &amp;gt;&amp;gt;&amp;gt;;

        if ( msg.data1 == 176 &amp;amp;&amp;amp; msg.data2 &amp;gt;= 64 &amp;amp;&amp;amp; msg.data2 &amp;lt; 72 &amp;amp;&amp;amp; msg.data3 == 127 ) {
            msg.data2 - 64 =&amp;gt; int chan;
            if ( on[chan] == 1 ) {
                0 =&amp;gt; on[chan];
                sendOff( chan );
                if (ids[chan] &amp;gt; 0) {
                    Machine.remove( ids[ chan ] )
                        -1 =&amp;gt; ids[chan];
                    }
                } else {
                    1 =&amp;gt; on[chan];
                    sendOn( chan );
                    if ( names[chan] != "" ) {
                        Machine.add( names[chan] ) =&amp;gt; ids[chan];
                    }
                }
            }
            // send( msg.data1, msg.data2, msg.data3 );
        }
    }

    fun void sendOn( int chan ) {
    send( 176, 64 + chan , 127 );
    }

    fun void sendOff( int chan ) {
    send( 176, 64 + chan, 0 );
    }

    fun void send( int d1, int d2, int d3 ) {
        MidiMsg msg;
    d1 =&amp;gt; msg.data1;
    d2 =&amp;gt; msg.data2;
    d3 =&amp;gt; msg.data3;
    mout.send( msg );
    }
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
</feed>

