musa-dsl 0.22.6 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/lib/musa-dsl.rb +14 -8
- data/lib/musa-dsl/core-ext/deep-copy.rb +12 -1
- data/lib/musa-dsl/core-ext/smart-proc-binder.rb +13 -11
- data/lib/musa-dsl/datasets/p.rb +14 -10
- data/lib/musa-dsl/generative/backboner.rb +6 -11
- data/lib/musa-dsl/generative/generative-grammar.rb +1 -3
- data/lib/musa-dsl/generative/markov.rb +10 -6
- data/lib/musa-dsl/neumalang/neumalang.rb +1 -1
- data/lib/musa-dsl/neumas/array-to-neumas.rb +1 -1
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-helper.rb +2 -2
- data/lib/musa-dsl/sequencer/sequencer-dsl.rb +6 -6
- data/lib/musa-dsl/series/base-series.rb +293 -144
- data/lib/musa-dsl/series/buffer-serie.rb +237 -0
- data/lib/musa-dsl/series/hash-or-array-serie-splitter.rb +128 -129
- data/lib/musa-dsl/series/main-serie-constructors.rb +247 -154
- data/lib/musa-dsl/series/main-serie-operations.rb +281 -316
- data/lib/musa-dsl/series/proxy-serie.rb +21 -41
- data/lib/musa-dsl/series/quantizer-serie.rb +38 -38
- data/lib/musa-dsl/series/queue-serie.rb +39 -43
- data/lib/musa-dsl/series/series-composer.rb +149 -0
- data/lib/musa-dsl/series/series.rb +5 -1
- data/lib/musa-dsl/series/timed-serie.rb +106 -119
- data/musa-dsl.gemspec +12 -2
- metadata +7 -7
- data/lib/musa-dsl/series/holder-serie.rb +0 -87
@@ -5,11 +5,15 @@ require_relative 'main-serie-operations'
|
|
5
5
|
|
6
6
|
require_relative 'array-to-serie'
|
7
7
|
|
8
|
-
require_relative 'holder-serie'
|
9
8
|
require_relative 'proxy-serie'
|
10
9
|
require_relative 'queue-serie'
|
11
10
|
|
11
|
+
require_relative 'buffer-serie'
|
12
|
+
|
13
|
+
require_relative 'series-composer'
|
14
|
+
|
12
15
|
require_relative 'hash-or-array-serie-splitter'
|
13
16
|
|
14
17
|
require_relative 'quantizer-serie'
|
15
18
|
require_relative 'timed-serie'
|
19
|
+
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require_relative '../datasets/e'
|
2
2
|
|
3
|
-
|
4
|
-
module Series
|
5
|
-
extend self
|
3
|
+
require_relative 'base-series'
|
6
4
|
|
5
|
+
module Musa
|
6
|
+
module Series::Constructors
|
7
7
|
def TIMED_UNION(*array_of_timed_series, **hash_of_timed_series)
|
8
8
|
raise ArgumentError, 'Can\'t union an array of series with a hash of series' if array_of_timed_series.any? && hash_of_timed_series.any?
|
9
9
|
|
@@ -17,29 +17,22 @@ module Musa
|
|
17
17
|
end
|
18
18
|
|
19
19
|
class TimedUnionOfArrayOfTimedSeries
|
20
|
-
include Serie
|
21
|
-
|
22
|
-
attr_reader :sources
|
20
|
+
include Series::Serie.with(sources: true)
|
23
21
|
|
24
22
|
def initialize(series)
|
25
|
-
|
26
|
-
|
27
|
-
else
|
28
|
-
series.collect(&:instance)
|
29
|
-
end
|
30
|
-
|
31
|
-
_restart false
|
32
|
-
|
33
|
-
mark_regarding! series[0]
|
23
|
+
self.sources = series
|
24
|
+
init
|
34
25
|
end
|
35
26
|
|
36
|
-
private def
|
37
|
-
@sources.each(&:restart) if restart_sources
|
27
|
+
private def _init
|
38
28
|
@sources_next_values = Array.new(@sources.size)
|
39
|
-
|
40
29
|
@components = nil
|
41
30
|
end
|
42
31
|
|
32
|
+
private def _restart
|
33
|
+
@sources.each(&:restart)
|
34
|
+
end
|
35
|
+
|
43
36
|
private def _next_value
|
44
37
|
sources_values = @sources_next_values.each_index.collect do |i|
|
45
38
|
@sources_next_values[i] || (@sources_next_values[i] = @sources[i].next_value)
|
@@ -149,30 +142,27 @@ module Musa
|
|
149
142
|
private_constant :TimedUnionOfArrayOfTimedSeries
|
150
143
|
|
151
144
|
class TimedUnionOfHashOfTimedSeries
|
152
|
-
include Serie
|
153
|
-
|
154
|
-
attr_reader :sources
|
145
|
+
include Series::Serie.with(sources: true)
|
155
146
|
|
156
147
|
def initialize(series)
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
series.transform_values(&:prototype).freeze
|
161
|
-
else
|
162
|
-
series.transform_values(&:instance)
|
163
|
-
end
|
164
|
-
|
165
|
-
_restart false
|
148
|
+
self.sources = series
|
149
|
+
init
|
150
|
+
end
|
166
151
|
|
167
|
-
|
152
|
+
def sources=(series)
|
153
|
+
super
|
154
|
+
@components = series.keys
|
168
155
|
end
|
169
156
|
|
170
|
-
private def
|
171
|
-
@sources.each_value(&:restart) if restart_sources
|
157
|
+
private def _init
|
172
158
|
@sources_next_values = @components.collect { |k| [k, nil] }.to_h
|
173
159
|
@other_attributes = nil
|
174
160
|
end
|
175
161
|
|
162
|
+
private def _restart
|
163
|
+
@sources.each_value(&:restart)
|
164
|
+
end
|
165
|
+
|
176
166
|
private def _next_value
|
177
167
|
sources_values = {}
|
178
168
|
|
@@ -231,126 +221,123 @@ module Musa
|
|
231
221
|
end
|
232
222
|
|
233
223
|
private_constant :TimedUnionOfHashOfTimedSeries
|
224
|
+
end
|
234
225
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
226
|
+
module Series::Operations
|
227
|
+
def flatten_timed
|
228
|
+
TimedFlattener.new(self)
|
229
|
+
end
|
239
230
|
|
240
|
-
|
241
|
-
|
242
|
-
|
231
|
+
def compact_timed
|
232
|
+
TimedCompacter.new(self)
|
233
|
+
end
|
243
234
|
|
244
|
-
|
245
|
-
|
246
|
-
|
235
|
+
def union_timed(*other_timed_series, key: nil, **other_key_timed_series)
|
236
|
+
if key && other_key_timed_series.any?
|
237
|
+
Series::Constructors.TIMED_UNION(key => self, **other_key_timed_series)
|
247
238
|
|
248
|
-
|
249
|
-
|
239
|
+
elsif other_timed_series.any? && other_key_timed_series.empty?
|
240
|
+
Series::Constructors.TIMED_UNION(self, *other_timed_series)
|
250
241
|
|
251
|
-
|
252
|
-
|
253
|
-
end
|
242
|
+
else
|
243
|
+
raise ArgumentError, 'Can\'t union an array of series with a hash of series'
|
254
244
|
end
|
245
|
+
end
|
255
246
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
attr_reader :source
|
247
|
+
class TimedFlattener
|
248
|
+
include Series::Serie.with(source: true)
|
260
249
|
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
250
|
+
def initialize(serie)
|
251
|
+
self.source = serie
|
252
|
+
init
|
253
|
+
end
|
265
254
|
|
266
|
-
|
267
|
-
|
268
|
-
|
255
|
+
private def _restart
|
256
|
+
@source.restart
|
257
|
+
end
|
269
258
|
|
270
|
-
|
271
|
-
|
259
|
+
private def _next_value
|
260
|
+
source_value = @source.next_value
|
272
261
|
|
273
|
-
|
274
|
-
|
275
|
-
|
262
|
+
if !source_value.nil?
|
263
|
+
time = source_value[:time]
|
264
|
+
source_value_value = source_value[:value]
|
276
265
|
|
277
|
-
|
278
|
-
|
279
|
-
|
266
|
+
source_value_extra = (source_value.keys - [:time, :value]).collect do |attribute_name|
|
267
|
+
[attribute_name, source_value[attribute_name]]
|
268
|
+
end.to_h
|
280
269
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
270
|
+
case source_value_value
|
271
|
+
when Hash
|
272
|
+
result = {}
|
273
|
+
source_value_value.each_pair do |key, value|
|
274
|
+
result[key] = { time: time, value: value }.extend(Musa::Datasets::AbsTimed)
|
286
275
|
|
287
|
-
|
288
|
-
|
289
|
-
end
|
276
|
+
source_value_extra.each do |attribute_name, attribute_value|
|
277
|
+
result[key][attribute_name] = attribute_value[key]
|
290
278
|
end
|
279
|
+
end
|
291
280
|
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
281
|
+
when Array
|
282
|
+
result = []
|
283
|
+
source_value_value.each_index do |index|
|
284
|
+
result[index] = { time: time, value: source_value_value[index] }.extend(Musa::Datasets::AbsTimed)
|
296
285
|
|
297
|
-
|
298
|
-
|
299
|
-
end
|
286
|
+
source_value_extra.each do |attribute_name, attribute_value|
|
287
|
+
result[index][attribute_name] = attribute_value[index]
|
300
288
|
end
|
301
|
-
else
|
302
|
-
result = source_value.clone.extend(Musa::Datasets::AbsTimed)
|
303
289
|
end
|
304
|
-
|
305
|
-
result.extend(Musa::Datasets::AbsTimed)
|
306
290
|
else
|
307
|
-
|
291
|
+
result = source_value.clone.extend(Musa::Datasets::AbsTimed)
|
308
292
|
end
|
309
|
-
end
|
310
293
|
|
311
|
-
|
312
|
-
|
294
|
+
result.extend(Musa::Datasets::AbsTimed)
|
295
|
+
else
|
296
|
+
nil
|
313
297
|
end
|
314
298
|
end
|
315
299
|
|
316
|
-
|
300
|
+
def infinite?
|
301
|
+
@source.infinite?
|
302
|
+
end
|
317
303
|
end
|
318
304
|
|
319
|
-
|
320
|
-
|
305
|
+
private_constant :TimedFlattener
|
306
|
+
end
|
321
307
|
|
322
|
-
|
308
|
+
class TimedCompacter
|
309
|
+
include Series::Serie.with(source: true)
|
323
310
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
311
|
+
def initialize(serie)
|
312
|
+
self.source = serie
|
313
|
+
init
|
314
|
+
end
|
328
315
|
|
329
|
-
|
330
|
-
|
331
|
-
|
316
|
+
private def _restart
|
317
|
+
@source.restart
|
318
|
+
end
|
332
319
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
320
|
+
private def _next_value
|
321
|
+
while (source_value = @source.next_value) && skip_value?(source_value[:value]); end
|
322
|
+
source_value
|
323
|
+
end
|
337
324
|
|
338
|
-
|
339
|
-
|
340
|
-
|
325
|
+
def infinite?
|
326
|
+
@source.infinite?
|
327
|
+
end
|
341
328
|
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
end
|
329
|
+
private def skip_value?(timed_value)
|
330
|
+
case timed_value
|
331
|
+
when Hash
|
332
|
+
timed_value.all? { |_, v| v.nil? }
|
333
|
+
when Array
|
334
|
+
timed_value.all?(&:nil?)
|
335
|
+
else
|
336
|
+
timed_value.nil?
|
351
337
|
end
|
352
338
|
end
|
353
|
-
|
354
|
-
private_constant :TimedCompacter
|
355
339
|
end
|
340
|
+
|
341
|
+
private_constant :TimedCompacter
|
356
342
|
end
|
343
|
+
|
data/musa-dsl.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'musa-dsl'
|
3
|
-
s.version = '0.
|
4
|
-
s.date = '
|
3
|
+
s.version = '0.23.0'
|
4
|
+
s.date = '2021-06-29'
|
5
5
|
s.summary = 'A simple Ruby DSL for making complex music'
|
6
6
|
s.description = 'Musa-DSL: A Ruby framework and DSL for algorithmic sound and musical thinking and composition'
|
7
7
|
s.authors = ['Javier Sánchez Yeste']
|
@@ -10,6 +10,16 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = 'https://github.com/javier-sy/musa-dsl'
|
11
11
|
s.license = 'LGPL-3.0'
|
12
12
|
|
13
|
+
s.required_ruby_version = '~> 2.7'
|
14
|
+
|
15
|
+
# TODO
|
16
|
+
#s.metadata = {
|
17
|
+
# "source_code_uri" => "https://",
|
18
|
+
# "homepage_uri" => "",
|
19
|
+
# "documentation_uri" => "",
|
20
|
+
# "changelog_uri" => ""
|
21
|
+
#}
|
22
|
+
|
13
23
|
s.add_runtime_dependency 'citrus', '~> 3.0.0', '>= 3.0.0'
|
14
24
|
|
15
25
|
s.add_runtime_dependency 'midi-message', '~> 0.4', '>= 0.4.9'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: musa-dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Sánchez Yeste
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: citrus
|
@@ -78,7 +78,6 @@ extensions: []
|
|
78
78
|
extra_rdoc_files: []
|
79
79
|
files:
|
80
80
|
- ".gitignore"
|
81
|
-
- ".ruby-version"
|
82
81
|
- Gemfile
|
83
82
|
- LICENSE.md
|
84
83
|
- README.md
|
@@ -179,13 +178,14 @@ files:
|
|
179
178
|
- lib/musa-dsl/series.rb
|
180
179
|
- lib/musa-dsl/series/array-to-serie.rb
|
181
180
|
- lib/musa-dsl/series/base-series.rb
|
181
|
+
- lib/musa-dsl/series/buffer-serie.rb
|
182
182
|
- lib/musa-dsl/series/hash-or-array-serie-splitter.rb
|
183
|
-
- lib/musa-dsl/series/holder-serie.rb
|
184
183
|
- lib/musa-dsl/series/main-serie-constructors.rb
|
185
184
|
- lib/musa-dsl/series/main-serie-operations.rb
|
186
185
|
- lib/musa-dsl/series/proxy-serie.rb
|
187
186
|
- lib/musa-dsl/series/quantizer-serie.rb
|
188
187
|
- lib/musa-dsl/series/queue-serie.rb
|
188
|
+
- lib/musa-dsl/series/series-composer.rb
|
189
189
|
- lib/musa-dsl/series/series.rb
|
190
190
|
- lib/musa-dsl/series/timed-serie.rb
|
191
191
|
- lib/musa-dsl/transcription.rb
|
@@ -212,16 +212,16 @@ require_paths:
|
|
212
212
|
- lib
|
213
213
|
required_ruby_version: !ruby/object:Gem::Requirement
|
214
214
|
requirements:
|
215
|
-
- - "
|
215
|
+
- - "~>"
|
216
216
|
- !ruby/object:Gem::Version
|
217
|
-
version: '
|
217
|
+
version: '2.7'
|
218
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
220
|
- - ">="
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
223
|
requirements: []
|
224
|
-
rubygems_version: 3.1.
|
224
|
+
rubygems_version: 3.1.6
|
225
225
|
signing_key:
|
226
226
|
specification_version: 4
|
227
227
|
summary: A simple Ruby DSL for making complex music
|
@@ -1,87 +0,0 @@
|
|
1
|
-
module Musa
|
2
|
-
module Series
|
3
|
-
# TODO: adapt to series prototyping
|
4
|
-
|
5
|
-
def HOLDER(serie = nil)
|
6
|
-
Holder.new(serie)
|
7
|
-
end
|
8
|
-
|
9
|
-
class Holder
|
10
|
-
include Serie
|
11
|
-
|
12
|
-
attr_reader :hold, :next
|
13
|
-
|
14
|
-
def initialize(serie)
|
15
|
-
@hold = serie.instance if serie
|
16
|
-
@next = []
|
17
|
-
|
18
|
-
mark_as_instance!
|
19
|
-
end
|
20
|
-
|
21
|
-
def hold=(serie)
|
22
|
-
@hold = serie.instance
|
23
|
-
end
|
24
|
-
|
25
|
-
def <<(serie)
|
26
|
-
if @hold.nil?
|
27
|
-
@hold = serie.instance
|
28
|
-
else
|
29
|
-
@next << serie.instance
|
30
|
-
end
|
31
|
-
|
32
|
-
self
|
33
|
-
end
|
34
|
-
|
35
|
-
def _prototype!
|
36
|
-
raise PrototypingSerieError, 'Cannot get prototype of a proxy serie'
|
37
|
-
end
|
38
|
-
|
39
|
-
def restart
|
40
|
-
if @next.empty? && @hold
|
41
|
-
@hold.restart
|
42
|
-
else
|
43
|
-
@hold = @next.shift
|
44
|
-
end
|
45
|
-
|
46
|
-
self
|
47
|
-
end
|
48
|
-
|
49
|
-
def current_value
|
50
|
-
@hold.current_value if @hold
|
51
|
-
end
|
52
|
-
|
53
|
-
def next_value
|
54
|
-
@hold.next_value if @hold
|
55
|
-
end
|
56
|
-
|
57
|
-
def peek_next_value
|
58
|
-
@hold.peek_next_value if @hold
|
59
|
-
end
|
60
|
-
|
61
|
-
def infinite?
|
62
|
-
@hold.infinite? if @hold
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def method_missing(method_name, *args, **key_args, &block)
|
68
|
-
if @hold && @hold.respond_to?(method_name)
|
69
|
-
@hold.send method_name, *args, **key_args, &block
|
70
|
-
else
|
71
|
-
super
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def respond_to_missing?(method_name, include_private)
|
76
|
-
@hold && @hold.respond_to?(method_name, include_private) || super
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
module SerieOperations
|
82
|
-
# TODO add test case
|
83
|
-
def hold
|
84
|
-
Series::Holder.new self
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|