Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.


This page removed for FERPA compliance
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Spring 2003 Take Home Exam 1

I am having problem silencing the "THIS".

REMINDER: This is a NON-COLLABORATIVE ACTIVITY! You may not talk to anyone about their code, nor look at anyone else's code, nor allow anyone to see your code. This is a TAKE HOME EXAM. It is an "open book" exam. You may use your book, any slides, any material in the CoWeb, and any programs you've written (even with others) that you already have direct access to.

Ask questions here but be sure to ask questions only about objectives and process. You are welcome to ask questions about any of the programs in the book or in the slides, but you cannot ask anyone (even the TA's or teacher) about your own solution.

Comments or questions?



Ok, I believe I have a solution, however, in Prof Guzdial's answer, there appears to be a little bit of spacing betwen "tset" and the rest of the phrase. My question is do you want a little room between the "tset" and the rest of the phrase or can the rest of the phrase come in a tiny bit quicker? If this question is out of line with the terms of this non-collaborative take home exam, please do remove it.

David Petersen

It will be hard for you NOT to have that space – don't worry about it. Get the definition right, and the rest will flow. Mark Guzdial


When I try to do recipe 15 (backwards), it does not play. I don't know what I'm doing wrong, it does something because it pauses and then it displays this: . Any suggestions?

I'm not sure if this is a legal question or not (I hope it is!) but when I attempted to use the backwards formula (on its on–not within the spliced formula) I kept getting the following error message: A local or global name could not be found.
Please check line 13 of C:\Documents and Settings\REMOVEDmmer\My Documents\this is a test backwards. And even though it reads line 13, there are only 9 lines in the program. I got my splicing and I just need the backwards part, but I wanted to make sure the backwards program would work by itself before I did it within the other program.
Student117
REMOVEDmmer, I removed the detail of your message where you gave the lines that are wrong. Please don't post lines of your program. I've found line numbers in JES to get garbled sometimes, too. Try saving and quitting, then re-opening JES and re-opening your program and trying again. Sometimes JES seems to stick in extra blank lines, and that's how it's figuring your line numbers, but you don't see the extra lines until you re-open the file. Also remember that functions can only be named with a single word, no spaces. Mark Guzdial

REMOVEDmmer- I had that same problem too. However, I fixed it. If your backwards recipe (recipe 15) has Return target BEFORE Play(target) then switch them and see if it plays. The book and the slides had it switched for some reason. Hope that helps.
Return must always be the last executed line in the function, but that's not what REMOVEDmmer's problem is. Mark Guzdial

I keep getting this error message: I wasn't able to do what you wanted.
The error java.lang.ArrayIndexOutOfBoundsException has occured
Please check line 13 of C:\Documents and Settings\default\My Documents\CS 1315 Class Assignments\Take-Home Exam #1- backSpliced
What does it mean?
Andrea Layton
I'm having the same problem as Andrea. I'm stumped.
Student86

What it means is that you're passing an index value to the getSampleValueAt function that is either less than 1 or REMOVED than the length of the sound. You need to trace the program – walk it line-by-line and figure out where you're passing in the wrong value. You can also put a print statement before that function so that you can see the values going in and see where the mistake lies. Mark Guzdial


I wrote my program, it sounds find except for it sounds like there's a catch in the word "is". It sounds like I put a space in between the word "is" instead of before. However, I've done neither. Is this an answerable question?
You don't need to add any space at all. Mark Guzdial

It sounds like the T at the end of TSET is cut off in my program. I was just wondering if anyone else is having this problem and is it okay?
It's probably fine – listen to mine and see what you think. Mark Guzdial


for some reason when i had "....mediasources\thisisatest2.wav" python read the \t part of my string as a tab and it could not find the file because it thought the file was "...mediasources hisatest.wav". did anyone else have this problem? so i was wondering if it was ok if i saved the file as "...mediasources\Thisisatest2.wav" because this one worked. thanks
Jessica REMOVED
Yes, that's fine, Jessica, but if you put the "r" before the string, that wouldn't happen. We'll be talking about this probably Wed. in class. Mark Guzdial

I think I almost have it, but it seems like the backwords form of the word test does not take up as much time as the regualar word is. It sounds like I am still getting part of the word is that jumbles with the backwards form of test. Any suggestions?
Nevermind on that question above. I figured it out!!!
Always a good thing! Mark Guzdial




In general, within a "for" loop - I type " sourceIndex = sourceIndex - 1 " - that means that the next sample it will take will be the value one less than the index number it just took? Is this correct? Because i can't seem to make my program take an index value coming before the first taken sample value. This may not make sense.... but i'm so tired of playing with the same 5 lines of code.

AHHHH
Student86

Yes, Justin – that's correct. Everytime that sourceIndex = sourceIndex -1 is executed within a FOR loop, the index will decrease, so that the next sample you get from the sourceIndex is the one just before the last one you took. Mark Guzdial


I spliced the sound correctly, and i inserted the backwards function so that "test", the new first word of the sentence is backwards (or at least really garbled).... but it doesn't sound exactly like the sample you posted on the exam page; it sounds like parts are backwards, or it's mixed up or something... i know my question makes no sense but if you understand wha i'm asking could you give me a suggestion as to whick part of my backwards function code contains the problem? thanks! Student68
I can't tell from your description, but remember that there ways to test your code – pages 69-70 talk about ways to check the samples and see if they're what you think. Write the sound out, and open it in MediaSources, then check it out in the Wave Viewer. Does it look like there are just four words? Move the cursor around in the sound file and "Play before cursor." Does it sound garbled, or does it sound right? Mark Guzdial

OK, REMOVED specificially, so my question makes REMOVED sense... "TEST" is backwards, but it sounds like there's an extra "st" on the end... it sounds like "tsetst is a test." i'm lost... suggestions? Student68
If you spliced it first in the correct order, and then spliced it again backwards, you might get that effect. That's my only thought how you might have done that. Mark Guzdial

When I run my program it doesn't sound quite like yours that you have posted on the web, but if i make it into a file by doing writeSoundTo...and then put that wav into the backwards recipe it seems to work. Is this okay?
I don't quite understand, but if I get the jist of what you're asking, the answer is No. You must write a single function that turns "This is a Test" into "Tset is a test." Mark Guzdial

Is this code supposed to be very long? Because mine is less than 10 lines long, and it took me less than half an hour to write it and get it to work. I keep worrying that I did something wrong, since it is so short. You said something about writing lots of extra lines of code, which I didn't do. Is that OK?
My solution is 10 lines long, too. Sounds okay to me! (Uh, no pun intended :-) Mark Guzdial

Could you go REMOVED into detail about the "arrayindexoutofboundsexception" thing. I keep coming across that too and I'm not sure what it means.
And–is it ok for us to have REMOVED than 10 lines in our solution or should it only be 10?
Student219
Remember that sounds are arrays. The index numbers on an array (the numbers below the boxes in the diagrams) start at 1 and continue to the length of the sound, getLength(sound). If you getSampleValueAt(sound,1), that'll work. If you getSampleValueAt(sound,getLength(sound)), that'll work, too. getSampleValueAt(sound,-1) or getSampleValueAt(sound,0) or getSampleValueAt(sound,getLength(sound)+1) will all generate the Array Index Out of Bounds Exception – you have tried to index the array with a number that is beyond the "bounds" of the array. Mark Guzdial

Are using 2 for loops in the program okay?
REMOVEDre, if you need them. I can't imagine a correct solution that involved nesting them, though. Mark Guzdial

ok–nevermind on the earlier question–I got that one. My next question is very similar to Kristie's. My thing sounds like "sttset is a test" which I don't know where that came from. And I still would like to know if it's ok to have REMOVED than 10 lines of code.
Rebecca Cocos
Yes, it is absolutely okay to have REMOVED than 10 lines of code. There are several right ways of doing this. I can't really answer the "how it sounds" question, since I don't know how it sounds. You can do the things I suggested earlier to check what you got. Mark Guzdial

Are we supposed to put the file in our program or can we just begin it to expect a file?
REMOVEDsan Holloman
You can directly reference the file (file = r"C:\...") and the TA will fix it when testing on his or her computer. Mark Guzdial


what's the code for writeSoundTo? i want to check my file in mediatools but i can't find the code

There are so many places to find it! Try the "Help" menu – Andrea Forte did a great job of documenting all the sound and picture functions there. It's in the slides and in the book, too. It's "writeSoundTo(sound,filename". Mark Guzdial


When you say we are supposed to enter the statement about not receiving any help into the comment area, do you mean the notes to TA area? or somewhere else?

Yes, notes to TA area. Mark Guzdial

Note from Mark

I was asked to post the ACTUAL sounds that I recorded and that I generated from my solution in JES, not the versions posted on the Take-Home Exams-Spring 2003 page. These won't sound great if you just click on them from a Windows box, but they'll work from JES or MediaTools.
Original recorded sound: thisisatest.wav
Solution sound: tsetisatest-jes.wav

I have now unlocked this page. If you would like to Attach your sounds for us to listen to, you may. That's acceptable to allow others to hear your output. Mark Guzdial



I can't make the file save as a sound. So when I pick the file and try to play it, I get the error "An error occurred attempting to pass an argument to a function." What am I doing wrong?

Did you turn the file into a sound first with makeSound()? I don't know what "I can't make the file save as a sound." mean. Are you getting the error when trying to do writeSoundTo? Mark Guzdial


Can you tell me how to find my file path on Mac
If you're using Mac OS X, the path will be "/Users/(yourusername)/(wherever you put your sound)/thisisatest.wav" try opening the file with pickAFile(), and then print that string to see how the location is formatted. Student57

I clicked on the link to hear the sound and tried to save it. But when I pull it up in Jes, it doesn't recognize the file as a sound. That is my problem. I can't even start the assignment right now because I can't get it to come up in Jes as a soundfile.
To save the file correctly, right-click on the link thisisatest.wav, and select save as... Select a place to save the file, and press ok. If you can open it in winamp or some other sound editor, you did it right. Student57

I don't know if you can answer this question or not; but I think that I have my code correct, however, whenever I try to get my recipe to play everything goes fine, until I get to when I type backSpliced() into the black box. When I type this in it goes to where I would pick a file, but I have already chosen a file at this point. Is there anything that I am doing wrong? Allison Weathers

K, nevermind the first question, I figured that one out, but now I have another problem. I got the sound to play, but it wasn't saying the right words, so I had to change some of the numbers. It now says that I am having a problem with a line in my recipe, but I know that the line is necessary and that it is typed and spaced correctly. The line is "source = makeSound(file)", do you have any suggestions? Thank you!
Allison Weathers
Make sure that file is what you think it is. Also, if makeSound is not purple, there's a character misplaced. Student57
You can also put "print file" in the file, just before the source= line, so what file is. Mark Guzdial

I just wanted to let everyone know– I did this all by myself, and got it right. It is the most exciting thing in the world AND now I can have a life tonight! HAHA. :) Kelly Farrell



i AM HAVING PROBLEM SILENCING THE "THIS"

You're copying the backwards "Test" right on top of it. You shouldn't hear the "This," except maybe at the very start or very end if you don't cover all of it (depending on how you write your program). Mark Guzdial


I first spliced the entire sound, then try to backward the word test alone but I am still hearing the "t" or "this".
Elijah
I wouldn't sweat the little details – if you splice it in backwards, that's the main point. You can adjust where the splice occurs by adjusting your index numbers. Mark Guzdial

I got it!!!!!!!!!!!!!! BOW TO ME JES! FOR I AM NO LONGER A PADAOUIN LEARNER! NOW I AM THE MASTER!
Student157



<big grin!> You go, Master Luke! Mark Guzdial


Okay, the file is saved to my computer, but after I makeSound(file) and then try to play it, it says the input is not a sound. What is going on? I can't even start this because it's not even being recognized.

Print whatever you're trying to play(). What is it? If it doesn't say it's a sound, it's not. Maybe it's a file? Or a sample? Mark Guzdial

Side Note

I just got an interesting new study on predictors of success in introductory computer science courses. One of the strongest predictors was the number of runs (attempted executions) of programs – experiments, even if not correct. TRY things!. Don't just "stare at the screen." Trying printing values, try different commands, modify your program with print statements and save it under a different name, use MediaTools to explore your media, and on and on. The REMOVED that you try things, the study says, the better the odds of success. Mark Guzdial



It is a sound. When I print it, it's saying media.sound blah blah blah. But then I got to play(file) and it says Input is not a sound. And error occurred attempting to pass an argument to a function.
You shouldn't be executing play(file). Do play on whatever thing said it was a sound. Mark Guzdial

i got this at first too, try to put the r in front of the string because of the /t in the string. python reads this as a tab and so it doesn't read it as anything on your computer. i don't know if this will help you but it helped me.
jessica

I keep getting the error message "An attempt was made to call a function with a parameter of an invalid type" when i try to run my program... i dont know what to do!! I dont know what that means... i dont know what to look for to change! Can someone PLEASE help me!?
It means that one of the arguments to the function is not what it's supposed to be. If the function required a string and you pass it a picture, it's going to throw that error. Also, if you have your arguments out of order it will throw that same error. For instance, getPixel(pic, x, y) requires pic to be a picture and x and y to be integers. If you try to call getPixel( x, y, pic) you will get that error because it expects the first argument to be a picture, and you've given it an integer. Student57
Here's a tip on using JES: Under the Edit menu, there is an item called Options. Select it. Change the "Mode:" from "Normal" to "Expert." You don't have to restart JES. What this will do is to give you REMOVED information in your error messages. Some of it may confuse you, but some of it may be helpful. For example, if you get an error where it doesn't a name, it'll tell you which name it can't find. See if that helps you make sense of your errors. Mark Guzdial

I think I like CS :)! Purposely blank
Shhhhh! If it gets out, everyone will want in! :-) Mark Guzdial


Does the 10 lines of code include th def,print, and return line?
It did in mine, but your mileage may vary: There is REMOVED than one way to solve this problem, and they would require different number of lines. Mark Guzdial

Is there partial credit? For instance, if I could get it to say "test is a tset"? I'm going to continue working on it, but if I can't get it, would there be partial credit?
nevermind... i got it! yay! i like cs again!!!

I did it all by myself!!!! i am soo happy that i can't stop listening to tset is a test!!!! bijal

i'm just glad that's over!!!



Link to this Page