motion-music 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/lib/motion-music/version.rb +1 -1
  3. data/lib/rb-music/version.rb +1 -1
  4. metadata +2 -70
  5. data/.gitignore +0 -6
  6. data/Gemfile +0 -8
  7. data/Guardfile +0 -6
  8. data/doc/Gemfile.html +0 -111
  9. data/doc/Gemfile_lock.html +0 -168
  10. data/doc/Guardfile.html +0 -111
  11. data/doc/LICENSE.html +0 -124
  12. data/doc/Object.html +0 -116
  13. data/doc/RBMusic.html +0 -164
  14. data/doc/RBMusic/Interval.html +0 -440
  15. data/doc/RBMusic/Note.html +0 -620
  16. data/doc/RBMusic/NoteSet.html +0 -277
  17. data/doc/RBMusic/Scale.html +0 -274
  18. data/doc/README_md.html +0 -163
  19. data/doc/created.rid +0 -8
  20. data/doc/fonts.css +0 -167
  21. data/doc/fonts/Lato-Light.ttf +0 -0
  22. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  23. data/doc/fonts/Lato-Regular.ttf +0 -0
  24. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  25. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  26. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  27. data/doc/images/add.png +0 -0
  28. data/doc/images/arrow_up.png +0 -0
  29. data/doc/images/brick.png +0 -0
  30. data/doc/images/brick_link.png +0 -0
  31. data/doc/images/bug.png +0 -0
  32. data/doc/images/bullet_black.png +0 -0
  33. data/doc/images/bullet_toggle_minus.png +0 -0
  34. data/doc/images/bullet_toggle_plus.png +0 -0
  35. data/doc/images/date.png +0 -0
  36. data/doc/images/delete.png +0 -0
  37. data/doc/images/find.png +0 -0
  38. data/doc/images/loadingAnimation.gif +0 -0
  39. data/doc/images/macFFBgHack.png +0 -0
  40. data/doc/images/package.png +0 -0
  41. data/doc/images/page_green.png +0 -0
  42. data/doc/images/page_white_text.png +0 -0
  43. data/doc/images/page_white_width.png +0 -0
  44. data/doc/images/plugin.png +0 -0
  45. data/doc/images/ruby.png +0 -0
  46. data/doc/images/tag_blue.png +0 -0
  47. data/doc/images/tag_green.png +0 -0
  48. data/doc/images/transparent.png +0 -0
  49. data/doc/images/wrench.png +0 -0
  50. data/doc/images/wrench_orange.png +0 -0
  51. data/doc/images/zoom.png +0 -0
  52. data/doc/index.html +0 -93
  53. data/doc/js/darkfish.js +0 -140
  54. data/doc/js/jquery.js +0 -18
  55. data/doc/js/navigation.js +0 -142
  56. data/doc/js/search.js +0 -109
  57. data/doc/js/search_index.js +0 -1
  58. data/doc/js/searcher.js +0 -228
  59. data/doc/projections_json.html +0 -115
  60. data/doc/rb-music_gemspec.html +0 -132
  61. data/doc/rdoc.css +0 -580
  62. data/doc/table_of_contents.html +0 -192
  63. data/lib/rb-music.rb +0 -8
  64. data/motion-music.gemspec +0 -20
  65. data/projections.json +0 -12
  66. data/rb-music.gemspec +0 -29
  67. data/spec/rb-music/constants_spec.rb +0 -27
  68. data/spec/rb-music/interval_spec.rb +0 -90
  69. data/spec/rb-music/note_set_spec.rb +0 -191
  70. data/spec/rb-music/note_spec.rb +0 -318
  71. data/spec/rb-music/scale_spec.rb +0 -88
  72. data/spec/spec_helper.rb +0 -14
@@ -1,318 +0,0 @@
1
- require_relative '../spec_helper'
2
-
3
- describe RBMusic::Note do
4
-
5
- describe "class methods" do
6
-
7
- describe "#from_latin" do
8
-
9
- context "when given a single-character valid note name" do
10
- let(:note_name) { RBMusic::NOTE_NAMES[0] }
11
- let(:subject) { described_class.from_latin(note_name) }
12
-
13
- it "returns a #{described_class}" do
14
- subject.should be_a(described_class)
15
- end
16
-
17
- it "assigns the correct latin name" do
18
- subject.latin.should == note_name
19
- end
20
-
21
- it "assigns a default octave of 0" do
22
- subject.octave.should == 0
23
- end
24
- end
25
-
26
- context "when given a single-character valid note name with octave" do
27
- let(:note_name) { RBMusic::NOTE_NAMES[0] }
28
- let(:octave) { 2 }
29
- let(:subject) { described_class.from_latin("#{note_name}#{octave}") }
30
-
31
- it "returns a #{described_class}" do
32
- subject.should be_a(described_class)
33
- end
34
-
35
- it "assigns the correct latin name" do
36
- subject.latin.should == note_name
37
- end
38
-
39
- it "assigns the correct octave" do
40
- subject.octave.should == 2
41
- end
42
- end
43
-
44
- context "when given a two-character valid note name with octave" do
45
- let(:note_name) { "C#" }
46
- let(:octave) { 3 }
47
- let(:subject) { described_class.from_latin("#{note_name}#{octave}") }
48
-
49
- it "returns a #{described_class}" do
50
- subject.should be_a(described_class)
51
- end
52
-
53
- it "assigns the correct latin name" do
54
- subject.latin.should == note_name
55
- end
56
-
57
- it "assigns the correct octave" do
58
- subject.octave.should == 3
59
- end
60
- end
61
-
62
- context "when given a single-character invalid note name" do
63
- let(:note_name) { "Z" }
64
-
65
- it "raises an exception" do
66
- lambda {
67
- described_class.from_latin(note_name)
68
- }.should raise_error(RBMusic::ArgumentError)
69
- end
70
- end
71
-
72
- context "when given an invalid note name / octave string" do
73
- it "raises an exception" do
74
- lambda {
75
- described_class.from_latin("C0E3")
76
- }.should raise_error(RBMusic::ArgumentError)
77
- end
78
- end
79
-
80
- context "when given an empty string" do
81
- it "raises an exception" do
82
- lambda {
83
- described_class.from_latin("")
84
- }.should raise_error(RBMusic::ArgumentError)
85
- end
86
- end
87
-
88
- context "when a non-string" do
89
- it "raises an exception" do
90
- lambda {
91
- described_class.from_latin(1)
92
- }.should raise_error(RBMusic::ArgumentError)
93
- end
94
- end
95
-
96
- end
97
-
98
- end
99
-
100
- describe "instance methods" do
101
- let(:subject) { Note.from_latin("A4") }
102
-
103
- describe "#frequency" do
104
- [
105
- ["A4", 440],
106
- ["A#4", 466.16],
107
- ["C4", 261.63],
108
- ["B3", 246.94],
109
- ["Ax3", 246.94]
110
- ].each do |pair|
111
-
112
- it "is #{pair[1]} for #{pair[0]}" do
113
- Note.from_latin(pair[0]).frequency.round(2).should == pair[1]
114
- end
115
-
116
- end
117
-
118
- end
119
-
120
- it "has a latin name" do
121
- subject.latin.should == "A"
122
- end
123
-
124
- it "has an octave" do
125
- subject.octave.should == 4
126
- end
127
-
128
- describe "#==" do
129
- context "when the argument is a note with the same latin name and octave" do
130
- it "is true" do
131
- subject.should == Note.from_latin("A4")
132
- end
133
- end
134
-
135
- context "when the argument is a note with a different latin name and same octave" do
136
- it "is false" do
137
- subject.should_not == Note.from_latin("B4")
138
- end
139
- end
140
-
141
- context "when the argument is a note with the same latin name and a different octave" do
142
- it "is false" do
143
- subject.should_not == Note.from_latin("A5")
144
- end
145
- end
146
-
147
- context "when the argument is not a note" do
148
- it "is false" do
149
- subject.should_not == "foo"
150
- end
151
- end
152
- end
153
-
154
- describe "#enharmonic?" do
155
- context "when the argument is a note with the same latin name and octave" do
156
- it "is true" do
157
- subject.should be_enharmonic(Note.from_latin("A4"))
158
- end
159
- end
160
-
161
- context "when the argument is a note with same frequency but a different latin name and/or octave" do
162
- it "is true" do
163
- Note.from_latin("E4").should be_enharmonic(Note.from_latin("Fb4"))
164
- Note.from_latin("Fbb4").should be_enharmonic(Note.from_latin("Eb4"))
165
- end
166
- end
167
-
168
- context "when the argument is a note with a different latin name and same octave" do
169
- it "is false" do
170
- subject.should_not be_enharmonic(Note.from_latin("B4"))
171
- subject.should_not be_enharmonically_equivalent_to(Note.from_latin("B4"))
172
- end
173
- end
174
-
175
- context "when the argument is a note with the same latin name and a different octave" do
176
- it "is false" do
177
- subject.should_not be_enharmonic(Note.from_latin("A5"))
178
- end
179
- end
180
-
181
- context "when the argument is not a note" do
182
- it "raises an exception" do
183
- lambda {
184
- subject.enharmonic?("foo")
185
- }.should raise_exception(RBMusic::ArgumentError)
186
- end
187
- end
188
- end
189
-
190
- describe "#add" do
191
- context "when given a string" do
192
- it "adds an interval from the string" do
193
- b4 = Note.from_latin("B4")
194
- result = subject.add("major_second")
195
-
196
- result.frequency.should == b4.frequency
197
- result.latin.should == b4.latin
198
- result.octave.should == b4.octave
199
- end
200
- end
201
-
202
- context "when given a symbol" do
203
- it "adds an interval from the symbol" do
204
- c5 = Note.from_latin("C5")
205
- result = subject.add(:minor_third)
206
-
207
- result.frequency.should == c5.frequency
208
- result.latin.should == c5.latin
209
- result.octave.should == c5.octave
210
- end
211
- end
212
-
213
- context "when given an array" do
214
- it "returns an NoteSet" do
215
- b4 = Note.from_latin("B4")
216
- c5 = Note.from_latin("C5")
217
- result = subject.add(["major_second", :minor_third])
218
-
219
- result.should be_a(NoteSet)
220
-
221
- result[0].frequency.should == b4.frequency
222
- result[0].latin.should == b4.latin
223
- result[0].octave.should == b4.octave
224
-
225
- result[1].frequency.should == c5.frequency
226
- result[1].latin.should == c5.latin
227
- result[1].octave.should == c5.octave
228
- end
229
- end
230
- end
231
-
232
- describe "#subtract" do
233
-
234
- context "when given a string" do
235
- it "returns a note with an interval from the string subtracted" do
236
- g4 = Note.from_latin("G4")
237
- result = subject.subtract("major_second")
238
-
239
- result.frequency.should == g4.frequency
240
- result.latin.should == g4.latin
241
- result.octave.should == g4.octave
242
- end
243
- end
244
-
245
- context "when given a symbol" do
246
- it "returns a note with an interval from the symbol subtracted" do
247
- f4 = Note.from_latin("F4")
248
- result = subject.subtract(:major_third)
249
-
250
- result.frequency.should == f4.frequency
251
- result.latin.should == f4.latin
252
- result.octave.should == f4.octave
253
- end
254
- end
255
-
256
- context "when given an array" do
257
- it "returns a NoteSet" do
258
- f4 = Note.from_latin("F4")
259
- g4 = Note.from_latin("G4")
260
- result = subject.subtract(["major_third", :major_second])
261
-
262
- result.should be_a(NoteSet)
263
- result[0].frequency.should == f4.frequency
264
- result[0].latin.should == f4.latin
265
- result[0].octave.should == f4.octave
266
-
267
- result[1].frequency.should == g4.frequency
268
- result[1].latin.should == g4.latin
269
- result[1].octave.should == g4.octave
270
- end
271
- end
272
-
273
- context "when given a Note" do
274
- it "returns the difference as an Interval" do
275
- f4 = Note.from_latin("F4")
276
- result = subject.subtract(f4)
277
-
278
- result.coord.should == Interval.from_name("major_third").coord
279
- end
280
- end
281
- end
282
- end
283
-
284
- describe "#midi_note_number" do
285
- [
286
- ["C3", 48],
287
- ["B2", 47],
288
- ["Ax2", 47],
289
- ["C4", 60],
290
- ["Cb4", 59],
291
- ["C#4", 61],
292
- ["Db4", 61]
293
- ].each do |pair|
294
- it "maps #{pair[0]} to #{pair[1]}" do
295
- Note.from_latin(pair[0]).midi_note_number.should == pair[1]
296
- end
297
- end
298
- end
299
-
300
- describe "#scale" do
301
- let(:subject) { Note.from_latin("C4") }
302
- let(:scale_name) { "major" }
303
- let(:scale) { Scale.new(subject.latin, scale_name) }
304
-
305
- it "is a note set with the default octave and range" do
306
- result = subject.scale(scale_name)
307
-
308
- result.should == NoteSet.from_scale(scale, subject.octave, 1)
309
- end
310
-
311
- it "accepts an octave range" do
312
- result = subject.scale(scale_name, 2)
313
-
314
- result.should == NoteSet.from_scale(scale, subject.octave, 2)
315
- end
316
- end
317
-
318
- end
@@ -1,88 +0,0 @@
1
- require_relative '../spec_helper'
2
-
3
- describe RBMusic::Scale do
4
-
5
- describe "initializer" do
6
-
7
- context "when called with no arguments" do
8
- it "raises an ArgumentError" do
9
- lambda {
10
- described_class.new
11
- }.should raise_error(ArgumentError)
12
- end
13
- end
14
-
15
- context "when called without a valid note name as key" do
16
- it "raises an ArgumentError" do
17
- lambda {
18
- described_class.new("foo", "bar")
19
- }.should raise_error(RBMusic::ArgumentError)
20
- end
21
- end
22
-
23
- context "when called without a valid key and scale name" do
24
- it "raises an ArgumentError" do
25
- lambda {
26
- described_class.new("C", "bar")
27
- }.should raise_error(RBMusic::ArgumentError)
28
- end
29
- end
30
-
31
- context "when called with a valid key and scale" do
32
- let(:key) { "C" }
33
- let(:name) { "major" }
34
- let(:subject) { described_class.new(key, name) }
35
-
36
- it "assigns the key attribute" do
37
- subject.key.should == key
38
- end
39
-
40
- it "assigns the degrees based on the name" do
41
- subject.degrees.should == [:unison] + SCALES[name.to_sym]
42
- end
43
- end
44
- end
45
-
46
- describe "instance methods" do
47
- let(:subject) { described_class.new("C", "major") }
48
-
49
- describe "#degree_count" do
50
- it "is the number of scale degrees" do
51
- subject.degree_count.should == subject.degrees.size
52
- end
53
- end
54
-
55
- describe "#name" do
56
- it "is the human-readable name" do
57
- subject.name.should == "C Major"
58
- Scale.new("D#", "harmonic_minor").name.should == "D# Harmonic Minor"
59
- end
60
- end
61
- end
62
-
63
- describe "scale types" do
64
- let(:note) { Note.from_latin("C4") }
65
-
66
- {
67
- "major" => ["C", "D", "E", "F", "G", "A", "B"],
68
- "natural_minor" => ["C", "D", "Eb", "F", "G", "Ab", "Bb"],
69
- "natural_minor" => ["C", "D", "Eb", "F", "G", "Ab", "Bb"],
70
- "harmonic_minor" => ["C", "D", "Eb", "F", "G", "Ab", "B"],
71
- "major_pentatonic" => ["C", "D", "E", "G", "A"],
72
- "minor_pentatonic" => ["C", "Eb", "F", "G", "Bb"],
73
- "blues" => ["C", "Eb", "F", "F#", "G", "Bb"],
74
- "ionian" => ["C", "D", "E", "F", "G", "A", "B"],
75
- "dorian" => ["C", "D", "Eb", "F", "G", "A", "Bb"],
76
- "phrygian" => ["C", "Db", "Eb", "F", "G", "A", "Bb"],
77
- "lydian" => ["C", "D", "E", "F#", "G", "A", "B"],
78
- "mixolydian" => ["C", "D", "E", "F", "G", "A", "Bb"],
79
- "aeolian" => ["C", "D", "Eb", "F", "G", "Ab", "Bb"],
80
- "locrian" => ["C", "Db", "Eb", "F", "Gb", "Ab", "Bb"],
81
- }.each_pair do |key, value|
82
- it "calculates a #{key} scale" do
83
- note.scale(key).map(&:latin).should == value
84
- end
85
- end
86
- end
87
-
88
- end
@@ -1,14 +0,0 @@
1
- $TESTING=true
2
- $:.push File.join(File.dirname(__FILE__), '..', 'lib')
3
-
4
- if ENV["COVERAGE"]
5
- require 'simplecov'
6
- SimpleCov.start
7
- end
8
-
9
- RSpec.configure do |c|
10
- c.filter_run focus: true
11
- c.run_all_when_everything_filtered = true
12
- end
13
-
14
- require 'rb-music'