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

MFoV P1 cases page

MFoV members:

The story behind P1
Russ and myself both decided to start hacking out some squeak code well before the milestone was due, just to get the hang of smalltalk and the whole squeak environment, which for those of you that haven't used it, while it may look frightening and weird, it is very easy to get the hang of. The part that I think is most interesting is that we both coded up recursive directory search algorithm's, which took me a while b/c I was never all that good with recursion, plus I had to do all kinds of funky string truncating and concatenating. This turned out to be a really good crash course in SmallTalk/Squeak. So after this painstakingly long process, we both come to find that there is a method already written that does exactly what we had done. We eventually used Russ's P1, although I did find a small bug in his code later on. To fix it, I created a hybrid SoundFileGroup that had some code from mine, and some from Russ's. The end result was actually efficient and fairly neat code. I also have to give props to Mark Guzdial, b/c if he hadn't told me about FileDirectory slash, which just returns whatever the slash charcater is for the OS squeak is running on (e.g "\", "/", ":", etc), I may have never found that method. I find it strange that although you have methods right there in front of your face in the System Browser, it is very easy, at least in Class's with many methods, to overlook methods that will do exactly what you want. Anyways, thanks Mark.

P1 Goals
1. To create a SoundFileGroup object that will be able to search a directory tree for .wav, .aiff, .mp3, and .midi files
2. Once the search has been completed, return the new instance
3. Be able to play the songs in the list as a background process
4. Be able to stop the currently playing song
5. Be able to return the playlist as an Array or String

What was hard about P1?
1. This was the first time any of us had used squeak/smalltalk. I enjoyed learning it and hacking out some code
2. The recursive directory search took forever to code, but in the end, it kicked ass!
3. It took me a while to get the MP3 stuff working. In Squeak 2.8 on the NT machines in the States Lab, you could only play MP3's while in morphic. If you tried to play them in MVC, it didn't work right. I didn't really care, b/c I like Morphic better anyhow.

For storing the files, we used an OrderedCollection, which is similar to a Vector() in Java. They are very nice tools, and very easy to access as far as adding/deleting elements goes.

Implementing methods for playing/stopping files was simple. There are actually two funcitons for playing. playAndWait will play files, but you will not be able to do anything while the files are playing. But startPlaying is much more practical and just runs playAndWait as a background process so you can actually multitask!

Since there is no graphical interface involved, I thought I'd just put a little workspace code to demonstrate the funcionality of P1.

"a new SoundFileGroup is created and stored in fileGroup

('midi' '.mp3' '.wav' '.aiff') is an array representing the file types you want to match. You could put in anything, but you won't hear too much sound if you try to play a .dll file

'c:\music' is just the directory you want to start searching from"

fileGroup := SoundFileGroup match: #('.midi' '.mp3' '.wav' '.aiff') from: 'c:\music'.

"this returns the file list as an Array"
fileGroup fileArray.

"this returns the file list as a String"
fileGroup printString.

"this also returns the file list, but as an OrderedCollection"
fileGroup fileList.

"this will start playing from the beginning of the list"
fileGroup startPlaying.

"this will stop playing the songs and kill the background process"
fileGroup stopPlaying.

Links to this Page