mtk 0.0.3.2 → 0.0.3.3

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.
Files changed (102) hide show
  1. data/.yardopts +2 -2
  2. data/DEVELOPMENT_NOTES.md +20 -0
  3. data/README.md +9 -3
  4. data/Rakefile +47 -13
  5. data/bin/mtk +55 -20
  6. data/examples/crescendo.rb +4 -4
  7. data/examples/{drum_pattern1.rb → drum_pattern.rb} +8 -8
  8. data/examples/dynamic_pattern.rb +5 -5
  9. data/examples/gets_and_play.rb +3 -2
  10. data/examples/notation.rb +3 -3
  11. data/examples/play_midi.rb +4 -4
  12. data/examples/print_midi.rb +2 -2
  13. data/examples/random_tone_row.rb +3 -3
  14. data/examples/syntax_to_midi.rb +2 -2
  15. data/examples/test_output.rb +4 -5
  16. data/examples/tone_row_melody.rb +7 -5
  17. data/lib/mtk/core/duration.rb +213 -0
  18. data/lib/mtk/core/intensity.rb +158 -0
  19. data/lib/mtk/core/interval.rb +157 -0
  20. data/lib/mtk/core/pitch.rb +154 -0
  21. data/lib/mtk/core/pitch_class.rb +194 -0
  22. data/lib/mtk/events/event.rb +4 -4
  23. data/lib/mtk/events/note.rb +12 -12
  24. data/lib/mtk/events/timeline.rb +232 -0
  25. data/lib/mtk/groups/chord.rb +56 -0
  26. data/lib/mtk/{helpers → groups}/collection.rb +33 -1
  27. data/lib/mtk/groups/melody.rb +96 -0
  28. data/lib/mtk/groups/pitch_class_set.rb +163 -0
  29. data/lib/mtk/{helpers → groups}/pitch_collection.rb +1 -1
  30. data/lib/mtk/{midi → io}/dls_synth_device.rb +3 -1
  31. data/lib/mtk/{midi → io}/dls_synth_output.rb +10 -10
  32. data/lib/mtk/{midi → io}/jsound_input.rb +2 -2
  33. data/lib/mtk/{midi → io}/jsound_output.rb +9 -9
  34. data/lib/mtk/{midi/file.rb → io/midi_file.rb} +13 -13
  35. data/lib/mtk/{midi/input.rb → io/midi_input.rb} +4 -4
  36. data/lib/mtk/{midi/output.rb → io/midi_output.rb} +8 -8
  37. data/lib/mtk/{helpers/lilypond.rb → io/notation.rb} +5 -5
  38. data/lib/mtk/{midi → io}/unimidi_input.rb +2 -2
  39. data/lib/mtk/{midi → io}/unimidi_output.rb +14 -9
  40. data/lib/mtk/{constants → lang}/durations.rb +11 -11
  41. data/lib/mtk/{constants → lang}/intensities.rb +11 -11
  42. data/lib/mtk/{constants → lang}/intervals.rb +17 -17
  43. data/lib/mtk/lang/mtk_grammar.citrus +9 -9
  44. data/lib/mtk/{constants → lang}/pitch_classes.rb +5 -5
  45. data/lib/mtk/{constants → lang}/pitches.rb +7 -7
  46. data/lib/mtk/{helpers → lang}/pseudo_constants.rb +1 -1
  47. data/lib/mtk/{variable.rb → lang/variable.rb} +1 -1
  48. data/lib/mtk/numeric_extensions.rb +40 -47
  49. data/lib/mtk/patterns/for_each.rb +1 -1
  50. data/lib/mtk/patterns/pattern.rb +3 -3
  51. data/lib/mtk/sequencers/event_builder.rb +16 -15
  52. data/lib/mtk/sequencers/legato_sequencer.rb +1 -1
  53. data/lib/mtk/sequencers/rhythmic_sequencer.rb +1 -1
  54. data/lib/mtk/sequencers/sequencer.rb +8 -8
  55. data/lib/mtk/sequencers/step_sequencer.rb +2 -2
  56. data/lib/mtk.rb +33 -39
  57. data/spec/mtk/{duration_spec.rb → core/duration_spec.rb} +3 -3
  58. data/spec/mtk/{intensity_spec.rb → core/intensity_spec.rb} +3 -3
  59. data/spec/mtk/{interval_spec.rb → core/interval_spec.rb} +1 -1
  60. data/spec/mtk/{pitch_class_spec.rb → core/pitch_class_spec.rb} +1 -1
  61. data/spec/mtk/{pitch_spec.rb → core/pitch_spec.rb} +8 -8
  62. data/spec/mtk/events/event_spec.rb +4 -4
  63. data/spec/mtk/events/note_spec.rb +8 -8
  64. data/spec/mtk/{timeline_spec.rb → events/timeline_spec.rb} +47 -47
  65. data/spec/mtk/{chord_spec.rb → groups/chord_spec.rb} +18 -16
  66. data/spec/mtk/{helpers → groups}/collection_spec.rb +3 -3
  67. data/spec/mtk/{melody_spec.rb → groups/melody_spec.rb} +36 -34
  68. data/spec/mtk/{pitch_class_set_spec.rb → groups/pitch_class_set_spec.rb} +57 -55
  69. data/spec/mtk/{midi/file_spec.rb → io/midi_file_spec.rb} +17 -17
  70. data/spec/mtk/{midi/output_spec.rb → io/midi_output_spec.rb} +6 -6
  71. data/spec/mtk/{constants → lang}/durations_spec.rb +1 -1
  72. data/spec/mtk/{constants → lang}/intensities_spec.rb +1 -1
  73. data/spec/mtk/{constants → lang}/intervals_spec.rb +1 -1
  74. data/spec/mtk/lang/parser_spec.rb +12 -6
  75. data/spec/mtk/{constants → lang}/pitch_classes_spec.rb +1 -1
  76. data/spec/mtk/{constants → lang}/pitches_spec.rb +1 -1
  77. data/spec/mtk/{helpers → lang}/pseudo_constants_spec.rb +2 -2
  78. data/spec/mtk/{variable_spec.rb → lang/variable_spec.rb} +4 -4
  79. data/spec/mtk/numeric_extensions_spec.rb +35 -55
  80. data/spec/mtk/patterns/for_each_spec.rb +1 -1
  81. data/spec/mtk/patterns/sequence_spec.rb +1 -1
  82. data/spec/mtk/sequencers/legato_sequencer_spec.rb +2 -2
  83. data/spec/mtk/sequencers/rhythmic_sequencer_spec.rb +4 -4
  84. data/spec/mtk/sequencers/step_sequencer_spec.rb +5 -5
  85. data/spec/spec_helper.rb +7 -6
  86. metadata +75 -61
  87. data/ext/mkrf_conf.rb +0 -25
  88. data/lib/mtk/chord.rb +0 -55
  89. data/lib/mtk/duration.rb +0 -211
  90. data/lib/mtk/helpers/convert.rb +0 -36
  91. data/lib/mtk/helpers/output_selector.rb +0 -67
  92. data/lib/mtk/intensity.rb +0 -156
  93. data/lib/mtk/interval.rb +0 -155
  94. data/lib/mtk/melody.rb +0 -94
  95. data/lib/mtk/pitch.rb +0 -152
  96. data/lib/mtk/pitch_class.rb +0 -192
  97. data/lib/mtk/pitch_class_set.rb +0 -161
  98. data/lib/mtk/timeline.rb +0 -230
  99. data/spec/mtk/midi/jsound_input_spec.rb +0 -11
  100. data/spec/mtk/midi/jsound_output_spec.rb +0 -11
  101. data/spec/mtk/midi/unimidi_input_spec.rb +0 -11
  102. data/spec/mtk/midi/unimidi_output_spec.rb +0 -11
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
- require 'mtk/midi/file'
2
+ require 'mtk/io/midi_file'
3
3
  require 'tempfile'
4
4
 
5
- describe MTK::MIDI::File do
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
- MIDI_File(test_mid).to_timelines.length.should == 1 # one track
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
- MIDI_File(test_mid).to_timelines.first.should == {
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
- MIDI_File(tempfile).write_timeline(
47
- Timeline.from_hash({
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
- MIDI_File(tempfile).write_timeline(
87
- Timeline.from_hash({
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
- MIDI_File(tempfile).write_timeline(
138
- Timeline.from_hash({
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
- MIDI_File(tempfile).write_timelines([
174
- Timeline.from_hash({
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.from_hash({
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 = MIDI_File(nil)
230
- timeline = Timeline.new
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 = MIDI_File(nil)
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/midi/output'
2
+ require 'mtk/io/midi_output'
3
3
 
4
- describe MTK::MIDI::Output do
4
+ describe MTK::IO::MIDIOutput do
5
5
 
6
- class MockOuput < MTK::MIDI::Output
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
- MTK::Timeline.from_hash 0 => event
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 MTK::Timeline.from_hash( 0 => Note(C4,fff,1) )
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.from_hash( 0 => Note(C4,fff,1) ), MTK::Timeline.from_hash( 2 => Note(G4,fff,1) )]
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
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MTK::Constants::Durations do
3
+ describe MTK::Lang::Durations do
4
4
 
5
5
  describe 'w' do
6
6
  it 'is 4 beats' do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MTK::Constants::Intensities do
3
+ describe MTK::Lang::Intensities do
4
4
 
5
5
  describe 'ppp' do
6
6
  it 'is equivalent to MIDI velocity 16' do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MTK::Constants::Intervals do
3
+ describe MTK::Lang::Intervals do
4
4
 
5
5
  describe 'P1' do
6
6
  it 'is 0 semitones' do
@@ -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 == Timeline.from_hash({0 => chain(C4,mp,q), 1 => chain(D4,o,h)})
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 == Timeline.from_hash({0 => seq(C)})
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 == Timeline.from_hash({0 => chain(C4,mp,q)})
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 == Timeline.from_hash({0 => chain(C4,mp,q), 1 => chain(D4,o,h)})
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.from_hash({0 => chain(Chord(C4,E4,G4),fff,w)})
180
+ # ", :timeline).should == Timeline.from_h({0 => chain(Chord(C4,E4,G4),fff,w)})
175
181
  #end
176
182
  end
177
183
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MTK::Constants::PitchClasses do
3
+ describe MTK::Lang::PitchClasses do
4
4
  let(:cases) {
5
5
  [
6
6
  [PitchClass['C'], 'C', 0],
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MTK::Constants::Pitches do
3
+ describe MTK::Lang::Pitches do
4
4
 
5
5
  it "defines constants for the 128 notes in MIDI" do
6
6
  Pitches.constants.length.should == 130 # there's also the PITCHES and PITCH_NAMES constants
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MTK::Helpers::PseudoConstants do
3
+ describe MTK::Lang::PseudoConstants do
4
4
 
5
5
  module MockConstants
6
- extend MTK::Helpers::PseudoConstants
6
+ extend MTK::Lang::PseudoConstants
7
7
  define_constant 'constant', :value
8
8
  end
9
9
 
@@ -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 '#semitones' do
7
- it "is the Numeric value" do
8
- 100.semitones.should == 100
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 "#minor_seconds" do
19
- it "is the Numeric value" do
20
- 2.minor_seconds.should == 2
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 "#minor_thirds" do
31
- it "is the Numeric * 3" do
32
- 2.minor_thirds.should == 6
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 "#major_thirds" do
37
- it "is the Numeric * 4" do
38
- 2.major_thirds.should == 8
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 "#perfect_fourths" do
43
- it "is the Numeric * 5" do
44
- 2.perfect_fourths.should == 10
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 "#augmented_fourths" do
55
- it "is the Numeric * 6" do
56
- 2.augmented_fourths.should == 12
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 "#diminshed_fifths" do
61
- it "is the Numeric * 6" do
62
- 2.diminshed_fifths.should == 12
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 "#minor_sixths" do
73
- it "is the Numeric * 8" do
74
- 2.minor_sixths.should == 16
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 "#major_sixths" do
79
- it "is the Numeric * 9" do
80
- 2.major_sixths.should == 18
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 "#minor_sevenths" do
85
- it "is the Numeric * 10" do
86
- 2.minor_sevenths.should == 20
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 "#major_sevenths" do
91
- it "is the Numeric * 11" do
92
- 2.major_sevenths.should == 22
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 "is the Numeric * 12" do
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
 
@@ -5,7 +5,7 @@ describe MTK::Patterns::ForEach do
5
5
  FOREACH = ::MTK::Patterns::ForEach
6
6
 
7
7
  def var(name)
8
- ::MTK::Variable.new(name)
8
+ ::MTK::Lang::Variable.new(name)
9
9
  end
10
10
 
11
11
  def seq(*args)
@@ -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::Helpers::Collection
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 == Timeline.from_hash({
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 == Timeline.from_hash({
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 Timeline
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 == Timeline.from_hash({
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 == Timeline.from_hash({
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 == Timeline.from_hash({
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 Timeline
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 == Timeline.from_hash({
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 == Timeline.from_hash({
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 == Timeline.from_hash({
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 == Timeline.from_hash({
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 Constants
6
- include PitchClasses
7
- include Pitches
8
- include Intensities
9
- include Durations
10
- include Intervals
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