Difference between revisions of "SLOrk/Instruments/KoolKeys"

From CCRMA Wiki
Jump to: navigation, search
(new page)
 
Line 1: Line 1:
 
== Description ==
 
== Description ==
  
This instrument play intervals. The tilting of the laptop controls the intensity of each note (tilting front or back play the root note and tilting to the sides play the "interval" note). The sound is played trough a LeSLOrklie speaker (it rotates around the Hemi at an adjustable spin frequency).
+
The program senses mouse movement, and plays chords (each note of the chord on a different channel) at the volume which cooresponds to the speed of the mouse movement.  It can be modified to play through a Hemi or through laptop speakers.
  
 
== Usage ==
 
== Usage ==
Line 9: Line 9:
  
 
=== Executing===
 
=== Executing===
* Using a terminal go to the folder were "koolkeys.ck" is located
+
* Using a terminal go to the folder where "koolkeys.ck" is located
 
* On the terminal window type: ''(replace N with the number of output channels of the audio card)'' <pre>chuck -cN koolkeys.ck</pre>
 
* On the terminal window type: ''(replace N with the number of output channels of the audio card)'' <pre>chuck -cN koolkeys.ck</pre>
 
* Play!
 
* Play!
Line 15: Line 15:
 
=== Execution ===
 
=== Execution ===
  
# Select the root note by using 2nd and 3rd rows of the keyboard (from Tab & CAPS to ] & RETURN). See [[#Root note selection|root note selection]] for details
+
This program works much like a keyboard on a piano, and is highly based off of the virtual keyboard in Garage Band.
# Select interval using the numbers (1 to 8)
+
 
# Play notes by tilting the laptop
+
# Select the root note by using 2nd and 3rd rows of the keyboard (from A & W to P & '). See [[#Root note selection|root note selection]] for details
 +
# Play chord by moving finger over trackpad
 
# Optional:
 
# Optional:
#* adjust timbre ([[#Other control keys|detail]])
+
#* Select number of pings to play by using numbers 1 through 9 (number of pings will be double the selected value)
#* adjust spin frequency ([[#Other control keys|detail]])
+
#* adjust chord type ([[#Other control keys|detail]])
#* change register ([[#Other control keys|detail]])
+
#* Change register ([[#Other control keys|detail]])
#* detune the instrument ([[#Other control keys|detail]])
+
#* Change tempo of pings ([[#Other control keys|detail]])
#* mute one or both notes ([[#Mute keys|detail]])
+
#* Isolate individual notes of chord ([[#Other control keys|detail]])
  
 
==== Key mapping ====
 
==== Key mapping ====
Line 30: Line 31:
  
 
{|style="color:black; background-color:#eeeeee;" cellpadding="5" cellspacing="0" border="1"
 
{|style="color:black; background-color:#eeeeee;" cellpadding="5" cellspacing="0" border="1"
|F4#||G4||G4#||A4|| A4#|| B4|| C5|| C5#|| D5|| D5#|| E5|| F5|| F5#|| G5|| G5#|| A5|| A5#|| B5|| C6|| C6#|| D6|| D6#|| E6
+
|C||C#||D||D#||E||F||F#||G||G#||A||A#||B||C||C#||D||D#||D||E||F
 
|-
 
|-
|TAB||CAPS||Q||A||W ||S ||D ||R ||F ||T ||G ||H ||U ||J ||I ||K ||O ||L ||; ||[ ||' ||] ||RETURN |
+
|A||W||S||E||D||F||T||G||Y||H||U||J||I||K||L||P||:||"|
 
|}
 
|}
  

Revision as of 02:39, 20 May 2009

Description

The program senses mouse movement, and plays chords (each note of the chord on a different channel) at the volume which cooresponds to the speed of the mouse movement. It can be modified to play through a Hemi or through laptop speakers.

Usage

Installation

Executing

  • Using a terminal go to the folder where "koolkeys.ck" is located
  • On the terminal window type: (replace N with the number of output channels of the audio card)
    chuck -cN koolkeys.ck
  • Play!

Execution

This program works much like a keyboard on a piano, and is highly based off of the virtual keyboard in Garage Band.

  1. Select the root note by using 2nd and 3rd rows of the keyboard (from A & W to P & '). See root note selection for details
  2. Play chord by moving finger over trackpad
  3. Optional:
    • Select number of pings to play by using numbers 1 through 9 (number of pings will be double the selected value)
    • adjust chord type (detail)
    • Change register (detail)
    • Change tempo of pings (detail)
    • Isolate individual notes of chord (detail)

Key mapping

Root note selection
C C# D D# E F F# G G# A A# B C C# D D# D E F
A W S E D F T G Y H U J I K L P :
Interval selection

Number keys from 1 to 8

Interval quality selection
  • M (Major/Perfect)
  • N (Minor/Tritone)

(no diminished or augmented)

Other control keys
Parameter Decrease Increase
Register , .
Detune 9 0
Spin frequency Arrow Left Arrow Right
Number of harmonics (timber) Arrow Down Arrow Up
Mute keys
Key Mutes ...
SPACE BAR Both notes
Left SHIFT Root note
Right SHIFT Interval note

Advanced users

ChucK Code

If you just want to look at the code, here it is:

//Project 2

2 => int speakers;
60 => int key;
0 => int chance_high;
0 => int player;
240 => float tempo;

SinOsc frst => JCRev r => dac.chan(0%speakers);
SinOsc thrd => r => dac.chan(1%speakers);
SinOsc fith => r => dac.chan(2%speakers);
SinOsc sevn => r => dac.chan(3%speakers);

SinOsc high => r => Echo a;

[0,4,7,12] @=> int maj[];
[0,3,7,12] @=> int min[];
[0,4,7,10] @=> int dom7[];
[0,3,7,10] @=> int min7[];
[0,7,12,0] @=> int pwr[];
[0,4,7,9] @=> int six[];
[0,4,7,11] @=> int maj7[];
[0,5,7,12] @=> int sus4[];
[0,4,7,14] @=> int nin[];
[0,2,7,12] @=> int sec[];
[0,3,6,9] @=> int dim7[];
[-1,3,6,11] @=> int flat7[];

KBHit kb; //keyboard
Hid hi;
HidMsg msg;
0=>float volume;
0=>float true_vol;

if( !hi.openMouse( 0 ) ) me.exit();

int k;
maj @=> int chord[];
0 => int deg;
0 => int octave;
float play_now[];


function float[] chnum(int start, int deg, int chord[]) {
    return [Std.mtof(start+deg+octave+chord[4%4]),Std.mtof(start+deg+octave+chord[5%4]),Std.mtof(start+deg+octave+chord[6%4]),Std.mtof(start+deg+octave+chord[7%4])];
}


function void get_mouse() {
    while (true) {
        hi => now;
        while (hi.recv( msg )) {
    
            if( msg.isMouseMotion() ) {
                Math.abs(msg.deltaX)+Math.abs(msg.deltaY)+volume=>volume;
            }
        }
    }
}

function void main_loop() {
    while (true) {
        volume*.85 => volume;
        volume => true_vol;
        true_vol/4500.0 => true_vol;
        if (true_vol>1.0) {1.0=>true_vol;}
        if (true_vol<.001) {0.0=>true_vol;}
        
        
        kb.getchar() => k;
        //<<<k>>>;
        if (k>=48&k<=57) {(k-48)*2 => chance_high;<<<(k-48)*2," pings">>>;}
        
        if (k==122) {maj@=>chord;<<<"Major","">>>;}
        if (k==120) {min@=>chord;<<<"Minor","">>>;}
        if (k==99) {dom7@=>chord;<<<"Dominant 7","">>>;}
        if (k==118) {min7@=>chord;<<<"Minor 7","">>>;}
        if (k==98) {pwr@=>chord;<<<"Power","">>>;}
        if (k==110) {six@=>chord;<<<"Sixth","">>>;}
        if (k==109) {maj7@=>chord;<<<"Major 7","">>>;}
        if (k==44) {sus4@=>chord;<<<"Sustained 4","">>>;}
        if (k==46) {nin@=>chord;<<<"Ninth","">>>;}
        if (k==47) {dim7@=>chord;<<<"Diminshed 7","">>>;}
        
        if (k==97) {0=>deg;<<<"C","">>>;}
        if (k==119) {1=>deg;<<<"C#","">>>;}
        if (k==115) {2=>deg;<<<"D","">>>;}
        if (k==101) {3=>deg;<<<"D#","">>>;}
        if (k==100) {4=>deg;<<<"E","">>>;}
        if (k==102) {5=>deg;<<<"F","">>>;}
        if (k==116) {6=>deg;<<<"F#","">>>;}
        if (k==103) {7=>deg;<<<"G","">>>;}
        if (k==121) {8=>deg;<<<"G#","">>>;}
        if (k==104) {9=>deg;<<<"A","">>>;}
        if (k==117) {10=>deg;<<<"A#","">>>;}
        if (k==106) {11=>deg;<<<"B","">>>;}
        if (k==107) {12=>deg;<<<"C","">>>;}
        if (k==111) {13=>deg;<<<"C#","">>>;}
        if (k==108) {14=>deg;<<<"D","">>>;}
        if (k==112) {15=>deg;<<<"D#","">>>;}
        if (k==59) {16=>deg;<<<"E","">>>;}
        if (k==39) {17=>deg;<<<"F","">>>;}

        if (k == 45) {12 -=> octave;<<<"Octave:",octave/12>>>;}
        if (k == 61) {12 +=> octave;<<<"Octave:",octave/12>>>;}

        if (k == 91) {5 -=> tempo;<<<tempo,"bpm">>>;}
        if (k == 93) {5 +=> tempo;<<<tempo,"bpm">>>;}

        if (k == 33) {1 => player;<<<"Base","">>>;}
        if (k == 64) {2 => player;<<<"Tenor","">>>;}
        if (k == 35) {3 => player;<<<"Alto","">>>;}
        if (k == 36) {4 => player;<<<"Soprano","">>>;}
        if (k == 37) {0 => player;<<<"All","">>>;}
        //<<<player>>>;

        chnum(key,deg,chord) @=> play_now;
        
        true_vol/5.0=>true_vol;
        //<<<true_vol>>>;
        if (player == 1) {true_vol => frst.gain;0 => thrd.gain;0 => fith.gain;0 => sevn.gain;}
        if (player == 2) {true_vol => thrd.gain;0 => frst.gain;0 => fith.gain;0 => sevn.gain;}
        if (player == 3) {true_vol => fith.gain;0 => frst.gain;0 => thrd.gain;0 => sevn.gain;}
        if (player == 4) {true_vol => sevn.gain;0 => frst.gain;0 => thrd.gain;0 => fith.gain;}
        if (player == 0) {true_vol => frst.gain;true_vol => thrd.gain;true_vol => fith.gain;true_vol => sevn.gain;}
        play_now[0] => frst.freq;
        play_now[1] => thrd.freq;
        play_now[2] => fith.freq;
        play_now[3] => sevn.freq;
        
        
        
        100::ms => now;
    }
}

function void pings(){
while(true){

for (0 => int i; i < chance_high; i++) {
            .05-true_vol/2 => high.gain;
            a => dac.chan(Std.rand2(0,speakers - 1));
            Std.mtof(chord[Std.rand2(0,3)]+key+deg+Std.rand2(0,1)*12) => high.freq;
            (60000/tempo)::ms => now;
        }
            0.0 => high.gain;
            a =< dac;
            0 => chance_high;

  
  100::ms => now;
}
}

spork ~ get_mouse();
spork ~ main_loop();
spork ~ pings();

while (true) {
    100::ms=>now;   
}