Skip to content

Commit 05d87eb

Browse files
author
Pablo Fernandez
committed
final program
added comments
1 parent 49b2dec commit 05d87eb

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

src/scaleplayer/ScalePlayer.java

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@
1717
import javafx.*;
1818
import java.util.*;
1919

20-
2120
/**
2221
* This JavaFX app lets the user play scales.
2322
* @author Pablo Fernandez
2423
* @author Quinn Salkind
2524
* @since January 26, 2017
2625
*/
27-
2826
public class ScalePlayer extends Application {
2927

3028
private static int startingNote;
3129
private MidiPlayer sequence = new MidiPlayer(2, 60);
3230

31+
/**
32+
* Start: Handles the menu bar, buttons, exits, and events.
33+
* @param primaryStage
34+
*/
3335
@Override
3436
public void start(Stage primaryStage) {
3537

@@ -48,7 +50,11 @@ public void start(Stage primaryStage) {
4850
playBtn.setText("Play Scale");
4951
playBtn.setStyle("-fx-base: #b6e7c9;");
5052
playBtn.setOnAction(new EventHandler<ActionEvent>() {
51-
53+
54+
/**
55+
* Handles the start and gets a note from the user, and starts the MidiPlayer using sequence.
56+
* @param event
57+
*/
5258
@Override
5359
public void handle(ActionEvent event) {
5460
TextInputDialog dialog = new TextInputDialog();
@@ -73,7 +79,11 @@ public void handle(ActionEvent event) {
7379
stopBtn.setText("Stop Playing");
7480
stopBtn.setStyle("-fx-base: #eda6a6;");
7581
stopBtn.setOnAction(new EventHandler<ActionEvent>() {
76-
82+
83+
/**
84+
* Stops and Clears Scale on Stop Button trigger
85+
* @param event
86+
*/
7787
@Override
7888
public void handle(ActionEvent event) {
7989
stopScale(sequence);
@@ -100,32 +110,30 @@ public void handle(ActionEvent event) {
100110
primaryStage.setScene(scene);
101111
primaryStage.show();
102112
}
103-
113+
114+
/**
115+
* Stops the current MidiPlayer sequence
116+
* @param sequence
117+
*/
104118
public void stopScale(MidiPlayer sequence) {
105119
sequence.stop();
106120
}
107121

122+
/**
123+
* Clears the current MidiPlayer sequence
124+
* @param sequence
125+
*/
108126
public void clearScale(MidiPlayer sequence) {
109127
sequence.clear();
110128
}
111-
112-
public void playScale(MidiPlayer sequence, int startingNote) {
113-
/**
114-
*
115-
* A convenience method for adding notes to the composition.
116-
*
117-
* @param pitch an integer from 0 to 127 giving the pitch
118-
* @param volume an integer from 0 to 127 giving the volume
119-
* @param startTick tells when the note is to start playing (in ticks)
120-
* @param duration the number of ticks the note is to play
121-
* @param channel an integer from 0 to 15; each channel typically
122-
* corresponds to a different instrument. The default
123-
* instrument for all channels is the grand piano.
124-
* @param trackIndex an integer from 0 to 7 giving the track for the note
125-
* pitch, volume, startTick, duration,
126-
channel, trackIndex
129+
130+
/**
131+
* Plays a scale from the MidiPlayer that starts at startingNote
132+
* and continues for 8 pitches up, and 8 pitches down.
133+
* @param sequence
134+
* @param startingNote
127135
*/
128-
136+
public void playScale(MidiPlayer sequence, int startingNote) {
129137
for(int i=1; i<9; i++)
130138
{
131139
sequence.addNote(startingNote, 100, i, 1,
@@ -144,6 +152,7 @@ public void playScale(MidiPlayer sequence, int startingNote) {
144152
}
145153

146154
/**
155+
* Starts the program
147156
* @param args the command line arguments
148157
*/
149158
public static void main(String[] args) {

0 commit comments

Comments
 (0)