author | mickeyl <mickeyl> | 2004-01-20 13:07:31 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-20 13:07:31 (UTC) |
commit | d388324e7b91bdd95553c3849d77cddd5bd0bfc4 (patch) (unidiff) | |
tree | ef660ffd25aa8cabbfa58e6c3b170e7c82511bc6 /noncore/multimedia/powerchord/chordengine.h | |
parent | 105007cca23072ee42a1f36625979966eb8a4854 (diff) | |
download | opie-d388324e7b91bdd95553c3849d77cddd5bd0bfc4.zip opie-d388324e7b91bdd95553c3849d77cddd5bd0bfc4.tar.gz opie-d388324e7b91bdd95553c3849d77cddd5bd0bfc4.tar.bz2 |
initial import of powerchord courtesy Camilo Mesias <mailto:camilo@mesias.co.uk>
modified some bits to be compatible with the opie build system
packaging not complete yet
i hope camilo will maintain this here...
Diffstat (limited to 'noncore/multimedia/powerchord/chordengine.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/powerchord/chordengine.h | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/noncore/multimedia/powerchord/chordengine.h b/noncore/multimedia/powerchord/chordengine.h new file mode 100644 index 0000000..44b7388 --- a/dev/null +++ b/noncore/multimedia/powerchord/chordengine.h | |||
@@ -0,0 +1,124 @@ | |||
1 | // | ||
2 | // ChordEngine class to calculate chords | ||
3 | // | ||
4 | |||
5 | // Copyright (c) 2001 Camilo Mesias | ||
6 | // camilo@mesias.co.uk | ||
7 | // | ||
8 | // derived from JavaScript code by Jim Cranwell, used with permission | ||
9 | // | ||
10 | // This program is free software; you can redistribute it and/or | ||
11 | // modify it under the terms of the GNU General Public License | ||
12 | // as published by the Free Software Foundation; either version 2 | ||
13 | // of the License, or (at your option) any later version. | ||
14 | // | ||
15 | // This program is distributed in the hope that it will be useful, | ||
16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | // GNU General Public License for more details. | ||
19 | // | ||
20 | // You should have received a copy of the GNU General Public License | ||
21 | // along with this program; if not, write to the Free Software | ||
22 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
23 | |||
24 | |||
25 | #ifndef __CHORDENGINE_H | ||
26 | #define __CHORDENGINE_H | ||
27 | |||
28 | #include <stdio.h> | ||
29 | |||
30 | class ChordEngine; | ||
31 | |||
32 | class ChordEngine { | ||
33 | |||
34 | private: | ||
35 | //saved state | ||
36 | |||
37 | int base_note; | ||
38 | int chord_type; | ||
39 | int fret_pos; | ||
40 | int span_size; | ||
41 | int variation; | ||
42 | int tuning; | ||
43 | |||
44 | int string[6]; | ||
45 | const char *notename[6]; | ||
46 | |||
47 | // unfathomable stuff ported from javascript: js_prefix | ||
48 | // may ask Jim Cranwell if he'd like to comment on it | ||
49 | int js_MMM[6]; | ||
50 | int note_indices[6]; | ||
51 | |||
52 | void js_tunit(int t); | ||
53 | |||
54 | int js_T[12]; | ||
55 | |||
56 | void js_whatchord(int c); | ||
57 | |||
58 | int js_L, js_Y, js_Z, js_VM; | ||
59 | |||
60 | void js_vboy(int v); | ||
61 | |||
62 | // stuff I put in | ||
63 | char label_text[20]; | ||
64 | static const int chordbases[][12]; | ||
65 | static const int alt_tunings[][6]; | ||
66 | |||
67 | public: | ||
68 | static const char* notes[]; | ||
69 | static const char* keys[]; | ||
70 | static const char* frets[]; | ||
71 | static const char* variations[]; | ||
72 | static const char* tunings[]; | ||
73 | |||
74 | |||
75 | static const int OPEN = 0; | ||
76 | static const int MUTED = 7; | ||
77 | |||
78 | ChordEngine(); | ||
79 | |||
80 | // accessors | ||
81 | const char *name(int f){return notename[f];}; | ||
82 | int noteindex(int f){ | ||
83 | if (string[f] == MUTED){ | ||
84 | return -1; | ||
85 | }else{ | ||
86 | return note_indices[f] + string[f]; | ||
87 | } | ||
88 | }; | ||
89 | |||
90 | void base(int b){base_note = b;}; | ||
91 | int base(){return base_note;}; | ||
92 | |||
93 | void chord(int c){chord_type = c; js_whatchord(c);}; | ||
94 | int chord(){return chord_type;}; | ||
95 | |||
96 | void fret(int f){fret_pos = f;}; | ||
97 | int fret(){return fret_pos;}; | ||
98 | |||
99 | void span(int s){span_size = s;}; | ||
100 | int span(){return span_size;}; | ||
101 | |||
102 | void vary(int v){variation = v; js_vboy(v);}; | ||
103 | int vary(){return variation;}; | ||
104 | |||
105 | void tune(int t){tuning = t; js_tunit(t);}; | ||
106 | int tune(){return tuning;}; | ||
107 | |||
108 | // methods | ||
109 | void calculate(); | ||
110 | |||
111 | const char *label(){return label_text;}; | ||
112 | |||
113 | int finger(int string); // returns fret position or MUTED | ||
114 | |||
115 | }; | ||
116 | |||
117 | #endif | ||
118 | |||
119 | |||
120 | |||
121 | |||
122 | |||
123 | |||
124 | |||