Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Questions on HW6-Fall2005

This is a big homework. Please do ask for help here if you run into difficulties!

When writing a solution to the homework, I found it useful to add the following method to SoundElement:
   * blocking-play the sound at this node.
  public void blockingPlay() {

It allows you to play the sound from a SoundElement node, as opposed to playing all sounds from that node on. #4

Right, or use to play just the sound whose node is pointed at by current Mark Guzdial

Does anyone know of a place where one could grab some really short sounds/sound effects to put into this thing? clap and the others are kinda boring.
Kyle DuPont

Google "free wav sounds" and you'll get lots, like Download them into your MediaSources directory and use them at will. (Be sure to include them in your turnin for ease of grading, please.) Mark Guzdial

So our animation can include anything just so long as there are different branches that move right?
Absolutely! Mark Guzdial

Since I'm setting my background as a picture, I have lines showing up when the other pictures are placed. I think you mentioned this is class the other day, but how do I make them go away? Student161
turtle.setPenDown(false); Mark Guzdial

The method that we use in order to build a list of sounds is to go in the soundElement class? When i did that i get a compiler error that says cannot resolve symbol: method buildSounds(). I'm trying to call the method inside my animation rendering program. When i put the method into the animation class, it doesn't have a compiler error, should it be there instead? why doesn't this function like scale() or flip() where you can call it anywhere?
Kyle DuPont

One way to do it is to have a buildSounds() method in your animation rendering program that sets the value of a SoundElement variable to the root of a list of SoundElement nodes, 1 for each frame you will be rendering. Then you can play the current sound every time you render a frame, then set the current to its next. #4

That's a complicated set of questions! (a) You should probably build up your sounds when you build your animation, so probably in setUp() in AnimationRunner. (b) That error says that you're calling buildSounds(), but the compiler can't find it. Is it in another class? What object are you calling the method on? (c) Putting a method named buildSounds() somewhere shouldn't generate an error. (d) scale() and flip() are called ON OBJECTS, e.g. pict.flip(), sound.scale(). You can't just call a method without an object reference. Mark Guzdial

Oh i have another question: I'm trying to play a sound every frame (my list of sounds can come out in the interactions pane). It gets to the point where it says: "There are no frames to show yet. When you add a frame it will be shown" but then right after that i get a "illegal argument exception: moved into tail"...whose tail did i move into? It seems to me that my buildSounds method isn't returning a linked list of sounds so i can't call the first element and subsequent elements in the list. I thought that return would output the linked list that i made in my loop?
Kyle DuPont

I've never seen that error, not sure. Could you post the entire error message, including the stack trace? #4

"There are no frames to show yet." isn't an error. It's just the FrameSequence announcing that you've "show"n it, but there's nothing to see until you add a frame. I've never seen a "moved into tail" error either. Can you show us the line of code where it happened? Mark Guzdial

I'm getting a problem with when I switch my lists (kinda like when you went from the wolves running toward to the wolves running away in your movie). Basically the error is:
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
and I just don't know what that means... Is there a problem in the fact that I remove two branches and insert two new ones? I was trying to do it like this:
The code looks right to me, Summer. What's at line 150 in your program? Where is "cloudsinbreeze" in your tree? If it's the very first thing, that might be a problem. In general, "NullPointerException" means that you have a link somewhere that's null, but you're trying to use it like it's really pointing to something. Mark Guzdial

And also, for the setPenDown(false) thing, I couldn't figure out really where it would go? Would I use it on the sceneroot or what? Student161
It's inside the class DrawableNode, in the method drawOn. It should already be there – check to see if it's not, or if it's set to "True" in your version.
Note that I won't be at office hours today, but I will tomorrow. Mark Guzdial

Just FYI for anyone, this is a really great site to download wav sound effects, you just search and it brings up a lots of different ones to choose from! Student161

I restarted my work on it today, and i no longer had that moved into tail error. I'm not really sure what that's all about. Anyway, i have my sound list working now and i know how to deal with putting sounds each frame. Thanks!
Kyle DuPont

Weird... Mark Guzdial

Is it alright to have the method that builds the sound data in the SoundElement Class and call the method from within the rendering method? I can't get it to work when i put the same code in the animation class. Also is there a way to cut off the sound once my frames run out but my sound is long so it keeps going?
Kyle DuPont

No, I don't think that that's a good idea. You shouldn't have to change SoundElement. If you're using blockingPlay(), the frames and sounds should be in synchrony. Mark Guzdial

Another method that you might find useful to add to SoundElement is:
   * Return my sound
  public Sound getSound(){return mySound;}

This allows you to say current.getSound().blockingPlay() Mark Guzdial

Oh the problem I have was that i was trying to play some theme music too, each frame already has a sound effect in it. So my computer is fast at first, but then the memory gets clogged or something i guess and the ending frames take a long time to render.
Kyle DuPont

Or you're using the old, where blockingPlay() takes too long. Mark Guzdial

If you'd like to chop up your longer sound into pieces, put the below method into your file and compile-all. I figured out why Summer's sound didn't work this morning. Her sound was sampled at 44,100 samples per second. New sounds, by default, are created at a 22050 sampling rate. The sound was there, but was too slow to hear. When I used a 22050 sound, it worked fine. Mark Guzdial
   * Return part of a sound
   * @param start where to start returning
   * @param end where to end returning
    public Sound portion(int start, int end){
      Sound retSound=new Sound((end-start)+1);
      int value = 0;
      // Basically, we simply copy from start to end into portion
      for (int source=start, target=0;
           source <= end;
           source++, target++)
      {value = this.getSampleValueAt(source);
      return retSound;

Link to this Page