Chord inversions are indicated by ^ for 1st inversion, ^^ for second inversion, etc. after chord name.
We can also use use Cmaj^E for example, for Cmaj inversion with E as bass, etc.
package jfugue16;
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.realtime.RealtimePlayer;
public class JFugue16 extends Application {
public static void main(String[] args) {
launch(args);
}
RealtimePlayer realtimePlayer;
TextArea text;
Button button1, button2;
@Override
public void stop() {
realtimePlayer.close();
}
@Override
public void start(Stage primaryStage) throws Exception {
int w = 250, h = 100;
realtimePlayer = new RealtimePlayer();
button1 = new Button("Play Inversions 1");
button1.setOnAction( e-> example1());
button1.setPrefSize(w,h);
button1.setFont(Font.font("Verdana", 16));
button2 = new Button("Play Inversions 2");
button2.setOnAction( e-> example2());
button2.setPrefSize(w,h);
button2.setFont(Font.font("Verdana", 16));
VBox examples = new VBox(10, button1, button2);
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 16. Inversions");
primaryStage.setScene(scene);
primaryStage.show();
}
private void example1() {
String patt = "Cmaj Ri Cmaj^ Rs Cmaj^^ Ri Cmaj";
Pattern pattern = new Pattern(patt);
text.appendText("\nPattern:\t" + pattern);
realtimePlayer.play(pattern);
}
private void example2() {
String patt = "Cmaj Ri Cmaj^E Rs Cmaj^G Ri Cmaj";
Pattern pattern = new Pattern(patt);
text.appendText("\nPattern:\t" + pattern);
realtimePlayer.play(pattern);
}
}
This is the output:
No comments:
Post a Comment