musa-dsl 0.23.8 → 0.23.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/musa-dsl/core-ext/with.rb +4 -3
- data/lib/musa-dsl/datasets/gdv.rb +2 -2
- data/lib/musa-dsl/datasets/gdvd.rb +2 -1
- data/lib/musa-dsl/datasets/helper.rb +1 -1
- data/lib/musa-dsl/datasets/score/queriable.rb +43 -42
- data/lib/musa-dsl/datasets/score/render.rb +24 -20
- data/lib/musa-dsl/datasets/score/to-mxml/to-mxml.rb +120 -122
- data/lib/musa-dsl/generative/backboner.rb +2 -2
- data/lib/musa-dsl/generative/generative-grammar.rb +2 -0
- data/lib/musa-dsl/generative/markov.rb +1 -2
- data/lib/musa-dsl/generative/variatio.rb +6 -10
- data/lib/musa-dsl/logger/logger.rb +22 -22
- data/lib/musa-dsl/matrix/matrix.rb +3 -5
- data/lib/musa-dsl/midi/midi-recorder.rb +3 -4
- data/lib/musa-dsl/midi/midi-voices.rb +3 -3
- data/lib/musa-dsl/music/chords.rb +26 -29
- data/lib/musa-dsl/musicxml/builder/direction.rb +2 -2
- data/lib/musa-dsl/neumalang/neumalang.rb +25 -67
- data/lib/musa-dsl/neumas/array-to-neumas.rb +2 -2
- data/lib/musa-dsl/repl/repl.rb +1 -1
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-every.rb +12 -11
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb +53 -52
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-helper.rb +2 -4
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb +43 -39
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-play.rb +5 -7
- data/lib/musa-dsl/sequencer/base-sequencer-implementation.rb +6 -14
- data/lib/musa-dsl/sequencer/base-sequencer-tick-based.rb +4 -3
- data/lib/musa-dsl/sequencer/base-sequencer.rb +5 -5
- data/lib/musa-dsl/sequencer/sequencer-dsl.rb +11 -6
- data/lib/musa-dsl/series/array-to-serie.rb +5 -3
- data/lib/musa-dsl/series/base-series.rb +2 -2
- data/lib/musa-dsl/series/buffer-serie.rb +0 -5
- data/lib/musa-dsl/series/main-serie-constructors.rb +16 -6
- data/lib/musa-dsl/series/main-serie-operations.rb +2 -2
- data/lib/musa-dsl/series/quantizer-serie.rb +47 -51
- data/lib/musa-dsl/series/series-composer.rb +16 -6
- data/lib/musa-dsl/series/timed-serie.rb +49 -48
- data/lib/musa-dsl/transcription/from-gdv-to-midi.rb +5 -7
- data/lib/musa-dsl/transcription/from-gdv-to-musicxml.rb +1 -4
- data/lib/musa-dsl/transcription/from-gdv.rb +1 -3
- data/lib/musa-dsl/transcription/transcription.rb +2 -4
- data/lib/musa-dsl/transport/input-midi-clock.rb +7 -4
- data/lib/musa-dsl/transport/transport.rb +10 -12
- data/lib/musa-dsl.rb +1 -1
- data/musa-dsl.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83e058435542d40d1947cb484686b8b78b67c39e0a00f88d60d3b1c534620401
|
4
|
+
data.tar.gz: eef1c767f85c7ad1c174986eee492f7588d6c6c32e57b3fa13f8dcb7e8a8db23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce2bbb09377ad73191994790009429f469a7c46edaa47bdf5dd7cbc04b4541cfeef36006bc9b68c0f5baf2598e9c52acf339dd3b166702cef102e96209cb5013
|
7
|
+
data.tar.gz: 0c787f3da1d3beddbf09dcf20493c0cb0ed97868a49ea26432307093df222ec69ef9128cf2ce9d58a0211ccd2ec3a4ea59446fb14026b00f90dd41691c4cbf3a
|
@@ -6,12 +6,13 @@ module Musa
|
|
6
6
|
def with(*value_parameters, **key_parameters, &block)
|
7
7
|
binder = Musa::Extension::SmartProcBinder::SmartProcBinder.new(block)
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
keep_proc_context = @keep_proc_context_on_with
|
10
|
+
keep_proc_context ||= binder.parameters[0][1] == :_ unless binder.parameters.empty?
|
11
|
+
keep_proc_context ||= false
|
11
12
|
|
12
13
|
effective_value_parameters, effective_key_parameters = binder._apply(value_parameters, key_parameters)
|
13
14
|
|
14
|
-
if
|
15
|
+
if keep_proc_context
|
15
16
|
binder.call(self, *effective_value_parameters, **effective_key_parameters)
|
16
17
|
else
|
17
18
|
if effective_value_parameters.empty? && effective_key_parameters.empty?
|
@@ -3,7 +3,6 @@ require_relative 'gdv'
|
|
3
3
|
|
4
4
|
require_relative 'helper'
|
5
5
|
|
6
|
-
using Musa::Extension::InspectNice
|
7
6
|
|
8
7
|
module Musa::Datasets
|
9
8
|
module GDVd
|
@@ -12,6 +11,8 @@ module Musa::Datasets
|
|
12
11
|
|
13
12
|
include Helper
|
14
13
|
|
14
|
+
using Musa::Extension::InspectNice
|
15
|
+
|
15
16
|
NaturalKeys = (NaturalKeys +
|
16
17
|
[:abs_grade, :abs_sharps, :abs_octave,
|
17
18
|
:delta_grade, :delta_sharps, :delta_interval_sign, :delta_interval, :delta_octave,
|
@@ -1,48 +1,49 @@
|
|
1
|
-
module Musa::Datasets
|
2
|
-
|
3
|
-
module
|
4
|
-
|
5
|
-
|
1
|
+
module Musa::Datasets
|
2
|
+
class Score
|
3
|
+
module Queriable
|
4
|
+
module QueryableByTimeSlot
|
5
|
+
def group_by_attribute(attribute)
|
6
|
+
group_by { |e| e[attribute] }.transform_values! { |e| e.extend(QueryableByTimeSlot) }
|
7
|
+
end
|
8
|
+
|
9
|
+
def select_by_attribute(attribute, value = nil)
|
10
|
+
if value.nil?
|
11
|
+
select { |e| !e[attribute].nil? }
|
12
|
+
else
|
13
|
+
select { |e| e[attribute] == value }
|
14
|
+
end.extend(QueryableByTimeSlot)
|
15
|
+
end
|
16
|
+
|
17
|
+
def sort_by_attribute(attribute)
|
18
|
+
select_by_attribute(attribute).sort_by { |e| e[attribute] }.extend(QueryableByTimeSlot)
|
19
|
+
end
|
6
20
|
end
|
7
21
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
22
|
+
private_constant :QueryableByTimeSlot
|
23
|
+
|
24
|
+
module QueryableByDataset
|
25
|
+
def group_by_attribute(attribute)
|
26
|
+
group_by { |e| e[:dataset][attribute] }.transform_values! { |e| e.extend(QueryableByDataset) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def select_by_attribute(attribute, value = nil)
|
30
|
+
if value.nil?
|
31
|
+
select { |e| !e[:dataset][attribute].nil? }
|
32
|
+
else
|
33
|
+
select { |e| e[:dataset][attribute] == value }
|
34
|
+
end.extend(QueryableByDataset)
|
35
|
+
end
|
36
|
+
|
37
|
+
def subset
|
38
|
+
raise ArgumentError, "subset needs a block with the inclusion condition on the dataset" unless block_given?
|
39
|
+
select { |e| yield e[:dataset] }.extend(QueryableByDataset)
|
40
|
+
end
|
41
|
+
|
42
|
+
def sort_by_attribute(attribute)
|
43
|
+
select_by_attribute(attribute).sort_by { |e| e[:dataset][attribute] }.extend(QueryableByDataset)
|
44
|
+
end
|
14
45
|
end
|
15
46
|
|
16
|
-
|
17
|
-
select_by_attribute(attribute).sort_by { |e| e[attribute] }.extend(QueryableByTimeSlot)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private_constant :QueryableByTimeSlot
|
22
|
-
|
23
|
-
module QueryableByDataset
|
24
|
-
def group_by_attribute(attribute)
|
25
|
-
group_by { |e| e[:dataset][attribute] }.transform_values! { |e| e.extend(QueryableByDataset) }
|
26
|
-
end
|
27
|
-
|
28
|
-
def select_by_attribute(attribute, value = nil)
|
29
|
-
if value.nil?
|
30
|
-
select { |e| !e[:dataset][attribute].nil? }
|
31
|
-
else
|
32
|
-
select { |e| e[:dataset][attribute] == value }
|
33
|
-
end.extend(QueryableByDataset)
|
34
|
-
end
|
35
|
-
|
36
|
-
def subset
|
37
|
-
raise ArgumentError, "subset needs a block with the inclusion condition on the dataset" unless block_given?
|
38
|
-
select { |e| yield e[:dataset] }.extend(QueryableByDataset)
|
39
|
-
end
|
40
|
-
|
41
|
-
def sort_by_attribute(attribute)
|
42
|
-
select_by_attribute(attribute).sort_by { |e| e[:dataset][attribute] }.extend(QueryableByDataset)
|
43
|
-
end
|
47
|
+
private_constant :QueryableByDataset
|
44
48
|
end
|
45
|
-
|
46
|
-
private_constant :QueryableByDataset
|
47
|
-
end
|
48
49
|
end; end
|
@@ -1,31 +1,35 @@
|
|
1
1
|
require_relative '../../sequencer'
|
2
2
|
require_relative '../../series'
|
3
3
|
|
4
|
-
module Musa
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
module Musa
|
5
|
+
module Datasets
|
6
|
+
class Score
|
7
|
+
module Render
|
8
|
+
def render(on:, &block)
|
9
|
+
@score.keys.each do |score_at|
|
10
|
+
effective_wait = score_at - 1r
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
@score[score_at].each do |element|
|
13
|
+
case element
|
14
|
+
when Score
|
15
|
+
on.wait effective_wait do
|
16
|
+
element.render(on: on, &block)
|
17
|
+
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
when Abs
|
20
|
+
on.wait effective_wait do
|
21
|
+
block.call(element)
|
22
|
+
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
else
|
25
|
+
raise ArgumentError, "Can't sequence #{element} because it's not an Abs dataset"
|
26
|
+
end
|
27
|
+
end
|
24
28
|
end
|
29
|
+
|
30
|
+
nil
|
25
31
|
end
|
26
32
|
end
|
27
|
-
|
28
|
-
nil
|
29
33
|
end
|
30
34
|
end
|
31
|
-
end
|
35
|
+
end
|
@@ -6,167 +6,165 @@ require_relative 'process-time'
|
|
6
6
|
require_relative 'process-pdv'
|
7
7
|
require_relative 'process-ps'
|
8
8
|
|
9
|
-
module Musa::Datasets
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
logger.debug! if do_log
|
32
|
-
end
|
9
|
+
module Musa::Datasets
|
10
|
+
class Score
|
11
|
+
module ToMXML
|
12
|
+
using Musa::Extension::InspectNice
|
13
|
+
|
14
|
+
def to_mxml(beats_per_bar, ticks_per_beat,
|
15
|
+
bpm: nil,
|
16
|
+
title: nil,
|
17
|
+
creators: nil,
|
18
|
+
encoding_date: nil,
|
19
|
+
parts:,
|
20
|
+
logger: nil,
|
21
|
+
do_log: nil)
|
22
|
+
|
23
|
+
bpm ||= 90
|
24
|
+
title ||= 'Untitled'
|
25
|
+
creators ||= { composer: 'Unknown' }
|
26
|
+
|
27
|
+
if logger.nil?
|
28
|
+
logger = Musa::Logger::Logger.new
|
29
|
+
logger.debug! if do_log
|
30
|
+
end
|
33
31
|
|
34
|
-
|
32
|
+
do_log ||= nil
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
mxml = Musa::MusicXML::Builder::ScorePartwise.new do |_|
|
35
|
+
_.work_title title
|
36
|
+
_.creators **creators
|
37
|
+
_.encoding_date encoding_date if encoding_date
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
parts.each_pair do |id, part_info|
|
40
|
+
_.part id,
|
41
|
+
name: part_info&.[](:name),
|
42
|
+
abbreviation: part_info&.[](:abbreviation) do |_|
|
45
43
|
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
_.measure do |_|
|
45
|
+
_.attributes do |_|
|
46
|
+
_.divisions ticks_per_beat
|
49
47
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
48
|
+
i = 0
|
49
|
+
(part_info&.[](:clefs) || { g: 2 }).each_pair do |clef, line|
|
50
|
+
i += 1
|
51
|
+
_.clef i, sign: clef.upcase, line: line
|
52
|
+
_.time i, beats: beats_per_bar, beat_type: 4
|
53
|
+
end
|
55
54
|
end
|
56
|
-
end
|
57
55
|
|
58
|
-
|
56
|
+
_.metronome placement: 'above', beat_unit: 'quarter', per_minute: bpm
|
57
|
+
end
|
59
58
|
end
|
60
59
|
end
|
61
60
|
end
|
62
|
-
end
|
63
61
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
62
|
+
if do_log
|
63
|
+
logger.debug ""
|
64
|
+
logger.debug"score.to_mxml log:"
|
65
|
+
logger.debug"------------------"
|
66
|
+
end
|
69
67
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
68
|
+
parts.each_key do |part_id|
|
69
|
+
fill_part mxml.parts[part_id],
|
70
|
+
beats_per_bar * ticks_per_beat,
|
71
|
+
(parts.size > 1 ? part_id : nil),
|
72
|
+
logger, do_log
|
73
|
+
end
|
76
74
|
|
77
|
-
|
78
|
-
|
75
|
+
mxml
|
76
|
+
end
|
79
77
|
|
80
|
-
|
78
|
+
private
|
81
79
|
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
def fill_part(part, divisions_per_bar, instrument, logger, do_log)
|
81
|
+
measure = nil
|
82
|
+
dynamics_context = nil
|
85
83
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
84
|
+
(1..finish || 0).each do |bar|
|
85
|
+
if do_log
|
86
|
+
logger.debug ""
|
87
|
+
logger.debug msg = "filling part #{part.name} (#{instrument || 'nil'}): processing bar #{bar}"
|
88
|
+
logger.debug "-" * msg.size
|
89
|
+
end
|
92
90
|
|
93
|
-
|
94
|
-
|
91
|
+
measure = part.add_measure if measure
|
92
|
+
measure ||= part.measures.last
|
95
93
|
|
96
|
-
|
94
|
+
pointer = 0r
|
97
95
|
|
98
|
-
|
96
|
+
instrument_score = subset { |dataset| instrument.nil? || dataset[:instrument] == instrument }
|
99
97
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
98
|
+
bar_elements = \
|
99
|
+
(instrument_score.changes_between(bar, bar + 1).select { |p| p[:dataset].is_a?(Musa::Datasets::PS) } +
|
100
|
+
(pdvs = instrument_score.between(bar, bar + 1).select { |p| p[:dataset].is_a?(Musa::Datasets::PDV) }))
|
101
|
+
.sort_by { |e| [ e[:time_in_interval] || e[:start_in_interval],
|
102
|
+
e[:dataset].is_a?(Musa::Datasets::PS) ? 0 : 1 ] }
|
105
103
|
|
106
|
-
|
107
|
-
|
104
|
+
if pdvs.empty?
|
105
|
+
logger.debug "\nadding full bar silence..." if do_log
|
108
106
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
107
|
+
process_pdv(measure, bar, divisions_per_bar,
|
108
|
+
{ start: bar,
|
109
|
+
finish: bar + 1,
|
110
|
+
dataset: { pitch: :silence, duration: 1 }.extend(Musa::Datasets::PDV) },
|
111
|
+
pointer,
|
112
|
+
logger,
|
113
|
+
do_log)
|
114
|
+
else
|
115
|
+
first = bar_elements.first
|
118
116
|
|
119
|
-
|
117
|
+
logger.debug "\nfirst element #{first.inspect}" if do_log
|
120
118
|
|
121
|
-
|
122
|
-
|
119
|
+
# TODO habrá que arreglar el cálculo de pointer cuando haya avances y retrocesos para que
|
120
|
+
# TODO no añada silencios incorrectos al principio o al final
|
123
121
|
|
124
|
-
|
122
|
+
if (first[:time_in_interval] || first[:start_in_interval]) > bar
|
125
123
|
|
126
|
-
|
124
|
+
silence_duration = first[:start_in_interval] - bar
|
127
125
|
|
128
|
-
|
126
|
+
logger.debug "\nadding initial silence for duration #{silence_duration}..." if do_log
|
129
127
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
128
|
+
pointer = process_pdv(measure, bar, divisions_per_bar,
|
129
|
+
{ start: bar,
|
130
|
+
finish: first[:start_in_interval],
|
131
|
+
dataset: { pitch: :silence, duration: silence_duration }.extend(Musa::Datasets::PDV) },
|
132
|
+
pointer,
|
133
|
+
logger,
|
134
|
+
do_log)
|
135
|
+
end
|
138
136
|
|
139
|
-
|
137
|
+
logger.debug "\nadding PDV and PS elements..." if do_log
|
140
138
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
139
|
+
bar_elements.each do |element|
|
140
|
+
case element[:dataset]
|
141
|
+
when Musa::Datasets::PDV
|
142
|
+
pointer = process_pdv(measure, bar, divisions_per_bar, element, pointer, logger, do_log)
|
145
143
|
|
146
|
-
|
147
|
-
|
144
|
+
when Musa::Datasets::PS
|
145
|
+
dynamics_context = process_ps(measure, element, dynamics_context, logger, do_log)
|
148
146
|
|
149
|
-
|
150
|
-
|
147
|
+
else
|
148
|
+
# ignored
|
149
|
+
end
|
151
150
|
end
|
152
|
-
end
|
153
151
|
|
154
|
-
|
155
|
-
|
152
|
+
if pointer < 1r
|
153
|
+
silence_duration = 1r - pointer
|
156
154
|
|
157
|
-
|
155
|
+
logger.debug "\nadded ending silence for duration #{silence_duration}..." if do_log
|
158
156
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
157
|
+
process_pdv(measure, bar, divisions_per_bar,
|
158
|
+
{ start: bar + pointer,
|
159
|
+
finish: bar + 1 - Rational(1, divisions_per_bar),
|
160
|
+
dataset: { pitch: :silence, duration: silence_duration }.extend(Musa::Datasets::PDV) },
|
161
|
+
pointer,
|
162
|
+
logger,
|
163
|
+
do_log)
|
166
164
|
|
165
|
+
end
|
167
166
|
end
|
168
167
|
end
|
169
168
|
end
|
170
169
|
end
|
171
|
-
end
|
172
170
|
end; end
|