Skip to content

Commit 1798ad9

Browse files
qsalkindqsalkind
authored andcommitted
Merge branch 'master' into MyStuffRightNow
2 parents a8cad18 + c111f4f commit 1798ad9

File tree

1 file changed

+56
-6
lines changed

1 file changed

+56
-6
lines changed

src/scaleplayer/ScalePlayer.java

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,34 +72,84 @@ public void handle(ActionEvent event) {
7272
System.out.println("Hello World!");
7373
}
7474
});
75-
75+
7676
HBox hbox = new HBox();
7777
hbox.getChildren().addAll(playBtn, stopBtn);
7878
hbox.setSpacing(10);
7979
hbox.setCenterShape(true);
8080
hbox.setAlignment(Pos.CENTER);
8181

82-
83-
8482
BorderPane root = new BorderPane();
8583

8684
root.setTop(menuBar);
8785
root.setCenter(hbox);
8886

89-
90-
9187
Scene scene = new Scene(root, 300, 250);
9288

9389
primaryStage.setTitle("Scale Player");
9490
primaryStage.setScene(scene);
9591
primaryStage.show();
9692
}
9793

94+
public void playScale(int startingNote) {
95+
96+
MidiPlayer sequence = new MidiPlayer(2, 60);
97+
/**
98+
*
99+
* A convenience method for adding notes to the composition.
100+
*
101+
* @param pitch an integer from 0 to 127 giving the pitch
102+
* @param volume an integer from 0 to 127 giving the volume
103+
* @param startTick tells when the note is to start playing (in ticks)
104+
* @param duration the number of ticks the note is to play
105+
* @param channel an integer from 0 to 15; each channel typically
106+
* corresponds to a different instrument. The default
107+
* instrument for all channels is the grand piano.
108+
* @param trackIndex an integer from 0 to 7 giving the track for the note
109+
* pitch, volume, startTick, duration,
110+
channel, trackIndex
111+
*/
112+
sequence.addNote(50, 100, 1, 1,
113+
1, 1);
114+
sequence.addNote(51, 100, 2, 1,
115+
1, 1);
116+
sequence.addNote(52, 100, 3, 1,
117+
1, 1);
118+
sequence.addNote(53, 100, 4, 1,
119+
1, 1);
120+
sequence.addNote(54, 100, 5, 1,
121+
1, 1);
122+
sequence.addNote(55, 100, 6, 1,
123+
1, 1);
124+
sequence.addNote(56, 100, 7, 1,
125+
1, 1);
126+
sequence.addNote(57, 100, 8, 1,
127+
1, 1);
128+
129+
sequence.addNote(57, 100, 10, 1,
130+
1, 1);
131+
sequence.addNote(56, 100, 11, 1,
132+
1, 1);
133+
sequence.addNote(55, 100, 12, 1,
134+
1, 1);
135+
sequence.addNote(54, 100, 13, 1,
136+
1, 1);
137+
sequence.addNote(53, 100, 14, 1,
138+
1, 1);
139+
sequence.addNote(52, 100, 15, 1,
140+
1, 1);
141+
sequence.addNote(51, 100, 16, 1,
142+
1, 1);
143+
sequence.addNote(50, 100, 17, 1,
144+
1, 1);
145+
sequence.play();
146+
}
147+
98148
/**
99149
* @param args the command line arguments
100150
*/
101151
public static void main(String[] args) {
102152
launch(args);
103153
}
104154

105-
}
155+
}

0 commit comments

Comments
 (0)