For discussion about setting up your studio and advice on the gear and equipment within it.
By dtaa pla muk Tue Apr 02, 2013 3:52 am
tapedeck wrote:http://chuck.cs.princeton.edu/
http://audicle.cs.princeton.edu/mini/ <-to start with

chuck is basically a programming language based on music / dsp concepts and very very rigidly tied to sample rate (that makes it very handy). i use it mostly when i want to give the machine more of a chance to sing instead of telling it what i think i want it to do....

...the cool thing about chuck is you can run it via terminal once you've written the program so it integrates into your computer, basically transforming it to do whatever you want, very smoothly.



tapedeck brought this up in another thread. i'd never heard of it. gonna be looking into it for sure.

tapedeck, how does this handle midi inputs/outputs? can you describe some of the ways you've implemented it?

edit: so far this is excitingly straightforward
User avatar
By tapedeck Tue Apr 02, 2013 2:30 pm
the best thing i can tell you about midi ins/outs is to find the example files that deal with midi and repurpose them how you need. they are basic enough that it should be easy to do.
http://chuck.cs.princeton.edu/doc/examples/

you'll basically find the port, wrap it in an object, and then manipulate that object.

i'll try to break this down...
the first line is a comment, anything preceded by '//' is a comment explaining to you in english what is going on.
so it says, use chuck --probe in the terminal to find your midi ports.
then you choose which port in your code (0 in this case).
the next line means you can pass in the midi device as an argument when you run the code from command line (terminal / dos / whatever).
then you name the midi-in object ('min') so you can reference it later.
then you give a name for the message it will send ('msg').
open the device (aka turn it on).
print out the opening of the device for some feedback that it actually happened.
set up a loop to run infinitely... (while(true))
wait until a message is received from midi port.
print out the midi message and return to the top of the loop to wait for the next message.
example:
Code: Select all// number of the device to open (see: chuck --probe)
0 => int device;
// get command line
if( me.args() ) me.arg(0) => Std.atoi => device;

// the midi event
MidiIn min;
// the message for retrieving data
MidiMsg msg;

// open the device
if( !min.open( device ) ) me.exit();

// print out device that was opened
<<< "MIDI device:", min.num(), " -> ", min.name() >>>;

// infinite time-loop
while( true )
{
    // wait on the event 'min'
    min => now;

    // get the message(s)
    while( min.recv(msg) )
    {
        // print out midi message
        <<< msg.data1, msg.data2, msg.data3 >>>;
    }
}


this is a VERY basic example and doesn't actually do anything with the midi message other than display it on screen, so you'd either need to find more examples to handle the messages, or write your own.
midi out will of course be slightly different (man pg. 23), but this was easy enough to break down line by line.

you could use the above code to interpret some midi messages and then try to create your own from what you learn.
User avatar
By tapedeck Tue Apr 02, 2013 4:17 pm
you'll need to check the midi input coming from the host - i think midiclock runs 24 ticks per quarter note?

so that code posted above should give you an example of the kind of message you will receive.

though i'm getting a little lost now because at first i thought you were trying to send midi notes, now you are talking about receiving midi clock.
i'm sure you can still do it but that will take a bit more doing to get it done.
i wonder if you cant write some sort of macro in reaper to send a midi control change, and then use that to interpret the tempo in chuck?
basically hack a control change to send the tempo as an integer value, then use that in chuck.

just a thought.
By dtaa pla muk Tue Apr 02, 2013 4:26 pm
though i'm getting a little lost now because at first i thought you were trying to send midi notes, now you are talking about receiving midi clock.


both. it's got to stay in time with the tempo from reaper. each note sent to chuck via launchpad triggers a cycle of notes (note++) through a range (say note 0 was struck: range = 0 thru 15 or 0 thru 32) and then repeats. as the master tempo speeds up, for example, the ++ must occur at a faster pace to keep in time.

whether or not chuck can address this particular issue, it will definitely solve something else
User avatar
By tapedeck Tue Apr 02, 2013 4:44 pm
it can definitely solve that particular issue - just might take more work on your part :mrgreen:

but again the beauty of hacking this low-level is you can define your own conventions.

depending on how fast your tempo is changing, you've got options.

remind me again are you on mac windows linux?
By dtaa pla muk Tue Apr 02, 2013 5:00 pm
win. i can send tempo info (clock, mtc) from reaper to chuck using loopbe easy enough. i could also just send a CC value to trigger a certain tempo in chuck

it looks like chuck does some nice things to prevent us having to interpret hexadecimals, which i appreciate