~ubuntu-branches/ubuntu/oneiric/tuxguitar/oneiric

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/song/models/Tempo.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mto: (5.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20080619003030-h719szrhsngou7c6
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Created on 29-nov-2005
3
 
 *
4
 
 * TODO To change the template for this generated file go to
5
 
 * Window - Preferences - Java - Code Style - Code Templates
6
 
 */
7
 
package org.herac.tuxguitar.song.models;
8
 
 
9
 
import java.io.Serializable;
10
 
 
11
 
/**
12
 
 * @author julian
13
 
 *
14
 
 * TODO To change the template for this generated type comment go to
15
 
 * Window - Preferences - Java - Code Style - Code Templates
16
 
 */
17
 
public class Tempo implements Serializable{
18
 
        private static final int SECOND_IN_MILLIS = 1000;
19
 
        
20
 
    private int value;
21
 
    
22
 
    private int percent;
23
 
    
24
 
    public Tempo(int value,int percent){
25
 
        this.value = value;
26
 
        this.percent = percent;
27
 
    }
28
 
    
29
 
    public Tempo(int value){
30
 
        this(value,100);
31
 
    }
32
 
    
33
 
    public int getValue() {
34
 
        return value;
35
 
    }
36
 
    
37
 
    public void setValue(int value) {
38
 
        this.value = value;
39
 
    }
40
 
    
41
 
    public int getPercent() {
42
 
                return percent;
43
 
        }
44
 
 
45
 
        public void setPercent(int percent) {
46
 
                this.percent = percent;
47
 
        }
48
 
 
49
 
        public long getInMillis(){        
50
 
        double millis = (((60.00 / (double)getValue() * (double)SECOND_IN_MILLIS)) * (double)getPercent() / 100.00);
51
 
        return (long)millis;       
52
 
    }
53
 
    
54
 
    public long getInUSQ(){        
55
 
        double usq = (((60.00 / (double)getValue() * (double)SECOND_IN_MILLIS) * 1000.00) * (double)getPercent() / 100.00);
56
 
        return (long)usq;       
57
 
    }
58
 
    
59
 
    public static Tempo fromUSQ(int usq){
60
 
        double value = ((60.00 * (double)SECOND_IN_MILLIS) / ((double)usq / 1000.00));
61
 
        return new Tempo((int)value);
62
 
    }
63
 
    
64
 
    public Object clone(){
65
 
        return new Tempo(getValue(),getPercent());
66
 
    }
67
 
}