![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Asked and answered down the page. Thanks! Brittany Duncan |
| Changing that now. Sorry. Thanks! Brittany Duncan |
| Yes to both. Thanks! Brittany Duncan |
| How about 15 different notes? Basically use 5 different sound files at least 15 times. Thanks! Brittany Duncan |
| Yes they will – just like the other homeworks in which you used getMediaPath. Colin Potts |
| This is really difficult. You can fairly easily go up an octave by doubling frequency just by copying every other sample. Code for that will be available on the Coweb shortly. I think that a fifth is 1.5 times the frequency, and if so, you could transform a C into a G, for example (if you didn't already have the sound) by copying two out of every three samples. But changing by just a semitone would require you to know the exact ratio of the frequencies of an F and F sharp. If you take CS 1316, you can do stuff like this in Java, but for now I recommend sticking to C major. Colin Potts |
| Sure. No problem. Colin Potts |
| Up now. Thanks! Brittany Duncan |
| Definitely NOT Monday. It seems that the week before Spring Break is an assignment and test magnet for many classes, so having some extra time is reasonable. We will post an official announcement soon and change the homework assignment page to reflect that. Colin Potts |
| This is what happens when you miss class. You're asking about a concept that has been discussed on several occasions and is illustrated in many examples posted to the slides/code page. You can also catch up by reading the textbook. (Start with the index.) Colin Potts |
| A minimum of 2 sounds must be blended on at least 3 occasions throughout the clip. Thanks! Brittany Duncan |
| No. This makes life more difficult for us, but easier for you. Colin Potts |
| That is because blendCopy makes an empty sound that is longer than the longer of the two sounds it is given. So if you use it repeatedly and then add the resulting sound, you will have gaps. You would be better off starting with addInto, wouldn't you? Unlike blendCopy, addInto takes a sound (possibly silence, possibly already copied into) and adds another sound into it. You already should have created a long sound that you are going to add into. You will have to supply another argument to say where you want the added sound to go, since the published function only adds at the very beginning. Colin Potts |
| Think about what your program is doing by describing it in English. Every time you use the words "and" or "next", you've probably finished describing one possible function and are about to describe the next one. It's really up to you: any more advice is giving this to you on a plate. Colin Potts |
| getSampleValueAt takes a sample number and gives you the value of the sample at that position. So if you have 22,050 samples per second, and say x=getSampleValueAt(22050) you will get the value of the sample at the end of the first second (i.e. a number between -32k and +32k). If you do s=getSampleObjectAt(22050) you will get a sample at that position. This is very like p=getPixel(x, y) for pictures. A "sample object", like s in this case, is a sample (i.e. the smallest element of a sound), not a number. Finally, having got your sample, s, you can type x = getSample(s). This is confusing, but that's just the way things are... give getSample() a sample object and it will give you NOT a sample as the name would suggest, but that sample's value (a number). Experiment in the command area by making a sound and then trying these functions out. Colin Potts |
| I strongly, STRONGLY recommend using getSampleValueAt() primarily. Every sort of manipulation we'd ask you to do can be done with it, in a fairly straightforward way; the others are, as Colin said, a bit confusing. getSampleValueAt() allows for a comparatively easier way to manipulate just portions of a song, as well. Chris Phillips |
def makeMusic(): sound1 = nearlyScale(dir, str(string)) sound2 = nearlyScale(dir, str(bassoon)) blendCopy(sound1, sound2)
| You aren't really understanding the concept of casting variables as strings. You are trying to make the string variable a string. Instead, you just need to tell JES that string is a word when you create it, by saying "string". If you still don't understand, please see a TA at office hours or read in the book about filenames. Thanks! Brittany Duncan |
| The returned value is available in the function that made the call, not in any function. By analogy, if a manager (function1) asks a subordinate (function2) to generate a report (the returned value), the manager can use the report. But other employees (including the manager's own manager) cannot unless the manager gives it to them. Colin Potts |
fileName = str(dir) + os.sep + "string-" + note + "4.wav"
sound = makeSound(fileName)
| If you are using setMediaPath(), then try using this line instead - fileName=getMediaPath("string-"+note+"4.wav") Chris Phillips |
setSampleValueAt(canvas, position+start-1, value)
| You're falling off the end of your sound canvas. Either you didn't make it long enough to accommodate all the samples you are copying or the value position+start+1 is wrong and you really should be copying to a lower sample number. Colin Potts |
def mainFunction():
def subFunction(variable):
return variable
| Your example doesn't illustrate your question. In answer to your question: No. With regard to your illustration: (a) Don't forget to add code tags on so that your code is readable on the Coweb. (I have done this for you). (b) You are trying to DEFINE (not use) one function inside the definition of another. (c) It's not a good idea to return a variable that was passed in as a parameter (the variable named "variable" in your case). It's better to create a variable inside your function that you will return. Colin Potts |
| You possibly copied the code that I posted intitially. I corrected it last week. The error is in the line of code that creates the blank canvas. (Well, that's obvious, isn't it?) And it must be making a canvas that is many times (hint, hint) too long. I don't know whether this will shorten the execution time. That could be a sign that you have also nested your loops incorrectly. Colin Potts |
| Are you storing it in a variable when it is returned? For example: "value = subfunction(foo, bar)" Thanks! Brittany Duncan |
| That would only produce one note, but why are you having 12 functions take in 1 sound? Why don't you just create 5 sounds and use those? This is very possible. If you are still confused, please see a TA at office hours or speak to someone on AIM. Thanks! Brittany Duncan |
| You have to add it. Chris Phillips |