1
package org.herac.tuxguitar.player.impl.sequencer;
3
import org.herac.tuxguitar.song.models.TGDuration;
5
public class MidiTickPlayer {
7
private static final int SECOND_IN_MILLIS = 1000;
12
private long lastTime;
13
private long tickLength;
14
private boolean tickChanged;
16
public MidiTickPlayer(){
20
public void process() {
21
this.lastTime = this.time;
22
this.time = System.currentTimeMillis();
23
if(!this.tickChanged){
24
this.tick += (TGDuration.QUARTER_TIME * ((float)getTempo() * (float)(this.time - this.lastTime) / 60f) / SECOND_IN_MILLIS);
26
this.tickChanged = false;
29
public void clearTick(){
33
public int getTempo() {
37
public void setTempo(int tempo) {
41
public long getTick() {
45
public void setTick(long tick) {
47
this.tickChanged = true;
50
public long getTickLength() {
51
return this.tickLength;
54
public void notifyTick(long tick){
55
this.tickLength = Math.max(this.tickLength,tick);