soundwaves-johnclarepoem

Processing Day 13: Breakthrough!

Working with the concept of sound and thinking about re-interpreting letterforms as sound, Arzu, one of my faculty members in the MFA Program and I had the idea to relate keyboard strokes to sounds so that when you type letters on the keyboard, you can play sounds. I talked to my brother about this and he said he could write something using Python in less than a half hour. But he’s super busy and I felt sort of bad taking his time up with that, so on a whim I just figured I’d see if I could figure it out myself in Processing now that I’m starting to better understand.

Well….I figured it out! I found some code that showed how to play a sound with a keystroke and was able to import piano notes I recorded into the Processing Data folder. The code uses a library called Minim which I was also able to download. Then I assigned the individual piano notes to keys on the QWERTY keyboard. I also had to figure out how to get them to play more than once, which I was able to find on the old Processing forum: I simply had to add a .rewind() after each call to the file.

Unfortunately I cannot upload it onto Openprocessing.org because they don’t support libraries, so I can’t as of yet embed it into my website for people to try online. I can, however, include a sample of me typing John Clare’s poem, “I am”. I know it sounds very discordant and awkward (my digital music knowledge is nil). In addition, the recording is terrible because I recorded it playing off my laptop in GarageBand, which worked once, and then made a horrendous high-pitched squealing sound. Soooo… I might have to work with someone who knows more about audio recording if I want to continue with this project. But I’m happy it works and now I feel that the possibilities are endless!

Here is the sound recording (please pardon the low-quality):

*
*For some reason, this audio player is working in Safari but not Firefox… I will look into this.

And here’s my code: (I’m sure there is a much cleaner way to write this code, but I’m working on it!)


//sound

import ddf.minim.* ;
Minim minim;
AudioPlayer au_player1, au_player2, au_player3, au_player4, au_player5,
au_player6, au_player7, au_player8, au_player9, au_player10, au_player11, au_player12,
au_player13, au_player14, au_player15, au_player16, au_player17, au_player18, au_player19,
au_player20, au_player21, au_player22, au_player23, au_player24, au_player25, au_player26;
void setup()
{
minim = new Minim(this) ;
au_player1 = minim.loadFile("single-A.wav") ;
au_player2 = minim.loadFile("single-B.wav") ;
au_player3 = minim.loadFile("single-C.wav") ;
au_player4 = minim.loadFile("single-D.wav") ;
au_player5 = minim.loadFile("single-E.wav") ;
au_player6 = minim.loadFile("single-F.wav") ;
au_player7 = minim.loadFile("single-G.wav") ;
au_player8 = minim.loadFile("single-H.wav") ;
au_player9 = minim.loadFile("single-I.wav") ;
au_player10 = minim.loadFile("single-J.wav") ;
au_player11 = minim.loadFile("single-K.wav") ;
au_player12 = minim.loadFile("single-L.wav") ;
au_player13 = minim.loadFile("single-M.wav") ;
au_player14 = minim.loadFile("single-N.wav") ;
au_player15 = minim.loadFile("single-O.wav") ;
au_player16 = minim.loadFile("single-P.wav") ;
au_player17 = minim.loadFile("single-Q.wav") ;
au_player18 = minim.loadFile("single-R.wav") ;
au_player19 = minim.loadFile("single-S.wav") ;
au_player20 = minim.loadFile("single-T.wav") ;
au_player21 = minim.loadFile("single-U.wav") ;
au_player22 = minim.loadFile("single-V.wav") ;
au_player23 = minim.loadFile("single-W.wav") ;
au_player24 = minim.loadFile("single-X.wav") ;
au_player25 = minim.loadFile("single-Y.wav") ;
au_player26 = minim.loadFile("single-Z.wav") ;
}

void draw()
{
}void mousePressed()
{
au_player1.play() ;
}


void keyReleased(){
if (key == 'a')
{
  au_player1.play() ;
  au_player1.rewind();
}  
  
if (key == 'b')
{
  au_player2.play() ;
  au_player2.rewind();
}

if (key == 'c')
{
au_player3.play() ;
au_player3.rewind();
}

if (key == 'd')
{
au_player4.play() ;
au_player4.rewind();
}

if (key == 'e')
{
au_player5.play() ;
au_player5.rewind();
}

if (key == 'f')
{
au_player6.play() ;
au_player6.rewind();
}

if (key == 'g')
{
au_player7.play() ;
au_player7.rewind();
}

if (key == 'h')
{
au_player8.play() ;
au_player8.rewind();
}

if (key == 'i')
{
au_player9.play() ;
au_player9.rewind();
}

if (key == 'j')
{
au_player10.play() ;
au_player10.rewind();
}

if (key == 'k')
{
au_player11.play() ;
au_player11.rewind();
}

if (key == 'l')
{
au_player12.play() ;
au_player12.rewind();
}

if (key == 'm')
{
au_player13.play() ;
au_player13.rewind();
}

if (key == 'n')
{
au_player14.play() ;
au_player14.rewind();
}

if (key == 'o')
{
au_player15.play() ;
au_player15.rewind();
}

if (key == 'p')
{
au_player16.play() ;
au_player16.rewind();
}

if (key == 'q')
{
au_player17.play() ;
au_player17.rewind();
}

if (key == 'r')
{
au_player18.play() ;
au_player18.rewind();
}

if (key == 's')
{
au_player19.play() ;
au_player19.rewind();
}

if (key == 't')
{
au_player20.play() ;
au_player20.rewind();
}

if (key == 'u')
{
au_player21.play() ;
au_player21.rewind();
}

if (key == 'v')
{
au_player22.play() ;
au_player22.rewind();
}

if (key == 'w')
{
au_player23.play() ;
au_player23.rewind();
}

if (key == 'x')
{
au_player24.play() ;
au_player24.rewind();
}

if (key == 'y')
{
au_player25.play() ;
au_player25.rewind();
}

if (key == 'z')
{
au_player26.play() ;
au_player26.rewind();
}
}