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

Questions on HW7-Spring2006

How do you make an onscreen music tool?

What? You're wondering too?

Ask your questions here, and we'll figure it out.


When you say riff, do you mean a certain sound file, as in give the user three sound files to chosse from?

Riff, I assume, is like those phrases we looked at in jMusic stuff...
~Jim

As Jim said. Mark Guzdial

OKAY... Our weave only inserts one copy of whatever ONCE...and it's pretty much always the second to the last sound... and it makes no sense - and it's confusing... AAH.WAV, AAH.WAV, AAH.WAV, AAH.WAV, clap!, AAH.WAV...

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH.wav

~Jennifer & Doroteya

So... the code for rhythm tool's weave, says that it will put in 10 copies of whatever, every num times. But when we tried it out - it only would put in 1 copy every num times. So is anyone else having trouble with their weave?????

~D&J

I haven't looked at the RythmTool code, but if it's what he showed us in class, that would be incorrect.
The tool he demonstrated in class only has 1 text field, so there was no way to specify both number of times to weave and number of times to skip. As I recall, the code simply used the input number for how many to skip and wove 1 copy each time... I'll take a look at it, see if that's what happens to me too :)
~Jim

Got it. It's ugly. :( The RythmTool uses something we won't need to touch: SoundElement. SoundElement's weave method has a loop that looks like this:
for (int i=1; i <= count; i++)
    {
      copy = nextOne.copyNode(); // Make a copy
      
      //Skip skipAmount nodes
      skipped = 1;
      while ((current.getNext() != null) && (skipped < skipAmount))
      {
        current = current.getNext();
        skipped++;
      };
      
      if (current.getNext() == null) // Did we actually get to the end early?
        break; // Leave the loop
      
      oldNext = current.getNext(); // Save its next
      current.insertAfter(copy); // Insert the copy after this one
      current = oldNext; // Continue on with the rest
    }
  }

Can you work out what it does?
It's going to go along skipping, then insert one copy, then go along skipping, then insert one copy, then go along skipping, then insert one copy, and so on until it has "gone along skipping, then inserted one copy" a total of 'count' times. This is opposed to inserting 'count' copies every certain number of nodes. And it'll break if it gets to the end before weavin the total number of times (like 10). Incidentally, I'd be interested in finding out which type of weave we are expected to do for this assignment...
~Jim


So, if I were to create a save button in my musictool, could that button count towards both the extra credit and the "other" button in the assignment?

do we have to create a score for the play button, or is there something I'm missing?

Well, what does your play button do? REMOVEDces are, it's going to call something that looks a whole lot like showFromMeOn in SongNode. Except that it will do Play.midi instead of View.notate.
Take a look at showFromMeOn and let me know if that makes it clearer... :)
~Jim

Jim, you're my hero.

I'll try to catch up on all of these at once.
  • Yes, a Save button would be a two-fer: Extra button AND extra credit.
  • You may not have to create a Score–Play.midi will play a Phrase, too. But you will have to assemble all the linked list nodes into a Phrase to do it.
  • As Jim said, the Weave in the existing RhythymTool is rather brain-dead. (My words – he's too polite.) You'll have to make one that makes more sense.
  • And I'll try to deal with Repeat in class. Mark Guzdial

Is the musictool suppose to have 1 or 2 inputs? Just for the weave and repeat I mean. The HW7 explanation confused me. That makes it sound like the musictool should have 3 inputs.
I think that that's the cleanest – one input for repeat, two inputs for weave, for a total of three. Maybe like the below: Mark Guzdial
Uploaded Image: SampleLayout-hw7.jpg

How do you label text fields. For example, for the weave button there should be two text fields. One for how many nodes to skip before inserting and how times to insert that node. So I would like to label the field for skipping and the field for inserting to make it clear which is for which.
Nabil and Jacob
Sounds great! How about using a JLabel like we've used several times now? Mark Guzdial

For the grid layout, how do you make different rows. Everytime we add a new panel, it adds the new panel to the right of the old panel but with a unifrom space between the panels.
Nabil and Jacob
I see Jim already got to this one...:-) Mark Guzdial

On a related note, if you add more elements than the grid can hold, it seems to add to the first row...
~Jim

How do you specify the rows and columns in the grid layout? Where are the directions for doing that? I couldn't find anything in the lecture slides.
~Nabil
That's because it's not there. If you want to go beyond the UI stuff we showed, you'll have to look it up. Fortunately, there are tons of good examples and tutorials on the Web, e.g. http://java.sun.com/docs/books/tutorial/uiswing/layout/grid.html Mark Guzdial

I was trying to make a save button, and I was wondering, do I have to modify a class so I can use the write.midi function or can I add it to an actionListener directly.
I don't see why you can't add it to the ActionListener. Mark Guzdial

Y'know a really easy and useful (and easy to implement) button to have would be "Clear". Just thinkin' out loud here... Mark Guzdial

:D You read our minds! We've made a Reset button, and we felt so unique. :) oh well.
I will attest, however, to the usefulness of such a button for testing–quitting and restarting the program is a pain.
~Jim

Okay... We got out repeat add to work... BUT - it adds it to the front - and possibly that is what weave is doing, we are wondering if pack() is collecting the nodes in reverse order?? Or something??
~D&J
Uh, why would pack() on the JFrame effect the linked list at all? Mark Guzdial

Alrighty... We've accepted the reverse order of this.. thing. NOW - the weave is only wanting to skip two and insert one... no matter what! Otherwise it won't work rather... it's pretty frustrating cause we have no clue what's wrong. (Oh - it is counting the empty sound that's created in the beginning as one of the nodes... so when it skips two - we hear only one node because we can't hear the empty sound.. if that makes any sense.) We could really use some help on this if someone has some time to sit and look at it.... help.. pleeasse..LIIIIIKKKEEEEE... Office hours??? tomorroow??? will we have them????
~D&J
Yes, I will have office hours tomorrow 2-3, and you're welcome to bring your problem to class. (Even send me code via email.) Yes, of course, the empty sound at the front is being counted – why wouldn't it? Think about it: How might you avoid that? (Hint: root.getNext().weave(...)) Mark Guzdial

Well, we weren't sure... We had looked at lots of things, so we were just curious. Yay for office hours! And I'll e-mail the code as well. We changed some stuff in SongNode.java, so I will send that as well. Thanks!!!!!
~Jennifer

So, adding the write.midi directly didn't seem to work too well....
For the people that have done it: Did you modify a class to use the write.midi function the same way you had to modify SongNode to use play.midi?
Java doesn't seem to recognize what write. midi is right now.....

Write is a class, so it has to be capitalized. And to access them, you'll have to do all the JMusic imports. Mark Guzdial




Link to this Page