1 package org.herac.tuxguitar.song.models;
2 
3 import org.herac.tuxguitar.song.factory.TGFactory;
4 
5 public abstract class TGChannel {
6 	public static final short DEFAULT_PERCUSSION_CHANNEL = 9;
7 
8 	public static final short DEFAULT_INSTRUMENT = 25;
9 	public static final short DEFAULT_VOLUME = 127;
10 	public static final short DEFAULT_BALANCE = 64;
11 	public static final short DEFAULT_CHORUS = 0;
12 	public static final short DEFAULT_REVERB = 0;
13 	public static final short DEFAULT_PHASER = 0;
14 	public static final short DEFAULT_TREMOLO = 0;
15 
16 	private short channel;
17 	private short effectChannel;
18 	private short instrument;
19 	private short volume;
20 	private short balance;
21 	private short chorus;
22 	private short reverb;
23 	private short phaser;
24 	private short tremolo;
25 
TGChannel()26 	public TGChannel() {
27 		this.channel = 0;
28 		this.effectChannel = 0;
29 		this.instrument = DEFAULT_INSTRUMENT;
30 		this.volume = DEFAULT_VOLUME;
31 		this.balance = DEFAULT_BALANCE;
32 		this.chorus = DEFAULT_CHORUS;
33 		this.reverb = DEFAULT_REVERB;
34 		this.phaser = DEFAULT_PHASER;
35 		this.tremolo = DEFAULT_TREMOLO;
36 	}
37 
getBalance()38 	public short getBalance() {
39 		return this.balance;
40 	}
41 
setBalance(short balance)42 	public void setBalance(short balance) {
43 		this.balance = balance;
44 	}
45 
getChannel()46 	public short getChannel() {
47 		return this.channel;
48 	}
49 
setChannel(short channel)50 	public void setChannel(short channel) {
51 		this.channel = channel;
52 	}
53 
getEffectChannel()54 	public short getEffectChannel() {
55 		return this.effectChannel;
56 	}
57 
setEffectChannel(short effectChannel)58 	public void setEffectChannel(short effectChannel) {
59 		this.effectChannel = effectChannel;
60 	}
61 
getChorus()62 	public short getChorus() {
63 		return this.chorus;
64 	}
65 
setChorus(short chorus)66 	public void setChorus(short chorus) {
67 		this.chorus = chorus;
68 	}
69 
getInstrument()70 	public short getInstrument() {
71 		return (!this.isPercussionChannel()?this.instrument:0);
72 	}
73 
setInstrument(short instrument)74 	public void setInstrument(short instrument) {
75 		this.instrument = instrument;
76 	}
77 
getPhaser()78 	public short getPhaser() {
79 		return this.phaser;
80 	}
81 
setPhaser(short phaser)82 	public void setPhaser(short phaser) {
83 		this.phaser = phaser;
84 	}
85 
getReverb()86 	public short getReverb() {
87 		return this.reverb;
88 	}
89 
setReverb(short reverb)90 	public void setReverb(short reverb) {
91 		this.reverb = reverb;
92 	}
93 
getTremolo()94 	public short getTremolo() {
95 		return this.tremolo;
96 	}
97 
setTremolo(short tremolo)98 	public void setTremolo(short tremolo) {
99 		this.tremolo = tremolo;
100 	}
101 
getVolume()102 	public short getVolume() {
103 		return this.volume;
104 	}
105 
setVolume(short volume)106 	public void setVolume(short volume) {
107 		this.volume = volume;
108 	}
109 
isPercussionChannel()110 	public boolean isPercussionChannel(){
111 		return TGChannel.isPercussionChannel(this.getChannel());
112 	}
113 
isPercussionChannel(int channel)114 	public static boolean isPercussionChannel(int channel){
115 		return (channel == DEFAULT_PERCUSSION_CHANNEL);
116 	}
117 
setPercussionChannel(TGChannel channel)118 	public static void setPercussionChannel(TGChannel channel){
119 		channel.setChannel(DEFAULT_PERCUSSION_CHANNEL);
120 		channel.setEffectChannel(DEFAULT_PERCUSSION_CHANNEL);
121 	}
122 
newPercussionChannel(TGFactory factory)123 	public static TGChannel newPercussionChannel(TGFactory factory){
124 		TGChannel channel = factory.newChannel();
125 		TGChannel.setPercussionChannel(channel);
126 		return channel;
127 	}
128 
clone(TGFactory factory)129 	public TGChannel clone(TGFactory factory){
130 		TGChannel channel = factory.newChannel();
131 		copy(channel);
132 		return channel;
133 	}
134 
copy(TGChannel channel)135 	public void copy(TGChannel channel){
136 		channel.setChannel(getChannel());
137 		channel.setEffectChannel(getEffectChannel());
138 		channel.setInstrument(getInstrument());
139 		channel.setVolume(getVolume());
140 		channel.setBalance(getBalance());
141 		channel.setChorus(getChorus());
142 		channel.setReverb(getReverb());
143 		channel.setPhaser(getPhaser());
144 		channel.setTremolo(getTremolo());
145 	}
146 }
147