Here you can find the source of formatMeasures(final int quartersPerMeasure, final double time, final int startOffset)
Parameter | Description |
---|---|
quartersPerMeasure | The number of quarters of a measure |
time | The time to format |
startOffset | An offset that is added to the measure, quarter and eights values |
public static String formatMeasures(final int quartersPerMeasure, final double time, final int startOffset)
//package com.java2s; // Licensed under LGPLv3 - http://www.gnu.org/licenses/lgpl-3.0.txt public class Main { /**//from w ww .ja v a 2 s.c o m * Format the given time as measure.quarters.eights. * * @param quartersPerMeasure The number of quarters of a measure * @param time The time to format * @param startOffset An offset that is added to the measure, quarter and eights values * @return The formatted text */ public static String formatMeasures(final int quartersPerMeasure, final double time, final int startOffset) { final int measure = (int) Math.floor(time / quartersPerMeasure); double t = time - measure * quartersPerMeasure; final int quarters = (int) Math.floor(t); // :1 t = t - quarters; // *1 final int eights = (int) Math.floor(t / 0.25); return measure + startOffset + "." + (quarters + startOffset) + "." + (eights + startOffset); } }