mtk 0.0.3.2 → 0.0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +2 -2
- data/DEVELOPMENT_NOTES.md +20 -0
- data/README.md +9 -3
- data/Rakefile +47 -13
- data/bin/mtk +55 -20
- data/examples/crescendo.rb +4 -4
- data/examples/{drum_pattern1.rb → drum_pattern.rb} +8 -8
- data/examples/dynamic_pattern.rb +5 -5
- data/examples/gets_and_play.rb +3 -2
- data/examples/notation.rb +3 -3
- data/examples/play_midi.rb +4 -4
- data/examples/print_midi.rb +2 -2
- data/examples/random_tone_row.rb +3 -3
- data/examples/syntax_to_midi.rb +2 -2
- data/examples/test_output.rb +4 -5
- data/examples/tone_row_melody.rb +7 -5
- data/lib/mtk/core/duration.rb +213 -0
- data/lib/mtk/core/intensity.rb +158 -0
- data/lib/mtk/core/interval.rb +157 -0
- data/lib/mtk/core/pitch.rb +154 -0
- data/lib/mtk/core/pitch_class.rb +194 -0
- data/lib/mtk/events/event.rb +4 -4
- data/lib/mtk/events/note.rb +12 -12
- data/lib/mtk/events/timeline.rb +232 -0
- data/lib/mtk/groups/chord.rb +56 -0
- data/lib/mtk/{helpers → groups}/collection.rb +33 -1
- data/lib/mtk/groups/melody.rb +96 -0
- data/lib/mtk/groups/pitch_class_set.rb +163 -0
- data/lib/mtk/{helpers → groups}/pitch_collection.rb +1 -1
- data/lib/mtk/{midi → io}/dls_synth_device.rb +3 -1
- data/lib/mtk/{midi → io}/dls_synth_output.rb +10 -10
- data/lib/mtk/{midi → io}/jsound_input.rb +2 -2
- data/lib/mtk/{midi → io}/jsound_output.rb +9 -9
- data/lib/mtk/{midi/file.rb → io/midi_file.rb} +13 -13
- data/lib/mtk/{midi/input.rb → io/midi_input.rb} +4 -4
- data/lib/mtk/{midi/output.rb → io/midi_output.rb} +8 -8
- data/lib/mtk/{helpers/lilypond.rb → io/notation.rb} +5 -5
- data/lib/mtk/{midi → io}/unimidi_input.rb +2 -2
- data/lib/mtk/{midi → io}/unimidi_output.rb +14 -9
- data/lib/mtk/{constants → lang}/durations.rb +11 -11
- data/lib/mtk/{constants → lang}/intensities.rb +11 -11
- data/lib/mtk/{constants → lang}/intervals.rb +17 -17
- data/lib/mtk/lang/mtk_grammar.citrus +9 -9
- data/lib/mtk/{constants → lang}/pitch_classes.rb +5 -5
- data/lib/mtk/{constants → lang}/pitches.rb +7 -7
- data/lib/mtk/{helpers → lang}/pseudo_constants.rb +1 -1
- data/lib/mtk/{variable.rb → lang/variable.rb} +1 -1
- data/lib/mtk/numeric_extensions.rb +40 -47
- data/lib/mtk/patterns/for_each.rb +1 -1
- data/lib/mtk/patterns/pattern.rb +3 -3
- data/lib/mtk/sequencers/event_builder.rb +16 -15
- data/lib/mtk/sequencers/legato_sequencer.rb +1 -1
- data/lib/mtk/sequencers/rhythmic_sequencer.rb +1 -1
- data/lib/mtk/sequencers/sequencer.rb +8 -8
- data/lib/mtk/sequencers/step_sequencer.rb +2 -2
- data/lib/mtk.rb +33 -39
- data/spec/mtk/{duration_spec.rb → core/duration_spec.rb} +3 -3
- data/spec/mtk/{intensity_spec.rb → core/intensity_spec.rb} +3 -3
- data/spec/mtk/{interval_spec.rb → core/interval_spec.rb} +1 -1
- data/spec/mtk/{pitch_class_spec.rb → core/pitch_class_spec.rb} +1 -1
- data/spec/mtk/{pitch_spec.rb → core/pitch_spec.rb} +8 -8
- data/spec/mtk/events/event_spec.rb +4 -4
- data/spec/mtk/events/note_spec.rb +8 -8
- data/spec/mtk/{timeline_spec.rb → events/timeline_spec.rb} +47 -47
- data/spec/mtk/{chord_spec.rb → groups/chord_spec.rb} +18 -16
- data/spec/mtk/{helpers → groups}/collection_spec.rb +3 -3
- data/spec/mtk/{melody_spec.rb → groups/melody_spec.rb} +36 -34
- data/spec/mtk/{pitch_class_set_spec.rb → groups/pitch_class_set_spec.rb} +57 -55
- data/spec/mtk/{midi/file_spec.rb → io/midi_file_spec.rb} +17 -17
- data/spec/mtk/{midi/output_spec.rb → io/midi_output_spec.rb} +6 -6
- data/spec/mtk/{constants → lang}/durations_spec.rb +1 -1
- data/spec/mtk/{constants → lang}/intensities_spec.rb +1 -1
- data/spec/mtk/{constants → lang}/intervals_spec.rb +1 -1
- data/spec/mtk/lang/parser_spec.rb +12 -6
- data/spec/mtk/{constants → lang}/pitch_classes_spec.rb +1 -1
- data/spec/mtk/{constants → lang}/pitches_spec.rb +1 -1
- data/spec/mtk/{helpers → lang}/pseudo_constants_spec.rb +2 -2
- data/spec/mtk/{variable_spec.rb → lang/variable_spec.rb} +4 -4
- data/spec/mtk/numeric_extensions_spec.rb +35 -55
- data/spec/mtk/patterns/for_each_spec.rb +1 -1
- data/spec/mtk/patterns/sequence_spec.rb +1 -1
- data/spec/mtk/sequencers/legato_sequencer_spec.rb +2 -2
- data/spec/mtk/sequencers/rhythmic_sequencer_spec.rb +4 -4
- data/spec/mtk/sequencers/step_sequencer_spec.rb +5 -5
- data/spec/spec_helper.rb +7 -6
- metadata +75 -61
- data/ext/mkrf_conf.rb +0 -25
- data/lib/mtk/chord.rb +0 -55
- data/lib/mtk/duration.rb +0 -211
- data/lib/mtk/helpers/convert.rb +0 -36
- data/lib/mtk/helpers/output_selector.rb +0 -67
- data/lib/mtk/intensity.rb +0 -156
- data/lib/mtk/interval.rb +0 -155
- data/lib/mtk/melody.rb +0 -94
- data/lib/mtk/pitch.rb +0 -152
- data/lib/mtk/pitch_class.rb +0 -192
- data/lib/mtk/pitch_class_set.rb +0 -161
- data/lib/mtk/timeline.rb +0 -230
- data/spec/mtk/midi/jsound_input_spec.rb +0 -11
- data/spec/mtk/midi/jsound_output_spec.rb +0 -11
- data/spec/mtk/midi/unimidi_input_spec.rb +0 -11
- data/spec/mtk/midi/unimidi_output_spec.rb +0 -11
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'mtk/
|
2
|
+
require 'mtk/io/midi_file'
|
3
3
|
require 'tempfile'
|
4
4
|
|
5
|
-
describe MTK::
|
5
|
+
describe MTK::IO::MIDIFile do
|
6
6
|
|
7
7
|
let(:test_mid) { File.join(File.dirname(__FILE__), '..', '..', 'test.mid') }
|
8
8
|
|
@@ -28,11 +28,11 @@ describe MTK::MIDI::File do
|
|
28
28
|
|
29
29
|
describe "#to_timelines" do
|
30
30
|
it "converts a single-track MIDI file to an Array containing one Timeline" do
|
31
|
-
|
31
|
+
MIDIFile(test_mid).to_timelines.length.should == 1 # one track
|
32
32
|
end
|
33
33
|
|
34
34
|
it "converts note on/off messages to Note events" do
|
35
|
-
|
35
|
+
MIDIFile(test_mid).to_timelines.first.should == {
|
36
36
|
0.0 => [Note(C4, 0.25, 126/127.0)],
|
37
37
|
1.0 => [Note(Db4, 0.5, 99/127.0)],
|
38
38
|
2.0 => [Note(D4, 0.75, 72/127.0)],
|
@@ -43,8 +43,8 @@ describe MTK::MIDI::File do
|
|
43
43
|
|
44
44
|
describe "#write_timeline" do
|
45
45
|
it 'writes monophonic Notes in a Timeline to a MIDI file' do
|
46
|
-
|
47
|
-
Timeline.
|
46
|
+
MIDIFile(tempfile).write_timeline(
|
47
|
+
MTK::Events::Timeline.from_h({
|
48
48
|
0 => Note(C4, q, 0.7),
|
49
49
|
1 => Note(G4, q, 0.8),
|
50
50
|
2 => Note(C5, q, 0.9)
|
@@ -83,8 +83,8 @@ describe MTK::MIDI::File do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'writes polyphonic (simultaneous) Notes in a Timeline to a MIDI file' do
|
86
|
-
|
87
|
-
Timeline.
|
86
|
+
MIDIFile(tempfile).write_timeline(
|
87
|
+
MTK::Events::Timeline.from_h({
|
88
88
|
0 => [Note(C4,q,0.5), Note(E4,q,0.5)],
|
89
89
|
2.0 => [Note(G4,h,1), Note(B4,h,1), Note(D5,h,1)]
|
90
90
|
})
|
@@ -134,8 +134,8 @@ describe MTK::MIDI::File do
|
|
134
134
|
end
|
135
135
|
|
136
136
|
it 'ignores rests (events with negative duration)' do
|
137
|
-
|
138
|
-
Timeline.
|
137
|
+
MIDIFile(tempfile).write_timeline(
|
138
|
+
MTK::Events::Timeline.from_h({
|
139
139
|
0 => Note(C4, q, 0.7),
|
140
140
|
1 => Note(G4, -q, 0.8), # this is a rest because it has a negative duration
|
141
141
|
2 => Note(C5, q, 0.9)
|
@@ -170,12 +170,12 @@ describe MTK::MIDI::File do
|
|
170
170
|
|
171
171
|
describe "#write_timelines" do
|
172
172
|
it "writes a multitrack MIDI file" do
|
173
|
-
|
174
|
-
Timeline.
|
173
|
+
MIDIFile(tempfile).write_timelines([
|
174
|
+
MTK::Events::Timeline.from_h({
|
175
175
|
0 => Note(C4, q, 0.7),
|
176
176
|
1.0 => Note(G4, q, 0.8),
|
177
177
|
}),
|
178
|
-
Timeline.
|
178
|
+
MTK::Events::Timeline.from_h({
|
179
179
|
1 => Note(C5, h, 0.9),
|
180
180
|
2 => Note(D5, h, 1),
|
181
181
|
}),
|
@@ -226,15 +226,15 @@ describe MTK::MIDI::File do
|
|
226
226
|
|
227
227
|
describe "#write" do
|
228
228
|
it "calls write_timeline when given a Timeline" do
|
229
|
-
midi_file =
|
230
|
-
timeline =
|
229
|
+
midi_file = MIDIFile(nil)
|
230
|
+
timeline = MTK::Events::Timeline.new
|
231
231
|
midi_file.should_receive(:write_timeline).with(timeline)
|
232
232
|
midi_file.write(timeline)
|
233
233
|
end
|
234
234
|
|
235
235
|
it "calls write_timelines when given an Array" do
|
236
|
-
midi_file =
|
237
|
-
timelines = [Timeline.new]
|
236
|
+
midi_file = MIDIFile(nil)
|
237
|
+
timelines = [MTK::Events::Timeline.new]
|
238
238
|
midi_file.should_receive(:write_timelines).with(timelines)
|
239
239
|
midi_file.write(timelines)
|
240
240
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'mtk/
|
2
|
+
require 'mtk/io/midi_output'
|
3
3
|
|
4
|
-
describe MTK::
|
4
|
+
describe MTK::IO::MIDIOutput do
|
5
5
|
|
6
|
-
class MockOuput < MTK::
|
6
|
+
class MockOuput < MTK::IO::MIDIOutput
|
7
7
|
public_class_method :new
|
8
8
|
end
|
9
9
|
|
@@ -24,7 +24,7 @@ describe MTK::MIDI::Output do
|
|
24
24
|
|
25
25
|
def timeline_with_param_event(event_type, event_options={})
|
26
26
|
event = MTK::Events::Parameter.new event_type, event_options
|
27
|
-
|
27
|
+
MTK::Events::Timeline.from_h 0 => event
|
28
28
|
end
|
29
29
|
|
30
30
|
def should_be_scheduled timed_data
|
@@ -51,7 +51,7 @@ describe MTK::MIDI::Output do
|
|
51
51
|
it "handles note events" do
|
52
52
|
should_be_scheduled 0 => [:note_on, 60, 127, 0],
|
53
53
|
1 => [:note_off, 60, 127, 0]
|
54
|
-
subject.play
|
54
|
+
subject.play MTK::Events::Timeline.from_h( 0 => Note(C4,fff,1) )
|
55
55
|
end
|
56
56
|
|
57
57
|
it "handles control events" do
|
@@ -94,7 +94,7 @@ describe MTK::MIDI::Output do
|
|
94
94
|
1 => [:note_off, 60, 127, 0],
|
95
95
|
2 => [:note_on, 67, 127, 0],
|
96
96
|
3 => [:note_off, 67, 127, 0]
|
97
|
-
subject.play [MTK::Timeline.
|
97
|
+
subject.play [ MTK::Events::Timeline.from_h( 0 => Note(C4,fff,1) ), MTK::Events::Timeline.from_h( 2 => Note(G4,fff,1) )]
|
98
98
|
end
|
99
99
|
|
100
100
|
end
|
@@ -23,7 +23,7 @@ describe MTK::Lang::Parser do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def var(name)
|
26
|
-
::MTK::Variable.new(name)
|
26
|
+
::MTK::Lang::Variable.new(name)
|
27
27
|
end
|
28
28
|
|
29
29
|
|
@@ -33,6 +33,12 @@ describe MTK::Lang::Parser do
|
|
33
33
|
|
34
34
|
|
35
35
|
describe ".parse" do
|
36
|
+
it "can parse a single pitch class and play it" do
|
37
|
+
sequencer = MTK::Lang::Parser.parse('c')
|
38
|
+
timeline = sequencer.to_timeline
|
39
|
+
timeline.should == MTK::Events::Timeline.from_h({0 => MTK.Note(C4)})
|
40
|
+
end
|
41
|
+
|
36
42
|
context "default (root rule) behavior" do
|
37
43
|
it "parses a bare_sequencer" do
|
38
44
|
sequencer = parse('C:q:mp D4:ff A i:p Eb:pp Bb7 F2:h. F#4:mf:s q ppp')
|
@@ -52,7 +58,7 @@ describe MTK::Lang::Parser do
|
|
52
58
|
0 => C4:mp:q
|
53
59
|
1 => D4:o:h
|
54
60
|
}
|
55
|
-
").should ==
|
61
|
+
").should == MTK::Events::Timeline.from_h({0 => chain(C4,mp,q), 1 => chain(D4,o,h)})
|
56
62
|
end
|
57
63
|
|
58
64
|
it "parses a chain of sequences" do
|
@@ -146,7 +152,7 @@ describe MTK::Lang::Parser do
|
|
146
152
|
|
147
153
|
context "timeline rule" do
|
148
154
|
it "parses a very simple Timeline" do
|
149
|
-
parse("{0 => C}", :timeline).should ==
|
155
|
+
parse("{0 => C}", :timeline).should == MTK::Events::Timeline.from_h({0 => seq(C)})
|
150
156
|
end
|
151
157
|
|
152
158
|
it "parses a Timeline with one entry" do
|
@@ -154,7 +160,7 @@ describe MTK::Lang::Parser do
|
|
154
160
|
{
|
155
161
|
0 => C4:mp:q
|
156
162
|
}
|
157
|
-
", :timeline).should ==
|
163
|
+
", :timeline).should == MTK::Events::Timeline.from_h({0 => chain(C4,mp,q)})
|
158
164
|
end
|
159
165
|
|
160
166
|
it "parses a Timeline with multiple entries" do
|
@@ -163,7 +169,7 @@ describe MTK::Lang::Parser do
|
|
163
169
|
0 => C4:mp:q
|
164
170
|
1 => D4:o:h
|
165
171
|
}
|
166
|
-
", :timeline).should ==
|
172
|
+
", :timeline).should == MTK::Events::Timeline.from_h({0 => chain(C4,mp,q), 1 => chain(D4,o,h)})
|
167
173
|
end
|
168
174
|
|
169
175
|
#it "parses a Timeline containing a chord" do
|
@@ -171,7 +177,7 @@ describe MTK::Lang::Parser do
|
|
171
177
|
# {
|
172
178
|
# 0 => [C4 E4 G4]:fff:w
|
173
179
|
# }
|
174
|
-
# ", :timeline).should == Timeline.
|
180
|
+
# ", :timeline).should == Timeline.from_h({0 => chain(Chord(C4,E4,G4),fff,w)})
|
175
181
|
#end
|
176
182
|
end
|
177
183
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe MTK::Variable do
|
3
|
+
describe MTK::Lang::Variable do
|
4
4
|
|
5
5
|
def var(*args)
|
6
|
-
::MTK::Variable.new(*args)
|
6
|
+
::MTK::Lang::Variable.new(*args)
|
7
7
|
end
|
8
8
|
|
9
9
|
describe '#name' do
|
@@ -41,11 +41,11 @@ describe MTK::Variable do
|
|
41
41
|
|
42
42
|
describe '#to_s' do
|
43
43
|
it "includes just the variable name when there's no value" do
|
44
|
-
var('$').to_s.should == 'MTK::Variable<$>'
|
44
|
+
var('$').to_s.should == 'MTK::Lang::Variable<$>'
|
45
45
|
end
|
46
46
|
|
47
47
|
it "includes just the variable name and value when there's a value" do
|
48
|
-
var('x',1).to_s.should == 'MTK::Variable<x=1>'
|
48
|
+
var('x',1).to_s.should == 'MTK::Lang::Variable<x=1>'
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -3,99 +3,79 @@ require 'mtk/numeric_extensions'
|
|
3
3
|
|
4
4
|
describe Numeric do
|
5
5
|
|
6
|
-
describe
|
7
|
-
it "
|
8
|
-
|
6
|
+
describe "#to_pitch" do
|
7
|
+
it "acts like Pitch.from_f applied to the Numeric value" do
|
8
|
+
12.3.to_pitch.should == MTK::Core::Pitch.from_f(12.3)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
describe "#cents" do
|
13
|
-
it "is the Numeric / 100.0" do
|
14
|
-
100.cents.should == 1
|
15
|
-
end
|
16
|
-
end
|
17
12
|
|
18
|
-
describe "#
|
19
|
-
it "
|
20
|
-
|
13
|
+
describe "#to_pitch_class" do
|
14
|
+
it "acts like PitchClass.from_f applied to the Numeric value" do
|
15
|
+
6.to_pitch_class.should == MTK::Core::PitchClass.from_f(6)
|
21
16
|
end
|
22
17
|
end
|
23
18
|
|
24
|
-
describe "#major_seconds" do
|
25
|
-
it "is the Numeric * 2" do
|
26
|
-
2.major_seconds.should == 4
|
27
|
-
end
|
28
|
-
end
|
29
19
|
|
30
|
-
describe "#
|
31
|
-
it "
|
32
|
-
|
20
|
+
describe "#to_duration" do
|
21
|
+
it "acts like Duration.from_f applied to the Numeric value" do
|
22
|
+
1.5.to_duration.should == MTK::Core::Duration.from_f(1.5)
|
33
23
|
end
|
34
24
|
end
|
35
25
|
|
36
|
-
describe "#
|
37
|
-
it "
|
38
|
-
|
26
|
+
describe "#beat" do
|
27
|
+
it "acts like #to_duration" do
|
28
|
+
1.beat.should == 1.to_duration
|
39
29
|
end
|
40
30
|
end
|
41
31
|
|
42
|
-
describe "#
|
43
|
-
it "
|
44
|
-
2.
|
32
|
+
describe "#beats" do
|
33
|
+
it "acts like #to_duration" do
|
34
|
+
2.beats.should == 2.to_duration
|
45
35
|
end
|
46
36
|
end
|
47
37
|
|
48
|
-
describe "#tritones" do
|
49
|
-
it "is the Numeric * 6" do
|
50
|
-
2.tritones.should == 12
|
51
|
-
end
|
52
|
-
end
|
53
38
|
|
54
|
-
describe "#
|
55
|
-
it "
|
56
|
-
|
39
|
+
describe "#to_intensity" do
|
40
|
+
it "acts like Intensity.from_f applied to the Numeric value" do
|
41
|
+
0.75.to_intensity.should == MTK::Core::Intensity.from_f(0.75)
|
57
42
|
end
|
58
43
|
end
|
59
44
|
|
60
|
-
describe "#
|
61
|
-
it "
|
62
|
-
|
45
|
+
describe "#percent_intensity" do
|
46
|
+
it "acts like Intensity.from_f applied to 1/100 of the Numeric value" do
|
47
|
+
75.percent_intensity.should == MTK::Core::Intensity.from_f(0.75)
|
63
48
|
end
|
64
49
|
end
|
65
50
|
|
66
|
-
describe "#perfect_fifths" do
|
67
|
-
it "is the Numeric * 7" do
|
68
|
-
2.perfect_fifths.should == 14
|
69
|
-
end
|
70
|
-
end
|
71
51
|
|
72
|
-
describe "#
|
73
|
-
it "
|
74
|
-
|
52
|
+
describe "#to_interval" do
|
53
|
+
it "acts like Interval.from_f applied to the Numeric value" do
|
54
|
+
3.5.to_interval.should == MTK::Core::Interval.from_f(3.5)
|
75
55
|
end
|
76
56
|
end
|
77
57
|
|
78
|
-
describe
|
79
|
-
it "
|
80
|
-
|
58
|
+
describe '#semitone' do
|
59
|
+
it "acts like #to_interval" do
|
60
|
+
1.semitone.should == 1.to_interval
|
81
61
|
end
|
82
62
|
end
|
83
63
|
|
84
|
-
describe
|
85
|
-
it "
|
86
|
-
2.
|
64
|
+
describe '#semitones' do
|
65
|
+
it "acts like #to_interval" do
|
66
|
+
2.semitones.should == 2.to_interval
|
87
67
|
end
|
88
68
|
end
|
89
69
|
|
90
|
-
describe "#
|
91
|
-
it "
|
92
|
-
|
70
|
+
describe "#cents" do
|
71
|
+
it "acts like Interval.from_f applied to 1/100 of the Numeric value" do
|
72
|
+
50.cents.should == MTK::Core::Interval.from_f(0.5)
|
93
73
|
end
|
94
74
|
end
|
95
75
|
|
96
76
|
describe "#octaves" do
|
97
|
-
it "
|
98
|
-
2.octaves.should == 24
|
77
|
+
it "acts like Interval.from_f applied to 12 times the Numeric value" do
|
78
|
+
2.octaves.should == MTK::Core::Interval.from_f(24)
|
99
79
|
end
|
100
80
|
end
|
101
81
|
|
@@ -8,7 +8,7 @@ describe MTK::Patterns::Sequence do
|
|
8
8
|
let(:sequence) { SEQUENCE.new(elements) }
|
9
9
|
|
10
10
|
it "is a MTK::Collection" do
|
11
|
-
sequence.should be_a MTK::
|
11
|
+
sequence.should be_a MTK::Groups::Collection
|
12
12
|
# and now we won't test any other collection features here... see collection_spec
|
13
13
|
end
|
14
14
|
|
@@ -12,7 +12,7 @@ describe MTK::Sequencers::LegatoSequencer do
|
|
12
12
|
|
13
13
|
describe "#to_timeline" do
|
14
14
|
it "contains notes assembled from the given patterns, with Timeline time deltas from the max event duration at the previous step" do
|
15
|
-
legato_sequencer.to_timeline.should ==
|
15
|
+
legato_sequencer.to_timeline.should == MTK::Events::Timeline.from_h({
|
16
16
|
0 => Note(C4,1,0.3),
|
17
17
|
1.0 => Note(D4,0.5,0.6),
|
18
18
|
1.5 => Note(E4,1.5,0.9),
|
@@ -22,7 +22,7 @@ describe MTK::Sequencers::LegatoSequencer do
|
|
22
22
|
|
23
23
|
it "treats negative durations as rests" do
|
24
24
|
legato_sequencer = LEGATO_SEQUENCER.new( [pitches, Patterns.DurationSequence(-1,-0.5,-1.5,4), intensities] )
|
25
|
-
legato_sequencer.to_timeline.should ==
|
25
|
+
legato_sequencer.to_timeline.should == MTK::Events::Timeline.from_h({
|
26
26
|
3.0 => Note(C4,4,1.0)
|
27
27
|
})
|
28
28
|
end
|
@@ -23,11 +23,11 @@ describe MTK::Sequencers::RhythmicSequencer do
|
|
23
23
|
|
24
24
|
describe "#to_timeline" do
|
25
25
|
it "returns a Timeline" do
|
26
|
-
rhythmic_sequencer.to_timeline.should be_a
|
26
|
+
rhythmic_sequencer.to_timeline.should be_a MTK::Events::Timeline
|
27
27
|
end
|
28
28
|
|
29
29
|
it "contains notes assembled from the given patterns, with Timeline time deltas from the :rhythm type pattern" do
|
30
|
-
rhythmic_sequencer.to_timeline.should ==
|
30
|
+
rhythmic_sequencer.to_timeline.should == MTK::Events::Timeline.from_h({
|
31
31
|
0 => Note(C4,1,0.3),
|
32
32
|
0.5 => Note(D4,1,0.6),
|
33
33
|
2.0 => Note(E4,2,0.9),
|
@@ -38,7 +38,7 @@ describe MTK::Sequencers::RhythmicSequencer do
|
|
38
38
|
|
39
39
|
it "uses the absolute value of any negative durations in the rhythm pattern" do
|
40
40
|
timeline = RHYTHMIC_SEQUENCER.new( [pitches, intensities, durations], rhythm: Patterns.RhythmSequence(-0.5, 1.5, -4) ).to_timeline
|
41
|
-
timeline.should ==
|
41
|
+
timeline.should == MTK::Events::Timeline.from_h({
|
42
42
|
0 => Note(C4,1,0.3),
|
43
43
|
0.5 => Note(D4,1,0.6),
|
44
44
|
2.0 => Note(E4,2,0.9),
|
@@ -50,7 +50,7 @@ describe MTK::Sequencers::RhythmicSequencer do
|
|
50
50
|
describe "#max_steps" do
|
51
51
|
it "controls the maximum number of times in the generated timeline" do
|
52
52
|
rhythmic_sequencer.max_steps = 2
|
53
|
-
rhythmic_sequencer.to_timeline.should ==
|
53
|
+
rhythmic_sequencer.to_timeline.should == MTK::Events::Timeline.from_h({
|
54
54
|
0 => Note(C4,1,0.3),
|
55
55
|
0.5 => Note(D4,1,0.6)
|
56
56
|
})
|
@@ -32,12 +32,12 @@ describe MTK::Sequencers::StepSequencer do
|
|
32
32
|
describe "#to_timeline" do
|
33
33
|
it "returns a Timeline" do
|
34
34
|
timeline = step_sequencer.to_timeline
|
35
|
-
timeline.should be_a
|
35
|
+
timeline.should be_a MTK::Events::Timeline
|
36
36
|
end
|
37
37
|
|
38
38
|
it "contains notes assembled from the given patterns" do
|
39
39
|
timeline = step_sequencer.to_timeline
|
40
|
-
timeline.should ==
|
40
|
+
timeline.should == MTK::Events::Timeline.from_h({
|
41
41
|
0 => Note(C4,1,0.3),
|
42
42
|
1 => Note(D4,1,0.7),
|
43
43
|
2 => Note(E4,2,1.0)
|
@@ -46,7 +46,7 @@ describe MTK::Sequencers::StepSequencer do
|
|
46
46
|
|
47
47
|
it "treats negative durations as rests" do
|
48
48
|
timeline = STEP_SEQUENCER.new( [pitches, intensities, Patterns.DurationSequence(1, -1, 2)] ).to_timeline
|
49
|
-
timeline.should ==
|
49
|
+
timeline.should == MTK::Events::Timeline.from_h({
|
50
50
|
0 => Note(C4,1,0.3),
|
51
51
|
2 => Note(E4,2,1.0)
|
52
52
|
})
|
@@ -57,7 +57,7 @@ describe MTK::Sequencers::StepSequencer do
|
|
57
57
|
it "controls the delta between each time in the generated timeline" do
|
58
58
|
step_sequencer.step_size = 2
|
59
59
|
timeline = step_sequencer.to_timeline
|
60
|
-
timeline.should ==
|
60
|
+
timeline.should == MTK::Events::Timeline.from_h({
|
61
61
|
0 => Note(C4,1,0.3),
|
62
62
|
2 => Note(D4,1,0.7),
|
63
63
|
4 => Note(E4,2,1.0)
|
@@ -69,7 +69,7 @@ describe MTK::Sequencers::StepSequencer do
|
|
69
69
|
it "controls the maximum number of times in the generated timeline" do
|
70
70
|
step_sequencer.max_steps = 2
|
71
71
|
timeline = step_sequencer.to_timeline
|
72
|
-
timeline.should ==
|
72
|
+
timeline.should == MTK::Events::Timeline.from_h({
|
73
73
|
0 => Note(C4,1,0.3),
|
74
74
|
1 => Note(D4,1,0.7)
|
75
75
|
})
|
data/spec/spec_helper.rb
CHANGED
@@ -2,10 +2,11 @@ $__RUNNING_RSPEC_TESTS__ = true
|
|
2
2
|
|
3
3
|
require 'mtk'
|
4
4
|
include MTK
|
5
|
-
include
|
6
|
-
include
|
7
|
-
include
|
8
|
-
include
|
9
|
-
include
|
10
|
-
include
|
5
|
+
include MTK::Core
|
6
|
+
include MTK::Lang
|
7
|
+
include MTK::Lang::PitchClasses
|
8
|
+
include MTK::Lang::Pitches
|
9
|
+
include MTK::Lang::Intensities
|
10
|
+
include MTK::Lang::Durations
|
11
|
+
include MTK::Lang::Intervals
|
11
12
|
|