musa-dsl 0.14.26 → 0.21.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/Gemfile +0 -1
- data/README.md +5 -1
- data/lib/musa-dsl.rb +54 -11
- data/lib/musa-dsl/core-ext.rb +7 -13
- data/lib/musa-dsl/core-ext/array-explode-ranges.rb +15 -23
- data/lib/musa-dsl/core-ext/arrayfy.rb +30 -12
- data/lib/musa-dsl/core-ext/attribute-builder.rb +194 -0
- data/lib/musa-dsl/core-ext/deep-copy.rb +185 -0
- data/lib/musa-dsl/core-ext/dynamic-proxy.rb +44 -40
- data/lib/musa-dsl/core-ext/inspect-nice.rb +40 -22
- data/lib/musa-dsl/core-ext/smart-proc-binder.rb +108 -0
- data/lib/musa-dsl/core-ext/with.rb +26 -0
- data/lib/musa-dsl/datasets.rb +8 -3
- data/lib/musa-dsl/datasets/dataset.rb +3 -0
- data/lib/musa-dsl/datasets/delta-d.rb +12 -0
- data/lib/musa-dsl/datasets/e.rb +61 -0
- data/lib/musa-dsl/datasets/gdv.rb +51 -411
- data/lib/musa-dsl/datasets/gdvd.rb +179 -0
- data/lib/musa-dsl/datasets/helper.rb +41 -0
- data/lib/musa-dsl/datasets/p.rb +68 -0
- data/lib/musa-dsl/datasets/packed-v.rb +19 -0
- data/lib/musa-dsl/datasets/pdv.rb +22 -15
- data/lib/musa-dsl/datasets/ps.rb +113 -0
- data/lib/musa-dsl/datasets/score.rb +210 -0
- data/lib/musa-dsl/datasets/score/queriable.rb +48 -0
- data/lib/musa-dsl/datasets/score/render.rb +31 -0
- data/lib/musa-dsl/datasets/score/to-mxml/process-pdv.rb +160 -0
- data/lib/musa-dsl/datasets/score/to-mxml/process-ps.rb +51 -0
- data/lib/musa-dsl/datasets/score/to-mxml/process-time.rb +153 -0
- data/lib/musa-dsl/datasets/score/to-mxml/to-mxml.rb +158 -0
- data/lib/musa-dsl/datasets/v.rb +23 -0
- data/lib/musa-dsl/generative.rb +5 -5
- data/lib/musa-dsl/generative/backboner.rb +274 -0
- data/lib/musa-dsl/generative/darwin.rb +102 -96
- data/lib/musa-dsl/generative/generative-grammar.rb +182 -187
- data/lib/musa-dsl/generative/markov.rb +56 -53
- data/lib/musa-dsl/generative/variatio.rb +234 -222
- data/lib/musa-dsl/logger.rb +1 -0
- data/lib/musa-dsl/logger/logger.rb +31 -0
- data/lib/musa-dsl/matrix.rb +1 -0
- data/lib/musa-dsl/matrix/matrix.rb +210 -0
- data/lib/musa-dsl/midi.rb +2 -2
- data/lib/musa-dsl/midi/midi-recorder.rb +54 -52
- data/lib/musa-dsl/midi/midi-voices.rb +183 -182
- data/lib/musa-dsl/music.rb +5 -5
- data/lib/musa-dsl/music/chord-definition.rb +54 -50
- data/lib/musa-dsl/music/chord-definitions.rb +13 -9
- data/lib/musa-dsl/music/chords.rb +236 -238
- data/lib/musa-dsl/music/equally-tempered-12-tone-scale-system.rb +187 -183
- data/lib/musa-dsl/music/scales.rb +331 -332
- data/lib/musa-dsl/musicxml.rb +1 -0
- data/lib/musa-dsl/musicxml/builder/attributes.rb +155 -0
- data/lib/musa-dsl/musicxml/builder/backup-forward.rb +45 -0
- data/lib/musa-dsl/musicxml/builder/direction.rb +322 -0
- data/lib/musa-dsl/musicxml/builder/helper.rb +90 -0
- data/lib/musa-dsl/musicxml/builder/measure.rb +137 -0
- data/lib/musa-dsl/musicxml/builder/note-complexities.rb +152 -0
- data/lib/musa-dsl/musicxml/builder/note.rb +577 -0
- data/lib/musa-dsl/musicxml/builder/part-group.rb +44 -0
- data/lib/musa-dsl/musicxml/builder/part.rb +67 -0
- data/lib/musa-dsl/musicxml/builder/pitched-note.rb +126 -0
- data/lib/musa-dsl/musicxml/builder/rest.rb +117 -0
- data/lib/musa-dsl/musicxml/builder/score-partwise.rb +120 -0
- data/lib/musa-dsl/musicxml/builder/typed-text.rb +43 -0
- data/lib/musa-dsl/musicxml/builder/unpitched-note.rb +112 -0
- data/lib/musa-dsl/neumalang.rb +1 -1
- data/lib/musa-dsl/neumalang/datatypes.citrus +79 -0
- data/lib/musa-dsl/neumalang/neuma.citrus +165 -0
- data/lib/musa-dsl/neumalang/neumalang.citrus +32 -242
- data/lib/musa-dsl/neumalang/neumalang.rb +373 -142
- data/lib/musa-dsl/neumalang/process.citrus +21 -0
- data/lib/musa-dsl/neumalang/terminals.citrus +67 -0
- data/lib/musa-dsl/neumalang/vectors.citrus +23 -0
- data/lib/musa-dsl/neumas.rb +5 -0
- data/lib/musa-dsl/neumas/array-to-neumas.rb +34 -0
- data/lib/musa-dsl/neumas/neuma-decoder.rb +63 -0
- data/lib/musa-dsl/neumas/neuma-gdv-decoder.rb +57 -0
- data/lib/musa-dsl/neumas/neuma-gdvd-decoder.rb +15 -0
- data/lib/musa-dsl/neumas/neumas.rb +37 -0
- data/lib/musa-dsl/neumas/string-to-neumas.rb +34 -0
- data/lib/musa-dsl/repl.rb +1 -1
- data/lib/musa-dsl/repl/repl.rb +105 -105
- data/lib/musa-dsl/sequencer.rb +1 -1
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-control.rb +163 -136
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-helper.rb +301 -286
- data/lib/musa-dsl/sequencer/base-sequencer-implementation.rb +562 -270
- data/lib/musa-dsl/sequencer/base-sequencer-public.rb +199 -199
- data/lib/musa-dsl/sequencer/base-sequencer-tick-based.rb +77 -0
- data/lib/musa-dsl/sequencer/base-sequencer-tickless-based.rb +75 -0
- data/lib/musa-dsl/sequencer/sequencer-dsl.rb +105 -85
- data/lib/musa-dsl/sequencer/timeslots.rb +34 -0
- data/lib/musa-dsl/series.rb +1 -1
- data/lib/musa-dsl/{core-ext → series}/array-to-serie.rb +1 -1
- data/lib/musa-dsl/series/base-series.rb +171 -168
- data/lib/musa-dsl/series/hash-serie-splitter.rb +134 -132
- data/lib/musa-dsl/series/holder-serie.rb +1 -1
- data/lib/musa-dsl/series/main-serie-constructors.rb +6 -1
- data/lib/musa-dsl/series/main-serie-operations.rb +807 -797
- data/lib/musa-dsl/series/proxy-serie.rb +6 -6
- data/lib/musa-dsl/series/queue-serie.rb +5 -5
- data/lib/musa-dsl/series/series.rb +2 -0
- data/lib/musa-dsl/transcription.rb +4 -0
- data/lib/musa-dsl/transcription/from-gdv-to-midi.rb +227 -0
- data/lib/musa-dsl/transcription/from-gdv-to-musicxml.rb +36 -0
- data/lib/musa-dsl/transcription/from-gdv.rb +17 -0
- data/lib/musa-dsl/transcription/transcription.rb +55 -0
- data/lib/musa-dsl/transport.rb +6 -6
- data/lib/musa-dsl/transport/clock.rb +26 -26
- data/lib/musa-dsl/transport/dummy-clock.rb +32 -30
- data/lib/musa-dsl/transport/external-tick-clock.rb +21 -20
- data/lib/musa-dsl/transport/input-midi-clock.rb +82 -80
- data/lib/musa-dsl/transport/timer-clock.rb +72 -71
- data/lib/musa-dsl/transport/timer.rb +28 -26
- data/lib/musa-dsl/transport/transport.rb +99 -95
- data/musa-dsl.gemspec +3 -3
- metadata +73 -24
- data/lib/musa-dsl/core-ext/array-apply-get.rb +0 -18
- data/lib/musa-dsl/core-ext/array-to-neumas.rb +0 -28
- data/lib/musa-dsl/core-ext/as-context-run.rb +0 -44
- data/lib/musa-dsl/core-ext/duplicate.rb +0 -134
- data/lib/musa-dsl/core-ext/key-parameters-procedure-binder.rb +0 -85
- data/lib/musa-dsl/core-ext/proc-nice.rb +0 -13
- data/lib/musa-dsl/core-ext/send-nice.rb +0 -21
- data/lib/musa-dsl/core-ext/string-to-neumas.rb +0 -27
- data/lib/musa-dsl/datasets/gdv-decorators.rb +0 -221
- data/lib/musa-dsl/generative/rules.rb +0 -282
- data/lib/musa-dsl/neuma.rb +0 -1
- data/lib/musa-dsl/neuma/neuma.rb +0 -181
@@ -48,7 +48,7 @@ module Musa
|
|
48
48
|
|
49
49
|
def method_missing(method_name, *args, **key_args, &block)
|
50
50
|
if @target && @target.respond_to?(method_name)
|
51
|
-
@target.
|
51
|
+
@target.send method_name, *args, **key_args, &block
|
52
52
|
else
|
53
53
|
super
|
54
54
|
end
|
@@ -58,12 +58,12 @@ module Musa
|
|
58
58
|
@target && @target.respond_to?(method_name, include_private) # || super
|
59
59
|
end
|
60
60
|
end
|
61
|
-
end
|
62
61
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
module SerieOperations
|
63
|
+
# TODO add test case
|
64
|
+
def proxied
|
65
|
+
Series::ProxySerie.new self
|
66
|
+
end
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -74,7 +74,7 @@ module Musa
|
|
74
74
|
|
75
75
|
def method_missing(method_name, *args, **key_args, &block)
|
76
76
|
if @target && @target.respond_to?(method_name)
|
77
|
-
@target.
|
77
|
+
@target.send method_name, *args, **key_args, &block
|
78
78
|
else
|
79
79
|
super
|
80
80
|
end
|
@@ -84,11 +84,11 @@ module Musa
|
|
84
84
|
@target && @target.respond_to?(method_name, include_private) # || super
|
85
85
|
end
|
86
86
|
end
|
87
|
-
end
|
88
87
|
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
module SerieOperations
|
89
|
+
def queued
|
90
|
+
Series::QueueSerie.new [self]
|
91
|
+
end
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
require_relative 'from-gdv'
|
2
|
+
|
3
|
+
include Musa::Transcription
|
4
|
+
|
5
|
+
module Musa::Transcriptors
|
6
|
+
module FromGDV
|
7
|
+
module ToMIDI
|
8
|
+
def self.transcription_set(duration_factor: nil)
|
9
|
+
[ Appogiatura.new,
|
10
|
+
Mordent.new(duration_factor: duration_factor),
|
11
|
+
Turn.new,
|
12
|
+
Trill.new(duration_factor: duration_factor),
|
13
|
+
Staccato.new,
|
14
|
+
Base.new ]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Process: appogiatura (neuma)neuma
|
18
|
+
class Appogiatura < FeatureTranscriptor
|
19
|
+
def transcript(gdv, base_duration:, tick_duration:)
|
20
|
+
gdv_appogiatura = gdv.delete :appogiatura
|
21
|
+
|
22
|
+
if gdv_appogiatura
|
23
|
+
# TODO process with Decorators the gdv_appogiatura
|
24
|
+
# TODO implement also posterior appogiatura neuma(neuma)
|
25
|
+
# TODO implement also multiple appogiatura with several notes (neuma ... neuma)neuma or neuma(neuma ... neuma)
|
26
|
+
|
27
|
+
gdv[:duration] = gdv[:duration] - gdv_appogiatura[:duration]
|
28
|
+
|
29
|
+
super [ gdv_appogiatura, gdv ], base_duration: base_duration, tick_duration: tick_duration
|
30
|
+
else
|
31
|
+
super
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Process: .mor
|
37
|
+
class Mordent < FeatureTranscriptor
|
38
|
+
def initialize(duration_factor: nil)
|
39
|
+
@duration_factor = duration_factor || 1/4r
|
40
|
+
end
|
41
|
+
|
42
|
+
def transcript(gdv, base_duration:, tick_duration:)
|
43
|
+
mor = gdv.delete :mor
|
44
|
+
|
45
|
+
if mor
|
46
|
+
direction = :up
|
47
|
+
|
48
|
+
check(mor) do |mor|
|
49
|
+
case mor
|
50
|
+
when true, :up
|
51
|
+
direction = :up
|
52
|
+
when :down, :low
|
53
|
+
direction = :down
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
short_duration = [base_duration * @duration_factor, tick_duration].max
|
58
|
+
|
59
|
+
gdvs = []
|
60
|
+
|
61
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:duration] = short_duration }
|
62
|
+
|
63
|
+
case direction
|
64
|
+
when :up
|
65
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += 1; gdv[:duration] = short_duration }
|
66
|
+
when :down
|
67
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] -= 1; gdv[:duration] = short_duration }
|
68
|
+
end
|
69
|
+
|
70
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:duration] -= 2 * short_duration }
|
71
|
+
|
72
|
+
super gdvs, base_duration: base_duration, tick_duration: tick_duration
|
73
|
+
else
|
74
|
+
super
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Process: .turn
|
80
|
+
class Turn < FeatureTranscriptor
|
81
|
+
def transcript(gdv, base_duration:, tick_duration:)
|
82
|
+
turn = gdv.delete :turn
|
83
|
+
|
84
|
+
if turn
|
85
|
+
start = :up
|
86
|
+
|
87
|
+
check(turn) do |turn|
|
88
|
+
case turn
|
89
|
+
when :true, :up
|
90
|
+
start = :up
|
91
|
+
when :down, :low
|
92
|
+
start = :down
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
duration = gdv[:duration] / 4r
|
97
|
+
|
98
|
+
gdvs = []
|
99
|
+
|
100
|
+
case start
|
101
|
+
when :up
|
102
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += 1; gdv[:duration] = duration }
|
103
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += 0; gdv[:duration] = duration }
|
104
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += -1; gdv[:duration] = duration }
|
105
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += 0; gdv[:duration] = duration }
|
106
|
+
when :down
|
107
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += -1; gdv[:duration] = duration }
|
108
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += 0; gdv[:duration] = duration }
|
109
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += 1; gdv[:duration] = duration }
|
110
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += 0; gdv[:duration] = duration }
|
111
|
+
end
|
112
|
+
|
113
|
+
super gdvs, base_duration: base_duration, tick_duration: tick_duration
|
114
|
+
else
|
115
|
+
super
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# Process: .tr
|
121
|
+
class Trill < FeatureTranscriptor
|
122
|
+
def initialize(duration_factor: nil)
|
123
|
+
@duration_factor = duration_factor || 1/4r
|
124
|
+
end
|
125
|
+
|
126
|
+
def transcript(gdv, base_duration:, tick_duration:)
|
127
|
+
tr = gdv.delete :tr
|
128
|
+
|
129
|
+
if tr
|
130
|
+
note_duration = base_duration * @duration_factor
|
131
|
+
|
132
|
+
check(tr) do |tr|
|
133
|
+
case tr
|
134
|
+
when Numeric # duration factor
|
135
|
+
note_duration *= base_duration * tr.to_r
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
used_duration = 0r
|
140
|
+
last = nil
|
141
|
+
|
142
|
+
gdvs = []
|
143
|
+
|
144
|
+
check(tr) do |tr|
|
145
|
+
case tr
|
146
|
+
when :low # start with lower note
|
147
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += (last = -1); gdv[:duration] = note_duration }
|
148
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += (last = 0); gdv[:duration] = note_duration }
|
149
|
+
used_duration += 2 * note_duration
|
150
|
+
|
151
|
+
when :low2 # start with upper note but go to lower note once
|
152
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += (last = 1); gdv[:duration] = note_duration }
|
153
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += (last = 0); gdv[:duration] = note_duration }
|
154
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += (last = -1); gdv[:duration] = note_duration }
|
155
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += (last = 0); gdv[:duration] = note_duration }
|
156
|
+
used_duration += 4 * note_duration
|
157
|
+
|
158
|
+
when :same # start with the same note
|
159
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += (last = 0); gdv[:duration] = note_duration }
|
160
|
+
used_duration += note_duration
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
2.times do
|
165
|
+
if used_duration + 2 * note_duration <= gdv[:duration]
|
166
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += (last = 1); gdv[:duration] = note_duration }
|
167
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += (last = 0); gdv[:duration] = note_duration }
|
168
|
+
|
169
|
+
used_duration += 2 * note_duration
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
while used_duration + 2 * note_duration * 2/3r <= gdv[:duration]
|
174
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += (last = 1); gdv[:duration] = note_duration * 2/3r }
|
175
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += (last = 0); gdv[:duration] = note_duration * 2/3r }
|
176
|
+
|
177
|
+
used_duration += 2 * note_duration * 2/3r
|
178
|
+
end
|
179
|
+
|
180
|
+
duration_diff = gdv[:duration] - used_duration
|
181
|
+
if duration_diff >= note_duration
|
182
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += (last = 1); gdv[:duration] = duration_diff / 2 }
|
183
|
+
gdvs << gdv.clone.tap { |gdv| gdv[:grade] += (last = 0); gdv[:duration] = duration_diff / 2 }
|
184
|
+
|
185
|
+
elsif duration_diff > 0
|
186
|
+
gdvs[-1][:duration] += duration_diff / 2
|
187
|
+
gdvs[-2][:duration] += duration_diff / 2
|
188
|
+
end
|
189
|
+
|
190
|
+
super gdvs, base_duration: base_duration, tick_duration: tick_duration
|
191
|
+
else
|
192
|
+
super
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
# Process: .st .st(1) .st(2) .st(3): staccato level 1 2 3
|
198
|
+
class Staccato < FeatureTranscriptor
|
199
|
+
def initialize(min_duration_factor: nil)
|
200
|
+
@min_duration_factor = min_duration_factor || 1/8r
|
201
|
+
end
|
202
|
+
|
203
|
+
def transcript(gdv, base_duration:, tick_duration:)
|
204
|
+
st = gdv.delete :st
|
205
|
+
|
206
|
+
if st
|
207
|
+
calculated = 0
|
208
|
+
|
209
|
+
check(st) do |st|
|
210
|
+
case st
|
211
|
+
when true
|
212
|
+
calculated = gdv[:duration] / 2r
|
213
|
+
when Numeric
|
214
|
+
calculated = gdv[:duration] / 2**st if st >= 1
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
gdv[:note_duration] = [calculated, base_duration * @min_duration_factor].max
|
219
|
+
end
|
220
|
+
|
221
|
+
super
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative 'from-gdv'
|
2
|
+
|
3
|
+
include Musa::Transcription
|
4
|
+
|
5
|
+
module Musa::Transcriptors
|
6
|
+
module FromGDV
|
7
|
+
module ToMusicXML
|
8
|
+
def self.transcription_set
|
9
|
+
[ Appogiatura.new,
|
10
|
+
Base.new ]
|
11
|
+
end
|
12
|
+
|
13
|
+
# Process: appogiatura (neuma)neuma
|
14
|
+
class Appogiatura < FeatureTranscriptor
|
15
|
+
def transcript(gdv, base_duration:, tick_duration:)
|
16
|
+
if gdv_appogiatura = gdv[:appogiatura]
|
17
|
+
gdv.delete :appogiatura
|
18
|
+
|
19
|
+
# TODO process with Decorators the gdv_appogiatura
|
20
|
+
# TODO implement also posterior appogiatura neuma(neuma)
|
21
|
+
# TODO implement also multiple appogiatura with several notes (neuma ... neuma)neuma or neuma(neuma ... neuma)
|
22
|
+
|
23
|
+
gdv_appogiatura[:grace] = true
|
24
|
+
gdv[:graced] = true
|
25
|
+
gdv[:graced_by] = gdv_appogiatura
|
26
|
+
|
27
|
+
[ gdv_appogiatura, gdv ]
|
28
|
+
else
|
29
|
+
gdv
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'transcription'
|
2
|
+
|
3
|
+
include Musa::Transcription
|
4
|
+
|
5
|
+
module Musa::Transcriptors
|
6
|
+
module FromGDV
|
7
|
+
# Process: .base .b
|
8
|
+
class Base < FeatureTranscriptor
|
9
|
+
def transcript(gdv, base_duration:, tick_duration:)
|
10
|
+
base = gdv.delete :base
|
11
|
+
base ||= gdv.delete :b
|
12
|
+
|
13
|
+
super base ? { duration: 0 }.extend(Musa::Datasets::AbsD) : gdv, base_duration: base_duration, tick_duration: tick_duration
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Musa
|
2
|
+
module Transcription
|
3
|
+
class Transcriptor
|
4
|
+
attr_reader :transcriptors
|
5
|
+
|
6
|
+
def initialize(transcriptors = nil, base_duration: nil, tick_duration: nil)
|
7
|
+
@transcriptors = transcriptors || []
|
8
|
+
|
9
|
+
@base_duration = base_duration || 1/4r
|
10
|
+
@tick_duration = tick_duration || 1/96r
|
11
|
+
end
|
12
|
+
|
13
|
+
def transcript(element)
|
14
|
+
@transcriptors.each do |transcriptor|
|
15
|
+
if element
|
16
|
+
if element.is_a?(Array)
|
17
|
+
element = element.collect { |element_i| transcriptor.transcript(element_i, base_duration: @base_duration, tick_duration: @tick_duration) }.flatten(1)
|
18
|
+
else
|
19
|
+
element = transcriptor.transcript(element, base_duration: @base_duration, tick_duration: @tick_duration)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
element
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class FeatureTranscriptor
|
31
|
+
def transcript(element, base_duration:, tick_duration:)
|
32
|
+
case element
|
33
|
+
when Hash
|
34
|
+
element.delete :modifiers if element[:modifiers]&.empty?
|
35
|
+
when Array
|
36
|
+
element.each { |_| _.delete :modifiers if _[:modifiers]&.empty? }
|
37
|
+
end
|
38
|
+
|
39
|
+
element
|
40
|
+
end
|
41
|
+
|
42
|
+
def check(value_or_array)
|
43
|
+
if block_given?
|
44
|
+
if value_or_array.is_a?(Array)
|
45
|
+
value_or_array.each { |value| yield value }
|
46
|
+
else
|
47
|
+
yield value_or_array
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
module Transcriptors; end
|
55
|
+
end
|
data/lib/musa-dsl/transport.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
|
1
|
+
require_relative 'transport/transport'
|
2
2
|
|
3
|
-
|
3
|
+
require_relative 'transport/timer'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
require_relative 'transport/input-midi-clock'
|
6
|
+
require_relative 'transport/timer-clock'
|
7
|
+
require_relative 'transport/dummy-clock'
|
8
|
+
require_relative 'transport/external-tick-clock'
|
9
9
|
|
@@ -1,36 +1,36 @@
|
|
1
|
-
require 'nibbler'
|
2
|
-
|
3
1
|
module Musa
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
module Clock
|
3
|
+
class Clock
|
4
|
+
def initialize
|
5
|
+
@run = nil
|
6
|
+
@on_start = []
|
7
|
+
@on_stop = []
|
8
|
+
@on_change_position = []
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
def running?
|
12
|
+
@run
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
def on_start(&block)
|
16
|
+
@on_start << block
|
17
|
+
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
def on_stop(&block)
|
20
|
+
@on_stop << block
|
21
|
+
end
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
def on_change_position(&block)
|
24
|
+
@on_change_position << block
|
25
|
+
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
def run
|
28
|
+
raise NotImplementedError
|
29
|
+
end
|
31
30
|
|
32
|
-
|
33
|
-
|
31
|
+
def terminate
|
32
|
+
raise NotImplementedError
|
33
|
+
end
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|