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

PreQuiz for 4March2005 Quiz

Consider the below addition to the class SoundTreeTest:

public class SoundTreeExample {

  ScaleBranch scaledBranch; // Needed between methods
  SoundBranch root;
  public SoundBranch root(){return root;}
//Ignore setUp()

    public void setUp2() {
    Sound clap = new Sound(FileChooser.getMediaPath("clap-q.wav"));
    Sound chirp = new Sound(FileChooser.getMediaPath("chirp-2.wav"));
    Sound rest = new Sound(FileChooser.getMediaPath("rest-1.wav"));
    Sound snap = new Sound(FileChooser.getMediaPath("snap-tenth.wav"));
    Sound clink = new Sound(FileChooser.getMediaPath("clink-tenth.wav"));
    Sound clave = new Sound(FileChooser.getMediaPath("clave-twentieth.wav"));
    Sound gong = new Sound(FileChooser.getMediaPath("gongb-2.wav"));
    Sound guzdial = new Sound(FileChooser.getMediaPath("guzdial.wav"));
    Sound is = new Sound(FileChooser.getMediaPath("is.wav"));
    root = new SoundBranch();
    SoundNode sn;
    SoundBranch branch1 = new SoundBranch();
    sn = new SoundNode(guzdial.append(is).append(snap));
    sn = new SoundNode(clink.append(snap).append(clave));
    sn = new SoundNode(guzdial.append(is).append(is));
    scaledBranch = new ScaleBranch(2.0);
    sn = new SoundNode(clink.append(clave).append(gong));
    sn = new SoundNode(rest.append(chirp).append(clap));
    scaledBranch = new ScaleBranch(0.5);
    sn = new SoundNode(guzdial.append(is).append(gong));

    SoundBranch branch2 = new SoundBranch();
    sn = new SoundNode(clap.append(clap).append(clave));
    sn = new SoundNode(snap.append(snap).append(clave));
    sn = new SoundNode(snap.append(snap).append(clave));

//Ignore the rest.


We'll execute this method like this:
> SoundTreeExample ste = new SoundTreeExample();
> ste.setUp2()

  1. Draw a diagram of what the nodes (branches, nodes, everything) connected to root will look like. Be sure to show what's contained in each node, and be sure to show what the child and next references point to – and distinguish between them.
  2. Describe the sound that we’ll hear.

Comments? Questions? Sample answers you'd like feedback on?

What's the significance of "public SoundBranch root(){return root;}"? I removed it and setUp2 played fine.
Hmmm...I typed in ste.root() and it returned a bunch of information on samples and next's

why do we use sound branches again? just to cluster sounds?

It's just a method for gaining access to the root outside the SoundTreeExample class – it's an accessor. We use SoundBranches to cluster sounds, and to apply operations (like scaling) to the children in the branch. A useful branch to build would be RepeatBranch that might repeat the children's sound a certain number of times. Mark Guzdial

Links to this Page