@@ -56,34 +56,84 @@ public void handle(ActionEvent event) {
5656 System .out .println ("Hello World!" );
5757 }
5858 });
59-
59+
6060 HBox hbox = new HBox ();
6161 hbox .getChildren ().addAll (playBtn , stopBtn );
6262 hbox .setSpacing (10 );
6363 hbox .setCenterShape (true );
6464 hbox .setAlignment (Pos .CENTER );
6565
66-
67-
6866 BorderPane root = new BorderPane ();
6967
7068 root .setTop (menuBar );
7169 root .setCenter (hbox );
7270
73-
74-
7571 Scene scene = new Scene (root , 300 , 250 );
7672
7773 primaryStage .setTitle ("Scale Player" );
7874 primaryStage .setScene (scene );
7975 primaryStage .show ();
8076 }
8177
78+ public void playScale (int startingNote ) {
79+
80+ MidiPlayer sequence = new MidiPlayer (2 , 60 );
81+ /**
82+ *
83+ * A convenience method for adding notes to the composition.
84+ *
85+ * @param pitch an integer from 0 to 127 giving the pitch
86+ * @param volume an integer from 0 to 127 giving the volume
87+ * @param startTick tells when the note is to start playing (in ticks)
88+ * @param duration the number of ticks the note is to play
89+ * @param channel an integer from 0 to 15; each channel typically
90+ * corresponds to a different instrument. The default
91+ * instrument for all channels is the grand piano.
92+ * @param trackIndex an integer from 0 to 7 giving the track for the note
93+ * pitch, volume, startTick, duration,
94+ channel, trackIndex
95+ */
96+ sequence .addNote (50 , 100 , 1 , 1 ,
97+ 1 , 1 );
98+ sequence .addNote (51 , 100 , 2 , 1 ,
99+ 1 , 1 );
100+ sequence .addNote (52 , 100 , 3 , 1 ,
101+ 1 , 1 );
102+ sequence .addNote (53 , 100 , 4 , 1 ,
103+ 1 , 1 );
104+ sequence .addNote (54 , 100 , 5 , 1 ,
105+ 1 , 1 );
106+ sequence .addNote (55 , 100 , 6 , 1 ,
107+ 1 , 1 );
108+ sequence .addNote (56 , 100 , 7 , 1 ,
109+ 1 , 1 );
110+ sequence .addNote (57 , 100 , 8 , 1 ,
111+ 1 , 1 );
112+
113+ sequence .addNote (57 , 100 , 10 , 1 ,
114+ 1 , 1 );
115+ sequence .addNote (56 , 100 , 11 , 1 ,
116+ 1 , 1 );
117+ sequence .addNote (55 , 100 , 12 , 1 ,
118+ 1 , 1 );
119+ sequence .addNote (54 , 100 , 13 , 1 ,
120+ 1 , 1 );
121+ sequence .addNote (53 , 100 , 14 , 1 ,
122+ 1 , 1 );
123+ sequence .addNote (52 , 100 , 15 , 1 ,
124+ 1 , 1 );
125+ sequence .addNote (51 , 100 , 16 , 1 ,
126+ 1 , 1 );
127+ sequence .addNote (50 , 100 , 17 , 1 ,
128+ 1 , 1 );
129+ sequence .play ();
130+ }
131+
82132 /**
83133 * @param args the command line arguments
84134 */
85135 public static void main (String [] args ) {
86136 launch (args );
87137 }
88138
89- }
139+ }
0 commit comments