ICM Final: Musical Typewriter – take 2

Update to my two previous posts:

ICM Final in Progress: Musical Typewriter

ICM Final Project Proposal: Text2Drum

After getting help from the ICM email list, I changed my AudioPlayer objects to AudioSamples, which only need to be triggered once, as opposed to AudioPlayer objects that require play and rewind functions.  This tweak solved my latency and crackle issues.

Testing out the new version has reminded me of the aural pleasure of typing on analog typewriters.  The rhythmic, percussive quality of clanking keys is now lost on contemporary computer keyboards that make more muted sounds when used.

I also thought it would be cool to visualize the waveform of the audio output and display that along with the letter on the screen.  Well, back to work…

New code after the jump:

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

Minim minim;
//AudioSample objects for each letter of the alphabet
AudioSample play_a;
AudioSample play_b;
AudioSample play_c;
AudioSample play_d;
AudioSample play_e;
AudioSample play_f;
AudioSample play_g;
AudioSample play_h;
AudioSample play_i;
AudioSample play_j;
AudioSample play_k;
AudioSample play_l;
AudioSample play_m;
AudioSample play_n;
AudioSample play_o;
AudioSample play_p;
AudioSample play_q;
AudioSample play_r;
AudioSample play_s;
AudioSample play_t;
AudioSample play_u;
AudioSample play_v;
AudioSample play_w;
AudioSample play_x;
AudioSample play_y;
AudioSample 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.loadSample(“A.mp3”, 512);
play_b = minim.loadSample(“B.mp3”, 512);
play_c = minim.loadSample(“C.mp3”, 512);
play_d = minim.loadSample(“D.mp3”, 512);
play_e = minim.loadSample(“E.mp3”, 512);
play_f = minim.loadSample(“F.mp3”, 512);
play_g = minim.loadSample(“G.mp3”, 512);
play_h = minim.loadSample(“H.mp3”, 512);
play_i = minim.loadSample(“I.mp3”, 512);
play_j = minim.loadSample(“J.mp3”, 512);
play_k = minim.loadSample(“K.mp3”, 512);
play_l = minim.loadSample(“L.mp3”, 512);
play_m = minim.loadSample(“M.mp3”, 512);
play_n = minim.loadSample(“N.mp3”, 512);
play_o = minim.loadSample(“O.mp3”, 512);
play_p = minim.loadSample(“P.mp3”, 512);
play_q = minim.loadSample(“Q.mp3”, 512);
play_r = minim.loadSample(“R.mp3”, 512);
play_s = minim.loadSample(“S.mp3”, 512);
play_t = minim.loadSample(“T.mp3”, 512);
play_u = minim.loadSample(“U.mp3”, 512);
play_v = minim.loadSample(“V.mp3”, 512);
play_w = minim.loadSample(“W.mp3”, 512);
play_x = minim.loadSample(“X.mp3”, 512);
play_y = minim.loadSample(“Y.mp3”, 512);
play_z = minim.loadSample(“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.trigger();
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

void stop()
{
minim.stop();
super.stop();
}

Published by

leesean

Foossa Facts