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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/editors/chord/ChordDatabase.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.gui.editors.chord;
 
2
 
 
3
/**
 
4
 * Stores the information about the chord name, structure and
 
5
 * alteration abilities into a list
 
6
 * 
 
7
 * @author Nikola Kolarovic <nikola.kolarovic@gmail.com>
 
8
 *
 
9
 */
 
10
public class ChordDatabase {
 
11
        
 
12
        /**
 
13
         * fills all the necessary data into chords List consisted out of ChordInfo-s
 
14
         * 
 
15
         * If you want to change it, please contact me on
 
16
         * nikola.kolarovic@gmail.com
 
17
         */
 
18
        private static final ChordInfo[] data = new ChordInfo[]{
 
19
                
 
20
                // Major--------------------------
 
21
                new ChordInfo("M",new int[]{ 1, 5, 8 }),
 
22
                
 
23
                // 7--------------------------
 
24
                new ChordInfo("7",new int[]{ 1, 5, 8, 11 }),
 
25
                
 
26
                // 7M--------------------------
 
27
                // hard-coded index used in ChordRecognizer, below comment "determine seventh", line 315 now
 
28
                new ChordInfo("maj7",new int[]{ 1, 5, 8, 12 }),
 
29
                
 
30
                // 6--------------------------
 
31
                new ChordInfo("6",new int[]{ 1, 5, 8, 10 }),
 
32
                
 
33
                // m--------------------------
 
34
                // index 4 hard-coded in ChordRecognizer line 220, so it is not so unusual
 
35
                new ChordInfo("m",new int[]{ 1, 4, 8 }),
 
36
                
 
37
                // m7--------------------------
 
38
                new ChordInfo("m7",new int[]{ 1, 4, 8, 11 }),
 
39
                
 
40
                // m7M--------------------------
 
41
                new ChordInfo("m/maj7",new int[]{ 1, 4, 8, 12 }),
 
42
                
 
43
                // m6--------------------------
 
44
                new ChordInfo("m6",new int[]{ 1, 4, 8, 10 }),
 
45
                
 
46
                // sus2--------------------------
 
47
                new ChordInfo("sus2",new int[]{ 1, 3, 8 }),
 
48
                
 
49
                // sus4--------------------------
 
50
                new ChordInfo("sus4",new int[]{ 1, 6, 8 }),
 
51
                
 
52
                // 7sus2--------------------------
 
53
                new ChordInfo("7sus2",new int[]{ 1, 3, 8, 11 }),
 
54
                
 
55
                // 7sus4--------------------------
 
56
                new ChordInfo("7sus4",new int[]{ 1, 6, 8, 11 }),
 
57
                
 
58
                // below indexes are hard-coded in ChordRecognizer line 311 now
 
59
                
 
60
                // dim--------------------------
 
61
                new ChordInfo("dim",new int[]{ 1, 4, 7 }),
 
62
                
 
63
                // dim7--------------------------
 
64
                new ChordInfo("dim7",new int[]{ 1, 4, 7, 10 }),
 
65
                
 
66
                // aug--------------------------
 
67
                new ChordInfo("aug",new int[]{ 1, 5, 9 }),
 
68
                
 
69
                // 5--------------------------
 
70
                // index <last> hard-coded in ChordRecognizer line 220, so it is not so unusual
 
71
                new ChordInfo("5",new int[]{ 1, 8 }),
 
72
                
 
73
        };
 
74
        
 
75
        public static int length(){
 
76
                return data.length;
 
77
        }
 
78
        
 
79
        public static ChordInfo get(int index){
 
80
                return data[index];
 
81
        }
 
82
        
 
83
        /** chord data structure, contains all info for chord formation **/
 
84
        public static class ChordInfo {
 
85
                
 
86
                private String name;
 
87
                private int[] requiredNotes;
 
88
                
 
89
                public ChordInfo(String name,int[] requiredNotes){
 
90
                        this.name = name;
 
91
                        this.requiredNotes = requiredNotes;
 
92
                }
 
93
                
 
94
                public String getName() {
 
95
                        return this.name;
 
96
                }
 
97
                
 
98
                public int[] getRequiredNotes() {
 
99
                        return this.requiredNotes;
 
100
                }
 
101
                
 
102
                public int[] cloneRequireds() {
 
103
                        int[] requiredNotes = new int[this.requiredNotes.length];
 
104
                        for(int i = 0; i < requiredNotes.length; i ++){
 
105
                                requiredNotes[i] = this.requiredNotes[i];
 
106
                        }
 
107
                        return requiredNotes;
 
108
                }
 
109
        }
 
110
}
 
 
b'\\ No newline at end of file'