We use the string instrument with Haydn Opus 64 no 5.
We use absolute timing. You could also use different voices and set appropriate rest at start. The StringBuilder class is used to build our pattern string.
package jfugue20;
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 JFugue20 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 \nHaydn, Opus 64\nno 5");
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 20. Haydn Opus 64 no 5");
primaryStage.setScene(scene);
primaryStage.show();
}
private void example() {
Player player = new Player();
StringBuilder sb = new StringBuilder();
sb.append(" A6i Ri A6i Ri A6i Ri A6w A7h. E7i D7i D7h ");
sb.append(" C#7i. D7s D7i. C#7t D7t E7q ");
sb.append(" @3.0 F#5q G5q F#5q E5q D5q Rh. G5q A5q G5q ");
sb.append(" F#5q E5q ");
sb.append(" @3.0 D5q E5q D5q A4q F#4q Rh. E5q F#5q E5q ");
sb.append(" D5q C#5q ");
sb.append(" @7.0 D3q F#3q A3q D4q A3q Rh. A3q ");
Pattern pattern = new Pattern(sb.toString());
pattern.setTempo(104);
pattern.setInstrument("SYNTH_STRINGS_1");
text.appendText("Playing pattern:\n" + pattern + "\n\n");
player.play(pattern);
}
}
This is the output after playing 2 times:
No comments:
Post a Comment