ICM Final in Progress: Musical Typewriter

I have completed phase 1 of my ICM final project, Text2Drum,  which involves me creating a new “percussion alphabet”, perhaps another way to describe it is “a musical Morse code.”  I have assigned a unique percussion sample to each letter of the alphabet.  I have assigned ‘A’ through ‘G’ pitched percussion hits that correspond to the white keys on a piano, but voiced at different octaves.  All of the other letters are un-pitched percussion sounds.  I have not assigned sounds to punctuation marks or numbers (yet).  I’m not sure if I want to or if this is necessary for my new language.

I have written a Processing sketch, with the help of the Minim library, that that plays back the “percussion letters” when the user types on the keyboard.  There is a bit of latency and audio “crackle” that still needs to be worked out, but for the most part, the musical typewriter works.  The next step is to build a related program that can read a text file as a musical score, translate the letters into percussion alphabet, play back the results, and save the audio playback as a file.

For more info, refer to my previous post about Text2Drum, or see my source code for the musical typewriter after the jump.


Musical Typewriter source code:

import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;

Minim minim;
//AudioPlayer objects for each letter of the alphabet
AudioPlayer play_a;
AudioPlayer play_b;
AudioPlayer play_c;
AudioPlayer play_d;
AudioPlayer play_e;
AudioPlayer play_f;
AudioPlayer play_g;
AudioPlayer play_h;
AudioPlayer play_i;
AudioPlayer play_j;
AudioPlayer play_k;
AudioPlayer play_l;
AudioPlayer play_m;
AudioPlayer play_n;
AudioPlayer play_o;
AudioPlayer play_p;
AudioPlayer play_q;
AudioPlayer play_r;
AudioPlayer play_s;
AudioPlayer play_t;
AudioPlayer play_u;
AudioPlayer play_v;
AudioPlayer play_w;
AudioPlayer play_x;
AudioPlayer play_y;
AudioPlayer play_z;

void setup()
{
minim = new Minim(this);
size(500,500);

background(0);
textFont(createFont(“Courier”, 50));
text(“Type letters”, 30, height/2-50);
text(“to play”, 30, height/2+25);

play_a = minim.loadFile(“A.mp3”, 512);
play_b = minim.loadFile(“B.mp3”, 512);
play_c = minim.loadFile(“C.mp3”, 512);
play_d = minim.loadFile(“D.mp3”, 512);
play_e = minim.loadFile(“E.mp3”, 512);
play_f = minim.loadFile(“F.mp3”, 512);
play_g = minim.loadFile(“G.mp3”, 512);
play_h = minim.loadFile(“H.mp3”, 512);
play_i = minim.loadFile(“I.mp3”, 512);
play_j = minim.loadFile(“J.mp3”, 512);
play_k = minim.loadFile(“K.mp3”, 512);
play_l = minim.loadFile(“L.mp3”, 512);
play_m = minim.loadFile(“M.mp3”, 512);
play_n = minim.loadFile(“N.mp3”, 512);
play_o = minim.loadFile(“O.mp3”, 512);
play_p = minim.loadFile(“P.mp3”, 512);
play_q = minim.loadFile(“Q.mp3”, 512);
play_r = minim.loadFile(“R.mp3”, 512);
play_s = minim.loadFile(“S.mp3”, 512);
play_t = minim.loadFile(“T.mp3”, 512);
play_u = minim.loadFile(“U.mp3”, 512);
play_v = minim.loadFile(“V.mp3”, 512);
play_w = minim.loadFile(“W.mp3”, 512);
play_x = minim.loadFile(“X.mp3”, 512);
play_y = minim.loadFile(“Y.mp3”, 512);
play_z = minim.loadFile(“Z.mp3”, 512);

textFont(createFont(“Courier”, 200));
}

void draw()
{

}

void keyPressed()
{
if ( key == ‘a’)
{
background(0);
text(“A”, width/2-60, height/2+20);
play_a.play();
play_a.rewind();
}

if ( key == ‘b’)
{
background(0);
text(“B”, width/2-60, height/2+20);
play_b.play();
play_b.rewind();
}

if ( key == ‘c’)
{
background(0);
text(“C”, width/2-60, height/2+20);
play_c.play();
play_c.rewind();
}

if ( key == ‘d’)
{
background(0);
text(“D”, width/2-60, height/2+20);
play_d.play();
play_d.rewind();
}

if ( key == ‘e’)
{
background(0);
text(“E”, width/2-60, height/2+20);
play_e.play();
play_e.rewind();
}

if ( key == ‘f’)
{
background(0);
text(“F”, width/2-60, height/2+20);
play_f.play();
play_f.rewind();
}

if ( key == ‘g’)
{
background(0);
text(“G”, width/2-60, height/2+20);
play_g.play();
play_g.rewind();
}

if ( key == ‘h’)
{
background(0);
text(“H”, width/2-60, height/2+20);
play_h.play();
play_h.rewind();
}

if ( key == ‘i’)
{
background(0);
text(“I”, width/2-60, height/2+20);
play_i.play();
play_i.rewind();
}

if ( key == ‘j’)
{
background(0);
text(“J”, width/2-60, height/2+20);
play_j.play();
play_j.rewind();
}

if ( key == ‘k’)
{
background(0);
text(“K”, width/2-60, height/2+20);
play_k.play();
play_k.rewind();
}

if ( key == ‘l’)
{
background(0);
text(“L”, width/2-60, height/2+20);
play_l.play();
play_l.rewind();
}

if ( key == ‘m’)
{
background(0);
text(“M”, width/2-60, height/2+20);
play_m.play();
play_m.rewind();
}

if ( key == ‘n’)
{
background(0);
text(“N”, width/2-60, height/2+20);
play_n.play();
play_n.rewind();
}

if ( key == ‘o’)
{
background(0);
text(“O”, width/2-60, height/2+20);
play_o.play();
play_o.rewind();
}

if ( key == ‘p’)
{
background(0);
text(“P”, width/2-60, height/2+20);
play_p.play();
play_p.rewind();
}

if ( key == ‘q’)
{
background(0);
text(“Q”, width/2-60, height/2+20);
play_q.play();
play_q.rewind();
}

if ( key == ‘r’)
{
background(0);
text(“R”, width/2-60, height/2+20);
play_r.play();
play_r.rewind();
}

if ( key == ‘s’)
{
background(0);
text(“S”, width/2-60, height/2+20);
play_s.play();
play_s.rewind();
}

if ( key == ‘t’)
{
background(0);
text(“T”, width/2-60, height/2+20);
play_t.play();
play_t.rewind();
}

if ( key == ‘u’)
{
background(0);
text(“U”, width/2-60, height/2+20);
play_u.play();
play_u.rewind();
}

if ( key == ‘v’)
{
background(0);
text(“V”, width/2-60, height/2+20);
play_v.play();
play_v.rewind();
}

if ( key == ‘w’)
{
background(0);
text(“W”, width/2-60, height/2+20);
play_w.play();
play_w.rewind();
}

if ( key == ‘x’)
{
background(0);
text(“X”, width/2-60, height/2+20);
play_x.play();
play_x.rewind();
}

if ( key == ‘y’)
{
background(0);
text(“Y”, width/2-60, height/2+20);
play_y.play();
play_y.rewind();
}

if ( key == ‘z’)
{
background(0);
text(“Z”, width/2-60, height/2+20);
play_z.play();
play_z.rewind();
}

if (key == ‘ ‘)
{
background(0);
}
}

Published by

leesean

Foossa Facts