2626 */
2727public class ScalePlayer extends Application {
2828
29- //TODO: Why does this field exist?
30- private static int startingNote ;
31- //TODO: Could this field be static, final?
32- private MidiPlayer sequence = new MidiPlayer (2 , 60 );
29+ private static int startingNote ; // Needed for method calls
30+ private static MidiPlayer sequence = new MidiPlayer (2 , 60 );
3331
3432 @ Override
3533 public void start (Stage primaryStage ) throws Exception {
@@ -44,7 +42,6 @@ public void start(Stage primaryStage) throws Exception {
4442
4543 }
4644 }
47-
4845
4946 @ FXML
5047 private MenuItem closeItem ;
@@ -77,7 +74,6 @@ void handleStartClick(ActionEvent event) {
7774 clearScale (sequence );
7875 playScale (sequence , startingNote );
7976 }
80-
8177 }
8278
8379 @ FXML
@@ -88,20 +84,21 @@ void handleStopClick(ActionEvent event) {
8884
8985 /**
9086 * Stops the current MidiPlayer sequence
91- * @param sequence //TODO: What is it?
87+ * @param sequence
88+ * Stops the scale, method is built in case functionality requirements
89+ * should grow in future versions
9290 */
93- //TODO: Why is this public?
94- public void stopScale (MidiPlayer sequence ) {
95- //TODO: Why do you need to define a one line method?
91+ private void stopScale (MidiPlayer sequence ) {
9692 sequence .stop ();
9793 }
9894
9995 /**
10096 * Clears the current MidiPlayer sequence
10197 * @param sequence
98+ * Clears the scale, method is built in case functionality requirements
99+ * should grow in future versions.
102100 */
103101 public void clearScale (MidiPlayer sequence ) {
104- //TODO: See above
105102 sequence .clear ();
106103 }
107104
@@ -112,27 +109,20 @@ public void clearScale(MidiPlayer sequence) {
112109 * @param startingNote
113110 */
114111 private void playScale (MidiPlayer sequence , int startingNote ) {
115- //TODO: Fix this so it's a Do-Re-Mi scale
116- //https://en.wikipedia.org/wiki/Solfège#Major
117- //TODO: Replace magic numbers with constants
118- //TODO: Fix indentation
119- for (int i =1 ; i <9 ; i ++)
120- {
112+ int [] scale = {0 ,2 ,2 ,1 ,2 ,2 ,2 ,1 ,0 ,0 ,1 ,2 ,2 ,2 ,1 ,2 ,2 };
113+ for (int i =1 ; i <9 ; i ++) {
114+ startingNote = startingNote + scale [i -1 ];
121115 sequence .addNote (startingNote , 100 , i , 1 ,
122116 1 , 1 );
123- startingNote = startingNote + 1 ;
124117 }
125-
126- startingNote = startingNote - 1 ;
127- for (int i =10 ; i <18 ; i ++)
128- {
118+ for (int i =10 ; i <18 ; i ++) {
119+ startingNote = startingNote - scale [i -1 ];
129120 sequence .addNote (startingNote , 100 , i , 1 ,
130121 1 , 1 );
131- startingNote = startingNote - 1 ;
132122 }
133- sequence .play ();
123+ sequence .play ();
134124 }
135-
125+
136126 /**
137127 * Starts the program
138128 * @param args the command line arguments
0 commit comments