Results 1 to 1 of 1
Thread: Using JMusic to make Nodes
- 02-18-2010, 03:48 AM #1
Using JMusic to make Nodes
Down here is a SoloNode.java code that I am working on. I dont know how to do the last 2 methods, they are:
public Phrase collect()
public String toString()
The above program should work by typing the following in the Interaction Pane.Java Code:import jm.music.data.*; import jm.JMC; import jm.util.*; import jm.music.tools.*; public class SoloNode { /////////Fields/////////// private SoloNode next; private Note myNote; //////Constructurs///// public SoloNode(){ this.next = null; this.myNote = new Note(); } public SoloNode(Note myNote) { this.myNote = new Note(); } /////Methods//////// public void setNode(Note myNote) { this.myNote = myNote; } public void setNext(SoloNode next) { this.next = next; } public Note getNote() { return this.myNote; } public SoloNode getNext() { return this.next; } }
SoloNode node1 = new SoloNode(new Note(C4,QN));
SoloNode node2 = new SoloNode(new Note(D4,QN));
SoloNode node3 = new SoloNode(new Note(E4,QN));
node1.setNext(node2);
node2.setNext(node3);
View.notate(node1.collect());
Following is the code from the book, that I am using as a reference.
Java Code:import jm.music.data.*; import jm.JMC; import jm.util.*; import jm.music.tools.*; public class SongNode { /////////Fields/////////// private SongNode next; private Phrase myPhrase; //////Constructurs///// public SongNode(){ this.next = null; this.myPhrase = new Phrase(); } /////Methods//////// public void setPhrase(Phrase thisPhrase) { this.myPhrase = thisPhrase; } public void setNext(SongNode nextOne) { this.next = nextOne; } public SongNode getNext() { return this.next; } private Phrase getPhrase() { return this.myPhrase; } private Note[] getNotes() { return this.myPhrase.getNoteArray(); } public void showFromMeOn(int instrument) { Score myScore = new Score("My Song"); myScore.setTimeSignature(3,4); myScore.setTempo(120.0); Part myPart = new Part(instrument); Phrase collector = new Phrase(); SongNode current = this; while (current != null) { collector.addNoteList(current.getNotes()); current = current.getNext(); } myPart.addPhrase(collector); myScore.addPart(myPart); View.notate(myScore); } }
Similar Threads
-
read nodes with same name but different atributes
By pankaj_salwan in forum XMLReplies: 0Last Post: 07-15-2009, 01:46 PM -
JcheckBoxes as JTree Nodes
By aneesahamedaa in forum AWT / SwingReplies: 11Last Post: 02-11-2009, 12:11 AM -
nodes
By Dr Gonzo in forum New To JavaReplies: 1Last Post: 12-08-2008, 04:22 PM -
nodes in java netowork
By ahsan in forum Advanced JavaReplies: 0Last Post: 12-26-2007, 03:11 PM -
nodes in java
By ahsan in forum New To JavaReplies: 0Last Post: 12-26-2007, 03:09 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks