1 package org.herac.tuxguitar.io.tef.base;
2 
3 import java.util.ArrayList;
4 import java.util.Iterator;
5 import java.util.List;
6 
7 public class TESong {
8 
9 	private int strings;
10 	private int measures;
11 	private TEInfo info;
12 	private TETempo tempo;
13 	private TETimeSignature timeSignature;
14 	private TERepeat[] repeats;
15 	private TEText[] texts;
16 	private TEChord[] chords;
17 	private TEPercussion[] percussions;
18 	private TERhythm[] rhythms;
19 	private TETrack[] tracks;
20 	private List components;
21 	private List tsChanges;
22 
TESong()23 	public TESong(){
24 		this.components = new ArrayList();
25 		this.tsChanges = new ArrayList();
26 	}
27 
getRhythms()28 	public TERhythm[] getRhythms() {
29 		return this.rhythms;
30 	}
31 
setRhythms(int length)32 	public void setRhythms(int length) {
33 		this.rhythms = new TERhythm[length];
34 	}
35 
setRhythm(int index,TERhythm rhythm)36 	public void setRhythm(int index,TERhythm rhythm) {
37 		this.rhythms[index] = rhythm;
38 	}
39 
getPercussions()40 	public TEPercussion[] getPercussions() {
41 		return this.percussions;
42 	}
43 
setPercussions(int length)44 	public void setPercussions(int length) {
45 		this.percussions = new TEPercussion[length];
46 	}
47 
setPercussion(int index,TEPercussion percussions)48 	public void setPercussion(int index,TEPercussion percussions) {
49 		this.percussions[index] = percussions;
50 	}
51 
getChords()52 	public TEChord[] getChords() {
53 		return this.chords;
54 	}
55 
setChords(int length)56 	public void setChords(int length) {
57 		this.chords = new TEChord[length];
58 	}
59 
setChord(int index,TEChord chord)60 	public void setChord(int index,TEChord chord) {
61 		this.chords[index] = chord;
62 	}
63 
getInfo()64 	public TEInfo getInfo() {
65 		return this.info;
66 	}
67 
setInfo(TEInfo info)68 	public void setInfo(TEInfo info) {
69 		this.info = info;
70 	}
71 
getRepeats()72 	public TERepeat[] getRepeats() {
73 		return this.repeats;
74 	}
75 
setRepeats(int length)76 	public void setRepeats(int length) {
77 		this.repeats = new TERepeat[length];
78 	}
79 
setRepeat(int index,TERepeat repeat)80 	public void setRepeat(int index,TERepeat repeat) {
81 		this.repeats[index] = repeat;
82 	}
83 
getTexts()84 	public TEText[] getTexts() {
85 		return this.texts;
86 	}
87 
setTexts(int length)88 	public void setTexts(int length) {
89 		this.texts = new TEText[length];
90 	}
91 
setText(int index,TEText text)92 	public void setText(int index,TEText text) {
93 		this.texts[index] = text;
94 	}
95 
getTracks()96 	public TETrack[] getTracks() {
97 		return this.tracks;
98 	}
99 
setTracks(int length)100 	public void setTracks(int length) {
101 		this.tracks = new TETrack[length];
102 	}
103 
setTrack(int index,TETrack track)104 	public void setTrack(int index,TETrack track) {
105 		this.tracks[index] = track;
106 	}
107 
getTimeSignature()108 	public TETimeSignature getTimeSignature() {
109 		return this.timeSignature;
110 	}
111 
setTimeSignature(TETimeSignature timeSignature)112 	public void setTimeSignature(TETimeSignature timeSignature) {
113 		this.timeSignature = timeSignature;
114 	}
115 
getTempo()116 	public TETempo getTempo() {
117 		return this.tempo;
118 	}
119 
setTempo(TETempo tempo)120 	public void setTempo(TETempo tempo) {
121 		this.tempo = tempo;
122 	}
123 
getStrings()124 	public int getStrings() {
125 		return this.strings;
126 	}
127 
setStrings(int strings)128 	public void setStrings(int strings) {
129 		this.strings = strings;
130 	}
131 
getMeasures()132 	public int getMeasures() {
133 		return this.measures;
134 	}
135 
setMeasures(int measures)136 	public void setMeasures(int measures) {
137 		this.measures = measures;
138 	}
139 
getComponents()140 	public List getComponents() {
141 		return this.components;
142 	}
143 
addTimeSignatureChange(TETimeSignatureChange tsChange)144 	public void addTimeSignatureChange(TETimeSignatureChange tsChange){
145 		this.tsChanges.add(tsChange);
146 	}
147 
getTimeSignature(int measure)148 	public TETimeSignature getTimeSignature(int measure){
149 		Iterator it = this.tsChanges.iterator();
150 		while(it.hasNext()){
151 			TETimeSignatureChange change = (TETimeSignatureChange)it.next();
152 			if(change.getMeasure() == measure){
153 				return change.getTimeSignature();
154 			}
155 		}
156 		return getTimeSignature();
157 	}
158 
toString()159 	public String toString(){
160 		String string = new String("[SONG] *** Tabledit file format ***\n");
161 		string +=  (this.getInfo().toString() + "\n");
162 		string +=  (this.getTempo().toString() + "\n");
163 		for(int i = 0; i < this.repeats.length; i ++){
164 			string +=  (this.repeats[i].toString() + "\n");
165 		}
166 		for(int i = 0; i < this.texts.length; i ++){
167 			string +=  (this.texts[i].toString() + "\n");
168 		}
169 		for(int i = 0; i < this.chords.length; i ++){
170 			string +=  (this.chords[i].toString() + "\n");
171 		}
172 		for(int i = 0; i < this.percussions.length; i ++){
173 			string +=  (this.percussions[i].toString() + "\n");
174 		}
175 		for(int i = 0; i < this.rhythms.length; i ++){
176 			string +=  (this.rhythms[i].toString() + "\n");
177 		}
178 		for(int i = 0; i < this.tracks.length; i ++){
179 			string +=  (this.tracks[i].toString() + "\n");
180 		}
181 		for(int i = 0; i < this.components.size(); i ++){
182 			string +=  (this.components.get(i).toString() + "\n");
183 		}
184 		return string;
185 	}
186 }
187