Monday, June 11, 2012

Processing and OSC and ChucK

I just found this web site:
http://visiblearea.com/blog/Processing_and_ChucK

that looks helpful in connecting code written in ChucK with code written in Processing, which makes animations, etc Processing is open source, written in Java, and friendlier

UPDATE:  Julia and I spent today working on Processing => OSC => ChucK.  We ran into some problems we needed to figure out:

ChuckFilePlayDemo and ChuckHelloWorld would run successfully once and the second time we lost sound.  There was an if statement in the monitor.ck file that included kill commands for three different systems.  After commenting out everything but the killall -c chuck command for MacOS, the ChuckFilePlayDemo file worked fine on each successive play with sound and killed all running instances.  However, the ChuckHelloWorld demo did not terminate after hitting the stop button in Processing.

The error message was TCP IP cannot bind to port 8888.  We learned this meant there was another socket trying to access port 8888, and was preventing the second play.  We typed "netstat -tan | grep 8888" into the command line of terminal and it showed several lines followed with CLOSE_WAIT.  This meant that the command to finish that was sent from Processing did not completely close out the connection.  We could not figure out what was different between the ChuckFilePlayDemo.pde that was now running successfully and ChuckHelloWorld.pde, because we made the same changes to monitor.ck.

Tonight I tried again and ChuckHelloWorld.pde does stop and clears out any TCP IP connections in terminal so there is only one LISTEN, however, there is one residual tone that plays continuously.  When I run the ChuckHelloWorld.pde again, it does not override the tone.  The tone is in the background of the subsequent call to ChuckHellowWorld.

We then met to work on a design based off of this code to create a visualization of rain based on the amount of amplitude received through the adc connected to an external microphone.


OSC for Java

So I'm working on creating the interactive/responsive animation for the hallway, and I've hit a few roadblocks. Can anyone help me figure this out?

javaOSC:

I downloaded the javaOSC folder from this site: http://www.illposed.com/software/javaosc.html. I added it to the package I'm working on, but the program isn't recognizing any of the classes. Anyone have any idea how to make it recognize the class names from the OSC download?

Making ChucK send the amplitude:

Jan sent me a great link which has some code, but I'm just kind of sitting here scratching my head as I try to figure out how it works. Help? (Here is the code: http://electro-music.com/forum/post-260184.html)

Java animation:

Is it just like animation in Python? Have a dy/dx and update the canvas with a small shift in location for each object?

Music theory for musicians

I decided not to make a powerpoint about music theory for musicians because it's such a widely covered topic already. Instead, I found some easy to use online resources that probably explain things better than I could. Most of these resources cover the systems that western music traditionally uses to write and play music (musical staves, types of notes, chords, harmony, etc).

http://www.musictheory.net/lessons
This site has excellent coverage of basic through intermediate/lower advanced topics of music theory. It lets you go through the lessons at your own pace and has exercises to test your knowledge too. However, if you're looking for a very quick summary, it may not be the best.

Here's a much more in-depth document that explains how notes relate to each other and how scales are constructed:
http://www.gospelmusic.org.uk/resources/cowpielessons.pdf

A very simply written summary of the basics:
http://datadragon.com/education/reading/

The Wikipedia page on music theory. Not very good as a learning tool, but not bad as a reference.
http://en.wikipedia.org/wiki/Music_theory


Digital to Audio Conversion and Intro to Synthesis Powerpoint

This is the powerpoint I spent most of last week researching for. I think it can be improved upon/added to, so please leave any thoughts/comments you have!!

I was planning on doing Wavetables in this powerpoint, but I quickly realized that wavetables make much more sense when one knows the basics of music synthesis. So the next powerpoint will be on wavetables... or at least, that is once again the plan.






Friday, June 8, 2012

The DOHboard

The original file can be found in the keyboard folder within the SMELT download.

Here's the altered file:


/*----------------------------------------------------------------------------
    S.M.E.L.T. : Small Musically Expressive Laptop Toolkit

    Copyright (c) 2007 Rebecca Fiebrink and Ge Wang.  All rights reserved.
      http://smelt.cs.princeton.edu/
      http://soundlab.cs.princeton.edu/

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
    U.S.A.
-----------------------------------------------------------------------------*/

//-----------------------------------------------------------------------------
// name: kb-fret.ck
// desc: this program attempts to open a keyboard; maps key-down events to
//       pitches via a fretboard-like mapping.
//
// authors: Rebecca Fiebrink and Ge Wang
// adapted from Crystalis and Joy of Chant
//
// to run (in command line chuck):
//     %> chuck kb-fret.ck
//
// to run (in miniAudicle):
//     (make sure VM is started, add the thing)
//-----------------------------------------------------------------------------

// base and register
12 => int base;
3 => int register;
0 => int reg_change;

// keyboard
HidIn kb;
// hid message
HidMsg msg;

// If the keyboard is not available, just exit the program right away
if( !kb.openKeyboard( 0 ) ) me.exit();
//Otherwise, assuming the program didn't exit on the last line, keep going
<<< "Ready?", "" >>>;

// sound synthesis
SndBuf bar => JCRev r => dac;
"special:dope" => bar.read;
0 => bar.gain;
// set mix
.1 => r.mix;
// bar settings
//4 => bar.preset;

// key map
int key[256];
// key and pitch
0 => key[23];
1 => key[27];
2 => key[6];
3 => key[25];
4 => key[5];
5 => key[4] => key[17];
6 => key[22] => key[16];
7 => key[7] => key[54];
8 => key[9] => key[55];
9 => key[10] => key[56];
10 => key[20] => key[11];
11 => key[26] => key[13];
12 => key[8] => key[14];
13 => key[21] => key[15];
14 => key[23] => key[51];
15 => key[28] => key[52];
16 => key[24];
17 => key[12];
18 => key[18];
19 => key[19];
20 => key[47];
21 => key[48];
22 => key[49];
// which key is current
0 => int current;

// yes
fun void registerUp()
{
    if( register < 6 ) { register++; 1 => reg_change; }
    <<< "register:", register >>>;
}

// yes
fun void registerDown()
{
    if( register > 0 ) { register--; 1 => reg_change; }
    <<< "register:", register >>>;
}

float freq;

// infinite event loop
while( true )
{
    // wait for event
    kb => now;

    // get message
    while( kb.recv( msg ) )
    {
        // which
        if( msg.which > 256 ) continue;
        if( key[msg.which] == 0 && msg.which != 29 )
        {
            // register
            if( msg.which == 80 && msg.isButtonDown() )
                registerDown();
            else if( msg.which == 79 && msg.isButtonDown() )
                registerUp();
        }
        // set
        else if( msg.isButtonDown() )
        {
            // freq
            //base + register * 12 + key[msg.which] => Std.mtof => bar.freq;
            base + register * 12 + key[msg.which] - 80 => Std.mtof => bar.freq;
            // fire!
            Std.rand2f(.4,.6) => bar.gain;
            0 => bar.pos;
            // go
    10::ms => now;
              }
    }
}

NETWORK SUCCESS!!!!

Successful network connection through OSC to play sounds generated from transmitting computer to receiving computer.  Lucy configured the iMac to communicate with chucK on her laptop and Julia's laptop, and shreds launched on the iMac played on their laptops.  Necessary code is below:

HALLWAY ChucK

Create a set up in hallway that will record noise and show a graphical representation on the computer screen.


  • Connect microphone to computer and show waveform changes as person makes sound
  • Connect microphone to computer and alter sound input 
  • Use webcam to create sounds based on user movement/gestures