![]() ![]() |
| |||||||||
| This page removed for FERPA compliance | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| 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. |
| 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 |
| 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 |
| Return must always be the last executed line in the function, but that's not what REMOVEDmmer's problem is. Mark Guzdial |
| 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 |
| You don't need to add any space at all. Mark Guzdial |
| It's probably fine – listen to mine and see what you think. Mark Guzdial |
| 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 |
| Always a good thing! Mark Guzdial |
| 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 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 |
| 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 |
| 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 |
| My solution is 10 lines long, too. Sounds okay to me! (Uh, no pun intended :-) Mark Guzdial |
| 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 |
| REMOVEDre, if you need them. I can't imagine a correct solution that involved nesting them, though. Mark Guzdial |
| 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 |
| You can directly reference the file (file = r"C:\...") and the TA will fix it when testing on his or her computer. Mark Guzdial |
| 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 |
| Yes, notes to TA area. Mark Guzdial |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 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 |
| <big grin!> You go, Master Luke! Mark Guzdial |
| 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 |
| You shouldn't be executing play(file). Do play on whatever thing said it was a sound. Mark Guzdial |
| 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 |
| Shhhhh! If it gets out, everyone will want in! :-) Mark Guzdial |
| 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 |