View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

AudioExplorer Modification

What you need:

To install the program, just download the two files then file them in. Starting up the program is pretty easy too – just go into class comments for AudioExplorer, select the last line and do it.

What you get is something that looks like this:

Uploaded Image: jrob_ae1.jpg

Actually, thats what it should look like after you've recorded some audio (did I mention you need a microphone?). To record sound you simply press the Record button at the bottom left; to stop hit pause.

Go ahead and hit the "Math On" button at the bottom left. You'll see something like this:

Uploaded Image: jrob_ae2.jpg

Now click on the "Sound On" button. Now when you hit any key on that little keyboard, it'll actually play that note.


So what did I do?


Well, I added the sound playing capabilities. Originally I was planning on just throwing the capability in there, but I spoke with the Author, Je77, and he expressed a desire to have the feature as an option... Thus the "Sound On"/"Sound Off" button was born.

And how did you do it?


Squeak actually had most of stuff already there, it was just a matter of hooking it up. My other considerations were to preserve the look and feel of the program, and to keep the code clean.


Adding the button

I didn't want the button to always be visible. Rather, I'd prefer it only appear when it acutally served a purpose, i.e. when the keyboard is visible. So, if you take a look at the "toggleMath" method you'll see where the button is added and removed.

Some other methods that were written with regards to the button were addSoundButton, and toggleSound both of which I think are pretty self explanatory.

Playing those sweet sounds

Here's the source for the playing the sound:
keyPressed: aKey 
	| frequency |
        "The numbers on the side are reference points"

	self selected: (scale indexOf: aKey).
"1"	frequency := 440  (2 raisedTo: selected	- 34 / 12).
	owner signalFrequencyPosition: frequency.
"2"	owner playSound ifTrue:[
"3"		((AbstractSound soundNamed: 'default') soundForPitch:
		frequency dur:0.5 loudness:1) play.
	].

OK, obviously this code is called when a key is pressed. Je77 had already written the code to calculate the tone's frequency (see line 1).

Line 2 has a little method I wrote called playSound. It returns a boolean saying whether or not to play the sound. Actual implementation is a little hack-ish since what it does is check the color of the "Sound" button. If its red, return true, else return false. Oh well, guess you're stuck with green and red.

Line 3 is the real heart of the code. AbstractSound is an object that can generate audio. The parameter that soundNamed takes in is a string representation of what instrument you want to have played. An AbstractSound object is returned. I told that object to play a sound at the frequency Je77 calculated for half a second and at full volume (YEAH!)

Things I might like to change




Questions? Comments? jroberts@cc.gatech.edu


Nice job! But a GLOBAL AbstractSound?!? EEKS! Probably better to figure out what's taking so long in making an AbstractSound. At worst, maybe you can attach one to the AudioExplorer somewhere. Mark Guzdial




Link to this Page