How to do slurs, ties and dynamics in JFugue 5

57 Views Asked by At

How can I do slurs, ties and dynamics in JFugue 5?

Concerning the dynamics, I would like to have them for one pattern until I place another dynamic and I want to set the dynamic volume (for example "mp" | "setVolume(mp=48)" or something that works like this).

Pattern pattern1 = new Pattern();
pattern1.add("C5q. D5i E5q G5q | A5h G5h");
pattern1.add("E5q. F5i E5q D5q | C5w");

Pattern main_voice = new Pattern();
main_voice.add(pattern1);
main_voice.setTempo(120);

Player player = new Player();
player.play(main_voice);

I set the music like this, so I don't want to place the dynamics again in every row. Also, it's possible that slurs and ties must go over more than one line. Is this possible?

1

There are 1 best solutions below

0
David Koelle On

Durations in JFugue use the dash character to indicate a note that either keeps playing, continues playing, or stops playing, depending on where it is placed in relation to the duration characters. Notice "q-", "-w-", and "-h" in the line below. This must be applied to notes of the same note value (behind the scenes, the - inhibits the MIDI NoteOff or NoteOn calls).

pattern1.add("Ah Gq Cq- | C-w- | C-h Ah");

That would play C for a quarter, whole, and half duration with no interruption.

This next line produces the same music, but the measure characters are nice to have to make the music more readable.

pattern1.add("Ah Gq Cqwh Ah"); // This produces equivalent music but is harder to read

For dynamics that you don't want to add to each line, look into Pattern.addToEachNoteToken(). These examples use durations, but you can use dynamics instead (where 'a' is followed by the on-velocity (0-128) and 'd' is followed by the off-velocity (also 0-128)):

new Pattern("A B C").addToEachNoteToken("a80") // Results in "Aa80 Ba80 Ca80" 
new Pattern("A B C").addToEachNoteToken("a80 a100") // Results in "Aa80 Ba100 Ca80" (rolls back to a80 for third note) 
new Pattern("A B C").addToEachNoteToken("a80d10 a80d90 a100d90") // Results in "Aa80d10 Ba80d90 Ca100d90"

Other than these features, the Staccato string in JFugue was not meant to replicate all of the features of sheet music; it was created to make human-readable music easy to enter and read. So, not all sheet music dynamics are represented in JFugue, although there may be workarounds.