JFugue Duration map string-millisecond based on BPM

43 views Asked by At

Is there a way to get millisecond duration of a jfugue duration like w, given a specific BPM rate?

Something like:

int millisDuration = durationManager.getMillis("w", 120);
1

There are 1 answers

4
David Koelle On BEST ANSWER

At the moment, the closest thing is a method in NoteSubparser called getDurationForString("UPPERCASE STRING"), which will return a double that represents the portion of a whole note that the string is. For example, passing "H" for a half-note will return 0.5. The string can be arbitrarily complex, such as "WWWH." (three whole notes and a dotted half), which will return 3.75. Since the value returned is relative to beats, and you have a BPM in mind, you should be able to calculate the milliseconds from that.

Use NoteSubparser.getInstance() to get an instance of NoteSubparser, then call getDurationForString("W") (Edit: It's necessary to use capital letters when calling parser code directly like this).