Three MIDI channels (V0, V1, V2) have Trumpet, Vibraphone, and Acoustic Bass instruments used in this trio.
We again use StringBuilder class to create our string pattern.
package jfugue21;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import org.jfugue.pattern.Pattern;
import org.jfugue.player.Player;
public class JFugue21 extends Application {
public static void main(String[] args) {
launch(args);
}
TextArea text;
Button button;
@Override
public void start(Stage primaryStage) throws Exception {
button = new Button("Play Autumn \n\tLeaves\n in a Jazz trio");
button.setOnAction(e->example());
button.setFont(Font.font("Verdana", 16));
button.setPrefSize(200, 100);
VBox examples = new VBox(10, button);
examples.setPadding(new Insets(10));
text = new TextArea();
text.setPrefRowCount(20);
text.setPrefColumnCount(32);
text.setFont(Font.font("Verdana", 20));
text.setEditable(false);
text.setWrapText(true);
HBox root = new HBox(50,examples,text);
Scene scene = new Scene(root, 900, 600);
primaryStage.setTitle("JFugue 21. Autumn Leaves in a Jazz trio");
primaryStage.setScene(scene);
primaryStage.show();
}
private void example() {
Player player = new Player();
StringBuilder sb = new StringBuilder();
sb.append(" V0 I[TRUMPET] Rq E6q F#6q G5q C6w Ri D5q. ");
sb.append(" E5q F#5q B5q. B5hi ");
sb.append(" Rq C5q D5q E5q A5w Ri B4q. A5q G5q E5w. ");
sb.append(" V1 I[VIBRAPHONE] Rw E4+G4+A4+C5h E4+G4+A4+C5q Rq ");
sb.append(" E4+F#4+A4+C4q ");
sb.append(" Rh. D4+F#4+G4+B4h D4+F#4+G4+B4q ");
sb.append(" Rq C4+E4+G4+B4q Rh. E4+F#4+A4+C5h ");
sb.append(" E4+F#4+A4+C5q ");
sb.append(" Rq D#4+F#4+A4+B4q Rh. E4+G4+B4h ");
sb.append(" D#4+F#4+A4+B4q ");
sb.append(" Rq E4+G4+B4h Rh ");
sb.append(" V2 I[ACOUSTIC_BASS] Rw A3q Ri A3i E3h D3q Ri ");
sb.append(" D3i A3h G3q Ri ");
sb.append(" G3i D3h C3q ");
sb.append(" Ri C3i G3h F#3q Ri F#3i C3h B2q Ri B2i F#3h E3q ");
sb.append(" Ri E3i E3q B2q E3h Rh ");
Pattern pattern = new Pattern(sb.toString());
pattern.setTempo(140);
text.appendText("Playing pattern:\n" + pattern + "\n\n");
player.play(pattern);
}
}
This is the output after 2 plays:
No comments:
Post a Comment