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.