chordy 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,81 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'chord'
4
-
5
- class B < Chord
6
- def play_major
7
- [2, 2, 4, 4, 4, 2]
8
- end
9
-
10
- def play_minor
11
- [2, 2, 4, 4, 3, 2]
12
- end
13
-
14
- def play_dominant_7
15
- [2, 2, 4, 2, 4, 2]
16
- end
17
-
18
- def play_dominant_7_5
19
- [-1, 2, 1, 2, 0, 1]
20
- end
21
-
22
- def play_major_6
23
- [2, 2, 4, 4, 4, 4]
24
- end
25
-
26
- def play_major_7
27
- [2, 2, 4, 3, 4, 2]
28
- end
29
-
30
- def play_major_9
31
- [-1, 2, 1, 2, 2, 2]
32
- end
33
-
34
- def play_minor_6
35
- [-1, 2, 0, 1, 3, 2]
36
- end
37
-
38
- def play_minor_7
39
- [-1, 2, 0, 2, 0, 2]
40
- end
41
-
42
- def play_half_diminished_7
43
- [1, 0, 0, 2, 0, 1]
44
- end
45
-
46
- def play_minor_major_7
47
- [2, 2, 4, 3, 3, 2]
48
- end
49
-
50
- def play_augmented_5
51
- [3, -1, 5, 4, 4, 3]
52
- end
53
-
54
- def play_augmented_7
55
- [-1, 2, 1, 2, 0, 3]
56
- end
57
-
58
- def play_augmented_major_7
59
- [-1, 2, -1, 3, 4, 3]
60
- end
61
-
62
- def play_diminished_5
63
- [1, -1, 3, 4, 3, 1]
64
- end
65
-
66
- def play_diminished_7
67
- [-1, -1, 0, 1, 0, 1]
68
- end
69
-
70
- def play_diminished_9
71
- [-1, 2, 1, 2, 1, 2]
72
- end
73
-
74
- def play_suspended_4
75
- [2, 2, 4, 4, 5, 2]
76
- end
77
-
78
- def play_suspended_7
79
- [2, 2, 2, 2, 5, 2]
80
- end
81
- end
@@ -1,81 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'chord'
4
-
5
- class C < Chord
6
- def play_major
7
- [3, 3, 2, 0, 1, 0]
8
- end
9
-
10
- def play_minor
11
- [-1, 3, 1, 0, 4, 3]
12
- end
13
-
14
- def play_dominant_7
15
- [0, 3, 2, 3, 1, 0]
16
- end
17
-
18
- def play_dominant_7_5
19
- [-1, 1, 2, 3, 1, 2]
20
- end
21
-
22
- def play_major_6
23
- [0, 3, 2, 1, 1, 0]
24
- end
25
-
26
- def play_major_7
27
- [0, 3, 2, 0, 0, 0]
28
- end
29
-
30
- def play_major_9
31
- [0, 3, 2, 3, 3, 0]
32
- end
33
-
34
- def play_minor_6
35
- [-1, 3, 1, 2, 1, 3]
36
- end
37
-
38
- def play_minor_7
39
- [-1, 1, 1, 3, 1, 3]
40
- end
41
-
42
- def play_half_diminished_7
43
- [-1, 1, 1, 3, 1, 2]
44
- end
45
-
46
- def play_minor_major_7
47
- [-1, 2, 1, 0, 0, 3]
48
- end
49
-
50
- def play_augmented_5
51
- [0, 3, 2, 1, 1, 0]
52
- end
53
-
54
- def play_augmented_7
55
- [-1, 1, 2, 3, 1, 4]
56
- end
57
-
58
- def play_augmented_major_7
59
- [0, 3, 2, 1, 0, 0]
60
- end
61
-
62
- def play_diminished_5
63
- [-1, -1, 4, 5, 4, 2]
64
- end
65
-
66
- def play_diminished_7
67
- [-1, -1, 1, 2, 1, 2]
68
- end
69
-
70
- def play_diminished_9
71
- [-1, 3, 2, 3, 2, 3]
72
- end
73
-
74
- def play_suspended_4
75
- [3, 3, 3, 0, 1, 1]
76
- end
77
-
78
- def play_suspended_7
79
- [1, 1, 3, 3, 1, 1]
80
- end
81
- end
@@ -1,83 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'chord'
4
-
5
- class CSharp < Chord
6
- def play_major
7
- [1, 4, 3, 1, 2, 1]
8
- end
9
-
10
- def play_minor
11
- [0, -1, 2, 1, 2, 4]
12
- end
13
-
14
- def play_dominant_7
15
- [1, 2, 3, 1, 2, 1]
16
- end
17
-
18
- def play_dominant_7_5
19
- [-1, 2, 3, 4, 2, 3]
20
- end
21
-
22
- def play_major_6
23
- [1, 1, 3, 1, 2, 1]
24
- end
25
-
26
- def play_major_7
27
- [1, 4, 3, 1, 1, 1]
28
- end
29
-
30
- def play_major_9
31
- [1, 2, 1, 1, 2, 1]
32
- end
33
-
34
- def play_minor_6
35
- [0, 4, 2, 3, 2, 4]
36
- end
37
-
38
- def play_minor_7
39
- [0, 2, 2, 4, 2, 4]
40
- end
41
-
42
- def play_half_diminished_7
43
- [0, 2, 2, 4, 2, 3]
44
- end
45
-
46
- def play_minor_major_7
47
- [0, 3, 2, 1, 1, 4]
48
- end
49
-
50
- def play_augmented_5
51
- [-1, 0, 3, 2, 2, 1]
52
- end
53
-
54
- def play_augmented_7
55
- [-1, 2, 3, 4, 2, 5]
56
- end
57
-
58
- def play_augmented_major_7
59
- [1, 4, 3, 2, 1, 1]
60
- end
61
-
62
- def play_diminished_5
63
- [0, -1, 2, 0, 2, 3]
64
- end
65
-
66
- def play_diminished_7
67
- [-1, -1, 2, 3, 2, 3]
68
- end
69
-
70
- def play_diminished_9
71
- [-1, 4, 3, 4, 3, 4]
72
- end
73
-
74
- def play_suspended_4
75
- [4, 4, 6, 6, 7, 4]
76
- end
77
-
78
- def play_suspended_7
79
- [2, 2, 4, 4, 2, 2]
80
- end
81
- end
82
-
83
- DFlat = CSharp
@@ -1,193 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Chord
4
- CHORD_FLAGS = %w(mute harmonic bend pull hammer_down slide_down slide_up dont_play vibrato)
5
-
6
- def self.all_flags
7
- CHORD_FLAGS.to_a
8
- end
9
-
10
- def self.start_of_strings tuning, start_delimiter
11
- num_strings = tuning.length
12
- (0...num_strings).map { |s| tuning[s].rjust(2) + start_delimiter.rjust(2) } + [ " " * 4 ]
13
- end
14
-
15
- def self.end_of_strings tuning, end_delimiter
16
- num_strings = tuning.length
17
- ([ end_delimiter ] * num_strings) + [ "" ]
18
- end
19
-
20
- def self.print_half_length_string_at string_pos, tuning, half_length_delimiter, chord_space
21
- if string_pos == tuning.length
22
- "".rjust(2)
23
- else
24
- half_length_delimiter.rjust(2, chord_space)
25
- end
26
- end
27
-
28
- def self.short_chords
29
- {
30
- :M => :major,
31
- :m => :minor,
32
- :_7 => :dominant_7,
33
- :_7_5 => :dominant_7_5,
34
- :_9 => :diminished_9,
35
- :M6 => :major_6,
36
- :M7 => :major_7,
37
- :M9 => :major_9,
38
- :m5 => :diminished_5,
39
- :m6 => :minor_6,
40
- :m7 => :minor_7,
41
- :m7_5 => :half_diminished_7,
42
- :mM7 => :minor_major_7,
43
- :aug5 => :augmented_5,
44
- :aug7 => :augmented_7,
45
- :aug7_5 => :augmented_major_7,
46
- :dim => :diminished_7,
47
- :dim7 => :diminished_7,
48
- :dim5 => :diminished_5,
49
- :dim9 => :diminished_9,
50
- :sus => :suspended_4,
51
- :sus4 => :suspended_4,
52
- :sus7 => :suspended_7,
53
- }
54
- end
55
-
56
- def initialize chord, strings
57
- @strings = [-1] * strings
58
- pad_low = false
59
- if chord.instance_of? String or chord.instance_of? Symbol
60
- short_chords = Chord.short_chords
61
- if short_chords.key? chord
62
- chord_strings = play short_chords[chord]
63
- @type = short_chords[chord]
64
- else
65
- chord_strings = play chord.to_sym
66
- @type = chord.to_sym
67
- end
68
- pad_low = true
69
- elsif chord.instance_of? Array
70
- chord_strings = chord.to_a
71
- end
72
-
73
- @strings = chord_strings
74
- pad_or_trim strings, pad_low
75
- @flags = 0
76
- end
77
-
78
- def pad_or_trim length, pad_low
79
- if @strings.length > length
80
- @strings = @strings.last length
81
- elsif @strings.length < length
82
- diff = length - @strings.length
83
- if pad_low
84
- first = @strings.first
85
- min = @strings.min
86
-
87
- # play as bar chord
88
- bar_chord_string = ((first == min) and (min > 0) and (first > 0)) ? first : -1
89
- @strings = ([bar_chord_string] * diff) + @strings
90
- else
91
- @strings = @strings + [-1] * diff
92
- end
93
-
94
- self
95
- end
96
- end
97
-
98
- def play chord_type
99
- method_for_chord_type = "play_" + chord_type.to_s
100
- chord = eval(method_for_chord_type)
101
- chord
102
- end
103
-
104
- def strings
105
- @strings
106
- end
107
-
108
- def flags
109
- @flags
110
- end
111
-
112
- def has_flag flag
113
- (@flags & flag) == flag
114
- end
115
-
116
- def add_flag flag
117
- @flags = @flags | flag
118
- self
119
- end
120
-
121
- def print_string_at i, chord_space
122
- to_print = chord_space
123
- string = @strings[i]
124
- if string != -1
125
- to_print = string.to_s
126
- end
127
-
128
- to_print = to_print.rjust(3, chord_space)
129
-
130
- if @flags != 0
131
- to_print = print_string_with_flag_at i, to_print, chord_space
132
- end
133
-
134
- to_print.ljust(4, chord_space)
135
- end
136
-
137
- def print_string_with_flag_at i, printed_string, chord_space
138
- to_print = printed_string
139
- string = @strings[i]
140
-
141
- if string != -1
142
- if has_flag DONT_PLAY
143
- to_print = "x".rjust(3, chord_space)
144
- elsif has_flag BEND
145
- to_print = to_print + "b"
146
- elsif has_flag HAMMER_DOWN
147
- to_print = to_print + "h"
148
- elsif has_flag PULL
149
- to_print = to_print + "p"
150
- elsif has_flag SLIDE_UP
151
- to_print = to_print + "/"
152
- elsif has_flag SLIDE_DOWN
153
- to_print = to_print + "\\"
154
- elsif has_flag VIBRATO
155
- to_print = to_print + "~"
156
- end
157
- end
158
-
159
- to_print
160
- end
161
-
162
- # for printing flags on diff line
163
- def print_flag
164
- to_print = ""
165
-
166
- if has_flag MUTE
167
- to_print = "M"
168
- elsif has_flag HARMONIC
169
- to_print = "H"
170
- end
171
-
172
- to_print.rjust(3).ljust(4)
173
- end
174
- end
175
-
176
- Chord::CHORD_FLAGS.each_with_index do |name,i|
177
- Chord.class_eval <<-ENDOFEVAL
178
- #{name.upcase} = #{2**i}
179
- private
180
- def #{name}()
181
- add_flag #{name.upcase}
182
- end
183
- ENDOFEVAL
184
- end
185
-
186
- Chord.short_chords.values.each do |chord_type|
187
- chord_type_str = chord_type.to_s
188
- Chord.class_eval <<-ENDOFEVAL
189
- def play_#{chord_type_str}
190
- [-1] * 6
191
- end
192
- ENDOFEVAL
193
- end
@@ -1,81 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'chord'
4
-
5
- class D < Chord
6
- def play_major
7
- [-1, 0, 0, 2, 3, 2]
8
- end
9
-
10
- def play_minor
11
- [-1, 0, 0, 2, 3, 1]
12
- end
13
-
14
- def play_dominant_7
15
- [-1, 0, 0, 2, 1, 2]
16
- end
17
-
18
- def play_dominant_7_5
19
- [-1, -1, 0, 1, 1, 2]
20
- end
21
-
22
- def play_major_6
23
- [-1, 0, 0, 2, 0, 2]
24
- end
25
-
26
- def play_major_7
27
- [-1, 0, 0, 2, 2, 2]
28
- end
29
-
30
- def play_major_9
31
- [0, 0, 0, 2, 1, 2]
32
- end
33
-
34
- def play_minor_6
35
- [-1, 0, 0, 2, 0, 1]
36
- end
37
-
38
- def play_minor_7
39
- [-1, 0, 0, 2, 1, 1]
40
- end
41
-
42
- def play_half_diminished_7
43
- [1, -1, 0, 1, 1, 1]
44
- end
45
-
46
- def play_minor_major_7
47
- [-1, 0, 0, 2, 2, 1]
48
- end
49
-
50
- def play_augmented_5
51
- [2, -1, 4, 3, 3, 2]
52
- end
53
-
54
- def play_augmented_7
55
- [-1, -1, 0, 3, 1, 2]
56
- end
57
-
58
- def play_augmented_major_7
59
- [2, 5, 4, 3, 2, 2]
60
- end
61
-
62
- def play_diminished_5
63
- [1, -1, 3, 1, 3, 1]
64
- end
65
-
66
- def play_diminished_7
67
- [-1, -1, 0, 1, 0, 1]
68
- end
69
-
70
- def play_diminished_9
71
- [0, 0, 1, 2, 1, 2]
72
- end
73
-
74
- def play_suspended_4
75
- [-1, 0, 0, 2, 3, 3]
76
- end
77
-
78
- def play_suspended_7
79
- [-1, 0, 0, 2, 1, 3]
80
- end
81
- end