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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/player/base/MidiPlayerMode.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
package org.herac.tuxguitar.player.base;
 
2
 
 
3
public class MidiPlayerMode{
 
4
        
 
5
        public static final int DEFAULT_TEMPO_PERCENT = 100;
 
6
        
 
7
        public static final int TYPE_SINGLE = 1;
 
8
        public static final int TYPE_CUSTOM = 2;
 
9
        
 
10
        private int type;
 
11
        private boolean loop;
 
12
        private int singlePercent;
 
13
        private int customPercentFrom;
 
14
        private int customPercentTo;
 
15
        private int customPercentIncrement;
 
16
        
 
17
        private int currentPercent;
 
18
        
 
19
        public MidiPlayerMode(){
 
20
                this.loop = false;
 
21
                this.type = TYPE_SINGLE;
 
22
                this.singlePercent = DEFAULT_TEMPO_PERCENT;
 
23
                this.customPercentFrom = DEFAULT_TEMPO_PERCENT;
 
24
                this.customPercentTo = DEFAULT_TEMPO_PERCENT;
 
25
                this.customPercentIncrement = 0;
 
26
                this.reset();
 
27
        }
 
28
        
 
29
        public void reset(){
 
30
                if(getType() == TYPE_SINGLE){
 
31
                        this.currentPercent = getSinglePercent();
 
32
                }
 
33
                else if(getType() == TYPE_CUSTOM){
 
34
                        this.currentPercent = getCustomPercentFrom();
 
35
                }
 
36
        }
 
37
        
 
38
        public void notifyLoop(){
 
39
                if(getType() == TYPE_SINGLE){
 
40
                        this.currentPercent = getSinglePercent();
 
41
                }
 
42
                else if(getType() == TYPE_CUSTOM){
 
43
                        this.currentPercent = (Math.min(getCustomPercentTo(),(getCurrentPercent() + getCustomPercentIncrement())));
 
44
                }
 
45
        }
 
46
        
 
47
        public int getCurrentPercent(){
 
48
                return this.currentPercent;
 
49
        }
 
50
        
 
51
        public boolean isLoop() {
 
52
                return this.loop;
 
53
        }
 
54
        
 
55
        public void setLoop(boolean loop) {
 
56
                this.loop = loop;
 
57
        }
 
58
        
 
59
        public int getType() {
 
60
                return this.type;
 
61
        }
 
62
        
 
63
        public void setType(int type) {
 
64
                this.type = type;
 
65
        }
 
66
        
 
67
        public int getCustomPercentFrom() {
 
68
                return this.customPercentFrom;
 
69
        }
 
70
        
 
71
        public void setCustomPercentFrom(int customPercentFrom) {
 
72
                this.customPercentFrom = customPercentFrom;
 
73
        }
 
74
        
 
75
        public int getCustomPercentIncrement() {
 
76
                return this.customPercentIncrement;
 
77
        }
 
78
        
 
79
        public void setCustomPercentIncrement(int customPercentIncrement) {
 
80
                this.customPercentIncrement = customPercentIncrement;
 
81
        }
 
82
        
 
83
        public int getCustomPercentTo() {
 
84
                return this.customPercentTo;
 
85
        }
 
86
        
 
87
        public void setCustomPercentTo(int customPercentTo) {
 
88
                this.customPercentTo = customPercentTo;
 
89
        }
 
90
        
 
91
        public int getSinglePercent() {
 
92
                return this.singlePercent;
 
93
        }
 
94
        
 
95
        public void setSinglePercent(int singlePercent) {
 
96
                this.singlePercent = singlePercent;
 
97
        }
 
98
        
 
99
}