MinuetFigureListener.java
1    /* 
2        Assignment 1, problem 5: Program to play each of the Bach minuet figures in the MMW 
3     */
4    
5    package mmw;
6    
7    import composer.SComposer;
8    
9    import javax.swing.SwingUtilities;
10   
11   public class MinuetFigureListener {
12   
13       private void playTheNotes() {
14           SComposer c = new SComposer();
15           c.text();
16   
17           //Plays 1 through 5 (5 included) of the Bach (JSB) notes
18           bach1(c);
19   
20           //Plays 6 through 10 (10 included) of the Bach (JSB) notes
21           bach2(c);
22   
23           //Plays 11 through 15 (15 included) of the Bach (JSB) notes
24           bach3(c);
25           c.untext();
26       }
27   
28       private static void bach1(SComposer c) {
29           //Melodic sequence mms_31_JSB_M1 (consists of 1 note in 3 beats)
30           System.out.println("c.mm_31_JSB_M1...");
31           c.mms_31_JSB_M1();
32           space(c);
33   
34           //Melodic sequence mms_33_JSB_M2 (consists of 3 notes in 3 beats)
35           System.out.println("c.mms_33_JSB_M2...");
36           c.mms_33_JSB_M2();
37           space(c);
38   
39           //Melodic sequence mms_33_JSB_M3 (consists of 3 notes in 3 beats)
40           System.out.println("c.mms_33_JSB_M3...");
41           c.mms_33_JSB_M3();
42           space(c);
43   
44           //Melodic sequence mms_33_JSB_M4 (consists of 3 notes in 3 beats)
45           System.out.println("c.mms_JSB_M4...");
46           c.mms_33_JSB_M4();
47           space(c);
48   
49           //Melodic sequence mms_33_JSB_M5 (consists of 3 notes in 3 beats)
50           System.out.println("mms_33_JSB_M5...");
51           c.mms_33_JSB_M5();
52           space(c);
53       }
54   
55       private static void bach2(SComposer c) {
56           //Melodic sequence mms_34_JSB_M6 (consists of 4 notes in 3 beats)
57           System.out.println("mms_34_JSB_M6...");
58           c.mms_34_JSB_M6();
59           space(c);
60   
61           //Melodic sequence mms_34_JSB_M7 (consists of 4 notes in 3 beats)
62           System.out.println("mms_34_JSB_M7...");
63           c.mms_34_JSB_M7();
64           space(c);
65   
66           //Melodic sequence mms_34_JSB_M8 (consists of 4 notes in 3 beats)
67           System.out.println("mms_34_JSB_M8...");
68           c.mms_34_JSB_M8();
69           space(c);
70   
71           //Melodic sequence mms_35_JSB_M9 (consists of 5 notes in 3 beats)
72           System.out.println("mms_35_JSB_M9...");
73           c.mms_35_JSB_M9();
74           space(c);
75   
76           //Melodic sequence mms_35_JSB_M10 (consists of 5 notes in 3 beats)
77           System.out.println("mms_35_JSB_M10...");
78           c.mms_35_JSB_M10();
79           space(c);
80       }
81   
82       private static void bach3(SComposer c) {
83           //Melodic sequence mms_35_JSB_M11 (consists of 5 notes in 3 beats)
84           System.out.println("mms_35_JSB_M11...");
85           c.mms_35_JSB_M11();
86           space(c);
87   
88           //Melodic sequence mms_35_JSB_M12 (consists of 5 notes in 3 beats)
89           System.out.println("mms_35_JSB_M12...");
90           c.mms_35_JSB_M12();
91           space(c);
92   
93           //Melodic sequence mms_35_JSB_M13 (consists of 5 notes in 3 beats)
94           System.out.println("mms_35_JSB_M13...");
95           c.mms_35_JSB_M13();
96           space(c);
97   
98           //Melodic sequence mms_36_JSB_M14 (consists of 6 notes in 3 beats)
99           System.out.println("mms_36_JSB_M14...");
100          c.mms_36_JSB_M14();
101          space(c);
102  
103          //Melodic sequence mms_36_JSB_M15 (consists of 6 notes in 3 beats)
104          System.out.println("mms_36_JSB_M15...");
105          c.mms_36_JSB_M15();
106          space(c);
107      }
108  
109      public static void space(SComposer c) {
110          c.untext();
111          c.note().rest(2);
112          c.text();
113      }
114  
115      public MinuetFigureListener() {
116          playTheNotes();
117      }
118  
119      public static void main(String[] args) {
120          SwingUtilities.invokeLater(new Runnable() {
121              public void run() {
122                  new MinuetFigureListener();
123              }
124          });
125      }
126  }
127