I found this wiki page on MultiGrain Granular Synthesis with ChucK. It includes code, however the example audio files aren't working on my computer right now:
https://ccrma.stanford.edu/wiki/MultiGrain_Granular_Synthesis_in_Chuck
This might be a good place to start exploring with Granular Synthesis in ChucK. It seems to me that we could very easily add to/alter the code to manipulate the synthesis.
Judy, let me know what you think, and if this is on the right track...
-Julia
Friday, June 29, 2012
Thursday, June 28, 2012
ICAD June 2012 ChucK Workshop
SonifyingInChucKICAD2012.pdf
This is the printout from the ChucK Workshop held recently with Perry Cook. ICAD was held in Atlanta on June 18-21, 2012.
Foundations of On-The-Fly Programming in the ChucK Programming Language
This paper written by Rebecca Fiebrink, Ge Wang, Perry Cook 2008.
ABSTRACT excerpt:
"We present three case studies of applying learning in real-time to performance tasks in ChucK, and we propose that fusing learning abilities with ChucK's real-time, on-the-fly aesthetic suggests exciting new ways of using and interacting with learning algorithms in live computer music performance."
More papers at http://smirk.cs.princeton.edu/
This is the printout from the ChucK Workshop held recently with Perry Cook. ICAD was held in Atlanta on June 18-21, 2012.
Foundations of On-The-Fly Programming in the ChucK Programming Language
This paper written by Rebecca Fiebrink, Ge Wang, Perry Cook 2008.
ABSTRACT excerpt:
"We present three case studies of applying learning in real-time to performance tasks in ChucK, and we propose that fusing learning abilities with ChucK's real-time, on-the-fly aesthetic suggests exciting new ways of using and interacting with learning algorithms in live computer music performance."
More papers at http://smirk.cs.princeton.edu/
Wednesday, June 27, 2012
EXERCISE - On the Fly
I uploaded a PDF of an "evolving" exercise I created for On The Fly Synchronization project using the example files OTF_01 to _07.ck files in the examples directory.
Click here to see a PDF of the On-The-Fly Exercise
Click here to see a PDF of the On-The-Fly Exercise
A mapping to the keyboard tutorial
// not a full "lab" per se but it does have the possibility to be developed into one. This is based on my experience working with the KIns.
To get ChucK working with the keyboard, there are a few essential things to include in your code:
1.
// keyboard
To get ChucK working with the keyboard, there are a few essential things to include in your code:
1.
// keyboard
HidIn kb;
// hid message
HidMsg msg;
In the above code, "Hid" stands for "Human Interface (possibly also input?) Device." AKA a device that you use to interact with your computer, like the keyboard. The first line defines the variable that will represent the HID, and the second defines the variable that will hold the information we receive from the HID.
2.
// 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?", "" >>>;
These lines are not critical, but helpful to include in a file, especially for debugging purposes. Obviously you can change them around to suit your tastes, such as only printing out a message if the keyboard *doesn't* open instead of if it does.
3.
// wait for event
kb => now;
The above lines go inside the event loop, which is the (usually infinite) loop that makes the program run. They'll probably be the first thing inside the loop, unless your program has a reason for them not to be. Basically they pause the loop until the HID has a message to send.
4.
kb.recv( msg )
When this function returns true, a key is being held down. It's probably best used in a while loop or if statement, such as while( kb.recv( msg ) ){....} That will execute the body of the loop as long as a key is being held down.
5. msg.which
The value of this variable contains an int that corresponds to the key that's being held down. Operators like ==, >, <, != can be used to work with it to assign different actions to different keys.
These are the most important things to understand when working with keyboard input. Using them, you can construct an array of values of the keys on your keyboard that correspond to meaningful values. For example, to make a program that plays notes when the keyboard is pressed, you could make an array in which the index of the array is the frequency of the note, and the data that corresponds to any given index is the key mapping integer.
How can we find out the key mapping integers if we don't know them or have a reference though? An easy, if tedious, way to do it is to simply print out msg.which whenever a keypress event is received. You can then write your own table by going through each key on your keyboard.
Oscillators, Harmonics and Wavelength Resource
Oscillators, Harmonics and Wavelength Explained Simply
The Synth School website is now closed and "under construction" but this video survived on YouTube. It's a very basic and clear explanation with great animations to show how to create saw and square waves from the original sine wave. Video: 10 minutes.
Tuesday, June 19, 2012
OSC Update
Update on the Hallway Project - June 19, 2012.
Thursday, June 14, 2012
Kins Project Progress
//piano patch
//clarinet patch
Clarinet clarin => JCRev c => dac;
0 => c.gain;
.1 => c.mix;
//flute patch
//organ patch
BeeThree org => JCRev o => Echo e => Echo e2 => dac;
o => dac;
// set delays
240::ms => e.max => e.delay;
480::ms => e2.max => e2.delay;
// set gains
//.6 => e.gain;
//.3 => e2.gain;
0 => o.gain;
0 => e.gain;
0 => e2.gain;
.05 => o.mix;
//brass patch
MAUI_View view;
view.name("Kins 2012");
MAUI_Button piano, clarinet, flute, organ, brass;
MAUI_LED lpiano, lclarinet, lflute, lorgan, lbrass;
MAUI_Slider volume;
view.size(500,250);
piano.pushType();
piano.size(100,100);
piano.position(0,0);
piano.name("piano");
view.addElement(piano);
clarinet.pushType();
clarinet.size(100,100);
clarinet.position(piano.x()+piano.width(),piano.y());
clarinet.name("clarinet");
view.addElement(clarinet);
flute.pushType();
flute.size(100,100);
flute.position(clarinet.x()+clarinet.width(),clarinet.y());
flute.name("flute");
view.addElement(flute);
organ.pushType();
organ.size(100,100);
organ.position(flute.x()+flute.width(),flute.y());
organ.name("organ");
view.addElement(organ);
brass.pushType();
brass.size(100,100);
brass.position(organ.x()+organ.width(),organ.y());
brass.name("brass");
view.addElement(brass);
lpiano.color(lpiano.blue);
lpiano.size(50,50);
lpiano.position(25,75);
lpiano.light();
view.addElement(lpiano);
lclarinet.color(lclarinet.blue);
lclarinet.size(50,50);
lclarinet.position(lpiano.x()+100, lpiano.y());
lclarinet.light();
view.addElement(lclarinet);
lflute.color(lflute.blue);
lflute.size(50,50);
lflute.position(lclarinet.x()+100,lclarinet.y());
lflute.light();
view.addElement(lflute);
lorgan.color(lorgan.blue);
lorgan.size(50,50);
lorgan.position(lflute.x()+100,lflute.y());
lorgan.light();
view.addElement(lorgan);
lbrass.color(lbrass.blue);
lbrass.size(50,50);
lbrass.position(lorgan.x()+100,lorgan.y());
lbrass.light();
view.addElement(lbrass);
volume.range(0,5);
volume.position (0,125);
volume.size(500,volume.height());
volume.name("Volume");
view.addElement(volume);
view.display();
[lpiano, lclarinet, lflute, lorgan, lbrass] @=>MAUI_LED leds[];
[622, 659, 698, 739, 783, 830,880, 932, 987, 1046, 1479,1567,1244,
349, 493, 174, 369, 415, 554, 440, 220, 311, 329, 1661, 1760,1864,
138,391,164,184,195,207,233,246,261,2093,2217,1108,587,523,155,466,146,293,277,2489,2637,2793,
61101016] @=>int keys[];
[131,139,156,165,185,208,233,247,277,311,330,370,415,
131,147,165,175,196,220,247,262,294,330,349,392,440,
523,554,622,659,740,831,932,988,69,78,82,93,
523,587,659,698,784,880,988,65,73,82,87] @=>int pitch[];
int ip, ic, ifl, io, ib;
function void volumeControl(){
while (true){
volume => now;
if (ip == 1){
<<<"volume">>>;
}
else if (ic == 1){
volume.value() => c.gain;
}
else if (ifl == 1){
}
else if (io == 1){
volume.value() => org.gain;
}
else if (ib == 1){
}
else{
}
}
}
function void ledControl(MAUI_LED led){
for (0=>int i; i<leds.cap(); i++){
leds[i].color(leds[i].blue);
leds[i].light();
}
led.color(led.green);
led.light();
}
function void allinstrumentsControl(){
while (true){
if (ic == 1){
clarinetSounds();
}
if (io == 1){
organSounds();
}
}
/* if (piano.state() == 0 || clarinet.state() == 0){
while (true){
<<< piano.state(), clarinet.state(), flute.state(),
organ.state(), brass.state()>>>;
if (piano.state() == 1){
pianoControl();
}
else if (clarinet.state() == 1){
clarinetControl();
}
else if (flute.state() == 1){
fluteControl();
}
else if (organ.state() == 1){
organControl();
}
else if (brass.state() == 1){
brassControl();
}
else {
}
}
}*/
}
function void pianoControl(){
while (true){
piano => now;
if (piano.state() == 1){
ledControl(lpiano);
1=>ip;
0=>ic=>ifl=>io=>ib;
<<< ip, ic, ifl, io, ib>>>;
}
}
}
function void clarinetControl(){
while (true){
clarinet => now;
if (clarinet.state() == 1){
ledControl(lclarinet);
1=>ic;
0=>ip=>ifl=>io=>ib;
<<< ip, ic, ifl, io, ib>>>;
//clarinetSounds();
}
}
}
function void fluteControl(){
while (true){
flute => now;
if (flute.state() == 1){
ledControl(lflute);
1=>ifl;
0=>ip=>ic=>io=>ib;
<<< ip, ic, ifl, io, ib>>>;
}
}
}
function void organControl(){
while (true){
organ => now;
if (organ.state() == 1){
ledControl(lorgan);
1=>io;
0=>ip=>ic=>ifl=>ib;
<<< ip, ic, ifl, io, ib>>>;
}
}
}
function void brassControl(){
while (true){
brass => now;
if (brass.state() == 1){
ledControl(lbrass);
1=>ib;
0=>ip=>ic=>ifl=>io;
<<< ip, ic, ifl, io, ib>>>;
}
}
}
function void pianoSounds(){
}
function void clarinetSounds(){
// HID
Hid hi;
HidMsg msg;
// which keyboard
0 => int device;
// get from command line
if( me.args() ) me.arg(0) => Std.atoi => device;
// open keyboard (get device number from command line)
if( !hi.openKeyboard( device ) ) me.exit();
<<< "keyboard '" + hi.name() + "' ready", "" >>>;
// infinite event loop (the if was a while)
while (true){
// wait for event
hi => now;
// get message
while ( hi.recv( msg ) ) {
if( msg.isButtonDown() && ic == 1) {
//0.75 => c.gain;
volume.value() => c.gain;
clarin.clear(1.0);
1 => clarin.reed;
Std.rand2f(0,1) => clarin.noiseGain;
Std.rand2f(0,12) => clarin.vibratoFreq;
Std.rand2f(0,1) => clarin.vibratoGain;
Std.rand2f(0,1)=> clarin.pressure;
// Std.mtof( msg.which + 45 ) => float freq;
Std.mtof( msg.which+45) => float freq;
freq $ int => int ifreq;
<<< "Frequency: " + freq + " " + ifreq>>>;
if( ifreq > 20000 ) continue;
for (0=>int i; i<keys.cap(); i++){
if (ifreq == keys[i]){
pitch[i] => clarin.freq;
1 => clarin.noteOn;
//<<< "in: noteOn">>>;
300::ms=>now;
}
0 =>clarin.noteOff;
}
}
0=>c.gain;
}
}
}
/**********************************************************************************************/
function void fluteSounds(){
}
/**********************************************************************************************/
function void organSounds(){
// HID
Hid hi;
HidMsg msg;
// which keyboard
0 => int device;
// get from command line
if( me.args() ) me.arg(0) => Std.atoi => device;
// open keyboard (get device number from command line)
if( !hi.openKeyboard( device ) ) me.exit();
<<< "keyboard '" + hi.name() + "' ready", "" >>>;
//0 => organ.gain;
// infinite event loop
while (true){
// wait for event
hi => now;
// get message
while ( hi.recv( msg) && io == 1) {
// check
//.75 => o.gain;
volume.value() => o.gain;
.6 => e.gain;
.3 => e2.gain;
if( msg.isButtonDown() ) {
// Std.mtof( msg.which + 45 ) => float freq;
Std.mtof( msg.which+45) => float freq;
freq $ int => int ifreq;
<<< "Frequency: " + freq + " " + ifreq>>>;
if( ifreq > 20000 ) continue;
//.5 => organ.gain;
for (0=>int i; i<keys.cap(); i++){
if (ifreq == keys[i]){
pitch[i] => org.freq;
1 => org.noteOn;
80::ms=>now;
}
0 => org.noteOff;
}
}
0=>e.gain;
0=>e2.gain;
0=>o.gain;
}
}
}
/**********************************************************************************************/
function void brassSounds(){
}
function void keyBoard(){
}
spork ~ pianoControl();
spork ~ clarinetControl();
spork ~ fluteControl();
spork ~ organControl();
spork ~ brassControl();
//spork ~ allinstrumentsControl();
spork ~ clarinetSounds();
spork ~ organSounds();
while (true){
1::day=>now;
}
//clarinet patch
Clarinet clarin => JCRev c => dac;
0 => c.gain;
.1 => c.mix;
//flute patch
//organ patch
BeeThree org => JCRev o => Echo e => Echo e2 => dac;
o => dac;
// set delays
240::ms => e.max => e.delay;
480::ms => e2.max => e2.delay;
// set gains
//.6 => e.gain;
//.3 => e2.gain;
0 => o.gain;
0 => e.gain;
0 => e2.gain;
.05 => o.mix;
//brass patch
MAUI_View view;
view.name("Kins 2012");
MAUI_Button piano, clarinet, flute, organ, brass;
MAUI_LED lpiano, lclarinet, lflute, lorgan, lbrass;
MAUI_Slider volume;
view.size(500,250);
piano.pushType();
piano.size(100,100);
piano.position(0,0);
piano.name("piano");
view.addElement(piano);
clarinet.pushType();
clarinet.size(100,100);
clarinet.position(piano.x()+piano.width(),piano.y());
clarinet.name("clarinet");
view.addElement(clarinet);
flute.pushType();
flute.size(100,100);
flute.position(clarinet.x()+clarinet.width(),clarinet.y());
flute.name("flute");
view.addElement(flute);
organ.pushType();
organ.size(100,100);
organ.position(flute.x()+flute.width(),flute.y());
organ.name("organ");
view.addElement(organ);
brass.pushType();
brass.size(100,100);
brass.position(organ.x()+organ.width(),organ.y());
brass.name("brass");
view.addElement(brass);
lpiano.color(lpiano.blue);
lpiano.size(50,50);
lpiano.position(25,75);
lpiano.light();
view.addElement(lpiano);
lclarinet.color(lclarinet.blue);
lclarinet.size(50,50);
lclarinet.position(lpiano.x()+100, lpiano.y());
lclarinet.light();
view.addElement(lclarinet);
lflute.color(lflute.blue);
lflute.size(50,50);
lflute.position(lclarinet.x()+100,lclarinet.y());
lflute.light();
view.addElement(lflute);
lorgan.color(lorgan.blue);
lorgan.size(50,50);
lorgan.position(lflute.x()+100,lflute.y());
lorgan.light();
view.addElement(lorgan);
lbrass.color(lbrass.blue);
lbrass.size(50,50);
lbrass.position(lorgan.x()+100,lorgan.y());
lbrass.light();
view.addElement(lbrass);
volume.range(0,5);
volume.position (0,125);
volume.size(500,volume.height());
volume.name("Volume");
view.addElement(volume);
view.display();
[lpiano, lclarinet, lflute, lorgan, lbrass] @=>MAUI_LED leds[];
[622, 659, 698, 739, 783, 830,880, 932, 987, 1046, 1479,1567,1244,
349, 493, 174, 369, 415, 554, 440, 220, 311, 329, 1661, 1760,1864,
138,391,164,184,195,207,233,246,261,2093,2217,1108,587,523,155,466,146,293,277,2489,2637,2793,
61101016] @=>int keys[];
[131,139,156,165,185,208,233,247,277,311,330,370,415,
131,147,165,175,196,220,247,262,294,330,349,392,440,
523,554,622,659,740,831,932,988,69,78,82,93,
523,587,659,698,784,880,988,65,73,82,87] @=>int pitch[];
int ip, ic, ifl, io, ib;
function void volumeControl(){
while (true){
volume => now;
if (ip == 1){
<<<"volume">>>;
}
else if (ic == 1){
volume.value() => c.gain;
}
else if (ifl == 1){
}
else if (io == 1){
volume.value() => org.gain;
}
else if (ib == 1){
}
else{
}
}
}
function void ledControl(MAUI_LED led){
for (0=>int i; i<leds.cap(); i++){
leds[i].color(leds[i].blue);
leds[i].light();
}
led.color(led.green);
led.light();
}
function void allinstrumentsControl(){
while (true){
if (ic == 1){
clarinetSounds();
}
if (io == 1){
organSounds();
}
}
/* if (piano.state() == 0 || clarinet.state() == 0){
while (true){
<<< piano.state(), clarinet.state(), flute.state(),
organ.state(), brass.state()>>>;
if (piano.state() == 1){
pianoControl();
}
else if (clarinet.state() == 1){
clarinetControl();
}
else if (flute.state() == 1){
fluteControl();
}
else if (organ.state() == 1){
organControl();
}
else if (brass.state() == 1){
brassControl();
}
else {
}
}
}*/
}
function void pianoControl(){
while (true){
piano => now;
if (piano.state() == 1){
ledControl(lpiano);
1=>ip;
0=>ic=>ifl=>io=>ib;
<<< ip, ic, ifl, io, ib>>>;
}
}
}
function void clarinetControl(){
while (true){
clarinet => now;
if (clarinet.state() == 1){
ledControl(lclarinet);
1=>ic;
0=>ip=>ifl=>io=>ib;
<<< ip, ic, ifl, io, ib>>>;
//clarinetSounds();
}
}
}
function void fluteControl(){
while (true){
flute => now;
if (flute.state() == 1){
ledControl(lflute);
1=>ifl;
0=>ip=>ic=>io=>ib;
<<< ip, ic, ifl, io, ib>>>;
}
}
}
function void organControl(){
while (true){
organ => now;
if (organ.state() == 1){
ledControl(lorgan);
1=>io;
0=>ip=>ic=>ifl=>ib;
<<< ip, ic, ifl, io, ib>>>;
}
}
}
function void brassControl(){
while (true){
brass => now;
if (brass.state() == 1){
ledControl(lbrass);
1=>ib;
0=>ip=>ic=>ifl=>io;
<<< ip, ic, ifl, io, ib>>>;
}
}
}
function void pianoSounds(){
}
function void clarinetSounds(){
// HID
Hid hi;
HidMsg msg;
// which keyboard
0 => int device;
// get from command line
if( me.args() ) me.arg(0) => Std.atoi => device;
// open keyboard (get device number from command line)
if( !hi.openKeyboard( device ) ) me.exit();
<<< "keyboard '" + hi.name() + "' ready", "" >>>;
// infinite event loop (the if was a while)
while (true){
// wait for event
hi => now;
// get message
while ( hi.recv( msg ) ) {
if( msg.isButtonDown() && ic == 1) {
//0.75 => c.gain;
volume.value() => c.gain;
clarin.clear(1.0);
1 => clarin.reed;
Std.rand2f(0,1) => clarin.noiseGain;
Std.rand2f(0,12) => clarin.vibratoFreq;
Std.rand2f(0,1) => clarin.vibratoGain;
Std.rand2f(0,1)=> clarin.pressure;
// Std.mtof( msg.which + 45 ) => float freq;
Std.mtof( msg.which+45) => float freq;
freq $ int => int ifreq;
<<< "Frequency: " + freq + " " + ifreq>>>;
if( ifreq > 20000 ) continue;
for (0=>int i; i<keys.cap(); i++){
if (ifreq == keys[i]){
pitch[i] => clarin.freq;
1 => clarin.noteOn;
//<<< "in: noteOn">>>;
300::ms=>now;
}
0 =>clarin.noteOff;
}
}
0=>c.gain;
}
}
}
/**********************************************************************************************/
function void fluteSounds(){
}
/**********************************************************************************************/
function void organSounds(){
// HID
Hid hi;
HidMsg msg;
// which keyboard
0 => int device;
// get from command line
if( me.args() ) me.arg(0) => Std.atoi => device;
// open keyboard (get device number from command line)
if( !hi.openKeyboard( device ) ) me.exit();
<<< "keyboard '" + hi.name() + "' ready", "" >>>;
//0 => organ.gain;
// infinite event loop
while (true){
// wait for event
hi => now;
// get message
while ( hi.recv( msg) && io == 1) {
// check
//.75 => o.gain;
volume.value() => o.gain;
.6 => e.gain;
.3 => e2.gain;
if( msg.isButtonDown() ) {
// Std.mtof( msg.which + 45 ) => float freq;
Std.mtof( msg.which+45) => float freq;
freq $ int => int ifreq;
<<< "Frequency: " + freq + " " + ifreq>>>;
if( ifreq > 20000 ) continue;
//.5 => organ.gain;
for (0=>int i; i<keys.cap(); i++){
if (ifreq == keys[i]){
pitch[i] => org.freq;
1 => org.noteOn;
80::ms=>now;
}
0 => org.noteOff;
}
}
0=>e.gain;
0=>e2.gain;
0=>o.gain;
}
}
}
/**********************************************************************************************/
function void brassSounds(){
}
function void keyBoard(){
}
spork ~ pianoControl();
spork ~ clarinetControl();
spork ~ fluteControl();
spork ~ organControl();
spork ~ brassControl();
//spork ~ allinstrumentsControl();
spork ~ clarinetSounds();
spork ~ organSounds();
while (true){
1::day=>now;
}
Subscribe to:
Posts (Atom)

