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

Questions on Sp2001 P1 Milestone

Ask questions on P1 here...
(Before you ask that question on Squeak that's at the tip of your tongue, check out the FAQ pages, especially the Squeak FAQ)

Any questions on P1? ANYONE? (Anyone?....anyone?....) Mark Guzdial

Note the new page: Playing MPEG files in Squeak by Lex Spoon.

Are you going to discuss anything about this in class?
No, not really – ask here. Mark Guzdial

I'm just starting and am really confused about certain issues. Does SoundFileGroup have instance variables? what exactly does it hold? The printString method, is it supposed to print a runon of all the files' pathnames? I am really confused about these. The P1 milestone is a little too basic, might want to elaborate on some aspects.
You might want to read ahead to the design sections of the book, if you're not sure how to start. Think about what a given object has to know. SoundFileGroup's need to know their files, right? That means that they have to have instance variables. YOU have to figure out what EXACT instance variables are needed. Remember: This is a class in DESIGN. We don't tell you exactly what's needed. Make printString print a readable representation. Mark Guzdial

How should we structure questions here? I'm having a problem playing MIDI files, I think I'm doing everything right, but I get no sound (yes, external players play fune). I'm wary about posting code, but how else can I get help?

You're welcome to post a sample piece of code that you think should work but isn't work. Posting some workspace code (code that should work in a workspace) isn't a violation of the honor code. Page. 219 in the book gives example code for playing a MIDI file. Mark Guzdial

More questions?

I was wondering what he value for platformName, in the SystemDictionary class, is for Unix and Mac systems, since we have to be able to handle these types of directory names as well as dos style.
Justin Holzer

Squeak includes code already that will handle filenames on any platform. So, you shouldn't need to query the filesystem directly. -Lex Spoon

i'm very confused on many things... the first of which is where we're supposed to learn to use squeak. it's obviously nothing like the languages we've been learning so far so it's difficult to figure out the syntax on our own, and at the rate we're going in class, well, we still wont know enough to do P1 by the end of the semester :)

Squeak is wierd, but it's actually pretty simple. Messages and objects.... As one tip, it probably helps to work through the examples from class yourself. Start up an image and play around some! -Lex Spoon

next, i have questions about the specific requirements of P1...

"s printString returns a String containing the full pathname of each of the files in the SoundFileGroup s."
i'm not sure what this means. if s is a SoundFileGroup, it will have many files and pathnames in it... yet it returns a single string? what should the string look like? what does it print? all the paths to all the files clumped together? or should they be delimited by something?

For example, try doing "#(1 2 3) printString" and seeing what string is returned. It is a string, which shows the three elements. Also, try "(OrderedCollection with: 1 with: 2 with: 3) printString". Does that help? The exact requirements aren't specific, but the elements should appear. ("A SoundFileGroup" is not acceptible!) -Lex Spoon

"s fileArray returns an array of strings, each of which is the full pathname of each of the files in the SoundFileGroup s."
this one makes a little more sense... each file has its own pathname... it would seem that printString would just print out all these strings in this array?

Basically. Note that printString is a noun, though – it means "return the print string", not "print as a string". For example, compare "Transcript show: 'hello'" to just plain "'hello'". The first actually prints something; the latter just calculates a string. -Lex Spoon"


We're going to make it a requirement that your project has to work cross-platform. It's pretty easy to do this, e.g., FileDirectory slash will return the path delimiter for the current platform ("/" for nix, ":" for Mac, "\" for those other OS...:-). Mark Guzdial


I have two questions:
1] I did a directory search starting at the '/' on a linux machine. My search eventually hit a symbollic link that just points back to it itself, and infinitely recursed. Should we be able to handle problems like these?

2] How can you take away or give control to/from the user, like we have to do in our playAndWait & startPlaying methods?

Justin Holzer

1. no, don't worry about it. 2. For playAndWait, just write a method that plays the sounds and waits for them to finish. For startPlaying, you need to start a thread that will do the playing for you. -Lex Spoon

Confused about the cross-platform addition:
Can we assume that the user will enter a correct path for the platform he/she's running in the match:from: message? Otherwise, squeak just opens an error window.
Now the confusion: why would we need to worry about path delimiters? If the user gives a correctly-formed root path to play from, doesn't FileDirectory handle all the platform-specific stuff? Same goes for the built-in subdir walk messages? Thanks.
Dave C
Yes, it's okay to generate an error if someone puts in an invalid path. It doesn't matter whether your code or existing code in Squeak generates this error. And yes, the easy way to access files also happens to be platform independent. -Lex Spoon

I keep getting an error in squeak. It tels me that squeakis low on memory. Is there any way I can increase the size of squeaks memory?
Russ Paul

Try -memory: 256 "%1" on the command line when you start squeak. (to allocate 256 megs, for example). One thing to note: if you allocate all the memory the machine has and you end up with a stack overflow of some kind (which is neat), you might be in for a some trouble. I've found that the machines in the NT cluster work quite well with 64 megs or so used for squeaking. Shaggz

On Unix it's "-memory 256m". On MacOS, you need to use the OS and modify the amount of memory that the Squeak VM will run with; I don't know exactly how this is done. -Lex Spoon

For the Mac, memory information can be found in the "get info" window. just select the VM file, and click command-i. Check the memory section in the resulting window. -Rich Glazerman

Why does this code play mp3's:

j := MPEGPlayerMorph new.
j playWhatever: 'c:\stuff.mp3'

Yet, this code dosen't work:

MPEGPlayer playFile: 'stuff.mp3'

Should the first code example open up a morph or should it just play the file?

Justin Holzer

MPEGPlayer playFile: tells the player which file it is going to play. It does NOT tell the player to actually play. Look for a way to tell the player to play the file it has been set for. Hint: check the newsgroup. Rich Glazerman

In squeak is it convention to use accessors and modifier methods when referencing an instance variable that is in scope? To be specific, if I have an instance variable in a class should the class? methods access the variable directly, or through accessor and modifier methods?

If you ever decide to use your class from some other class, you'll need the modifiers and accessors anyway, and if you have them, you may as well use them. Whether it's convention or not, it's a good practice to follow. Rich Glazerman

This is a long-standing style question in Smalltalk. Whatever you decide, definitely do not add accessors just to fit your decision. Perhaps you use accessors when they are there, but don't add accessors just because of a general notion that accessors are better. -Lex Spoon

I am having a very strange problem. On NT, on the states lab machines at the CoC, when I invoke my startPlaying method, it dosen't start working until I click the left mouse button and bring up whatever menu it invokes. 1 time, I had to do that in order to play each file in the list.

However, under linux on the CoC machines, and on my home pc (Win 98 SE), the songs play "automagically". Should I be worried, or is something beyond my control?

Justin Holzer

You should probably run in Morphic instead of MVC. Does that fix your problems? -Lex Spoon

I was thinking is there an MPEG3-Kernel that has any comments it would be of great help. The one I am using does not have any comments and I am not sure what half of the methods are supposed to do. Any suggestions people?
I am getting the full path names, however for extremly long file names it truncates the file path leaving me with something like #14, eg. 'c:\gsgfd\gsgdgdfs...gfdgfdsggfdgfs.mp3'.

Any ideas on how to fix this
Can someone please tell me how do you call an existing method in squeak or must you rewrite it even if there is a method that can do what you want.
Perpetual Claudia. Iriele

My MPEGPlayer class has an extremely useful comment, in case you literally meant no comments. On the file paths issue, feel free to add a method to MPEGFile (or whatever) if what you need doesn't seem to be there. On the second question, I'm not sure what you're after in the second question, but you can not just invoke an arbitrary method directly. Instead, you must obtain an instance of the appropriate class and send a message to it. For example, what would it mean to call the "x" method from Point directly, as opposed to invoking "x" for a particular point? -Lex Spoon

( why isn't &star mapping to an asterisk? )
I was planning on using the "match:" method in class String to handle this to allow for more sophisticated matching behavior. Unfortunately using this method on the example listed in the Project Description...
'.mp3' match: 'test.mp3' returns false. The method requires that an asterisk be present in the match string.
'&star.mp3' match: 'test.mp3' returns true.
The question is should I make the "match:from:" method match '.mp3' to a filename such as 'bubblegumpop.mp3' or is it alright to require the user to specify '&star.mp3' to the argument? Shane.

No, the user supplies things like
, without the asterisk. If you want to use
, you'll have to process the query into something
understands (ie, add asterisks). (on the other question, check the Coweb "help" pages – in defiance of all established software engineering practice, Cowebs actually have useful documentation under "Help")
-Lex Spoon

hello, this is the first time i've ever noticed this. well, i have 2 questions:
1. i read the boxes chapter in our squeak book, specifically the section on processes, but i'm still finding the idea intimidating, and don't know how to get started. exactly what is supposed to be a process in this milestone one?

2. printString does not work correctly when i call it printString, but when I call is something else, it works perfectly. when it's called printString, it makes s the string that is returned, but when the method is called testString s stays a SoundGroupFile. why is this?

On 1, it's hard to know what to suggest. Save that part for last, probably. On 2, it sound like your printString is actually working. What does "s class" say, for example? String, or SoundGroupFile? Note that alt-p will use your printString method to figure out what to print

I'm having a lot of problems with the Squeak Program itself. I cannot save anything. If I try to save an image, Squeak freezes. If I open anything but the original image, all I get is a blank white screen. Any advice would be appreciated. Thanks -Kevin Morris

Sounds like you have some messed up images. Playing with processes is a great way to do that. Try and file your code out, and start from a new image. -Lex Spoon

Q: How can I have a process start playing a midi file and then return control when the process is finished with the song. Something analagous to the MPEGPlayer's playAudioStreamAndWait: method. Shane

Each of the sound objects, including midi ScorePlayer's, you will need to use have a method called isPlaying. This returns true if the object is playing a file. I just made a while loop that loops while isPlaying is true. Justin Holzer
TURNIN question:
Turnin question:
How are we supposed to turnin this project, are we supposed to just print out a hard copy and turn it in during class (where do we put our names and info if so?

How are we supposed to know what type of file it is? Can we just use the file extension given by the match: to figure it out? So if they give us .mp3 and it matches we assume that the matching files are of type .mp3?

Q: A question on forking processes. Both of the code examples below don't return control to Squeak until they've finished playing.
p := MPEGPlayer playFile: 'C:\squeak\sounds\1.mp3'.
p playAudioStreamWaitTilDone: 0.

s := SampledSound fromWaveFileNamed: 'C:\sounds\test.wav'.
s playAndWaitUntilDone.

However the first MP3 example below does return control after starting to play and the second example concerning a wave file does not. Why? Is it a subtlety of forking I'm not grasping?

p := MPEGPlayer playFile: 'C:\squeak\sounds\1.mp3'.
[p playAudioStreamWaitTilDone: 0] forkAt: Processor userInterruptPriority.

s := SampledSound fromWaveFileNamed: 'C:\sounds\test.wav'.
[s playAndWaitUntilDone] forkAt: Processor userInterruptPriority.

Should our projects for this class be in MVC or Morphic? By the way, "FileList open." isn't working properly in Morphic. Any suggestions?

I think I've found a bug in the MPEG library. I am running Windows 98 and here is the strange behavior. I have an Mp3 called test.MP3 (capital .MP3)

When I issue the following commands I get an error saying that the filename is invalid:

s:= MPEGPlayer playFile: 'C:\WINDOWS\DESKTOP\SQUEAK\test.MP3'
s playAudioStreamWaitTilDone 0.

however when I issue the exact same command with the MP3 lowercase:

s:= MPEGPlayer playFile: 'C:\WINDOWS\DESKTOP\SQUEAK\test.mp3'
s playAudioStreamWaitTilDone 0.

it plays the file.

Can anyone else recreate this behavior? This is wrong because the extension .MP3 IS capitalized under windows, but it only plays the file if you type it in lowercase. My temporary solution is to force the name to be lowercase, but this destroys my cross-platform-ness.

Again, we meet, Oh Anonymous One. Hmm – that is weird. Are you SURE that at the file-level the MP3 is capitalized? Win98 does fiddle with names (isn't that nice of the Evil Empire?). But in general, I haven't heard of any bugs in Window file name handling in Squeak. Mark Guzdial

Link to this Page