musa-dsl 0.23.11 → 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/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 +8 -8
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb +49 -49
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-helper.rb +2 -2
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb +2 -2
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-play.rb +2 -2
- data/lib/musa-dsl/sequencer/base-sequencer-implementation.rb +2 -2
- 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/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 +6 -4
- data/lib/musa-dsl/series/main-serie-operations.rb +2 -2
- data/lib/musa-dsl/series/quantizer-serie.rb +46 -50
- data/lib/musa-dsl/series/series-composer.rb +6 -5
- 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
@@ -1,13 +1,13 @@
|
|
1
1
|
require_relative '../core-ext/smart-proc-binder'
|
2
2
|
require_relative '../core-ext/with'
|
3
3
|
|
4
|
-
using Musa::Extension::Arrayfy
|
5
|
-
|
6
4
|
# TODO hacer que pueda funcionar en tiempo real? le vas suministrando seeds y le vas diciendo qué opción has elegido (p.ej. para hacer un armonizador en tiempo real)
|
7
5
|
# TODO esto mismo sería aplicable en otros generadores? variatio/darwin? generative-grammar? markov?
|
8
6
|
|
9
7
|
module Musa
|
10
8
|
module Backboner
|
9
|
+
using Musa::Extension::Arrayfy
|
10
|
+
|
11
11
|
class Backboner
|
12
12
|
include Musa::Extension::With
|
13
13
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Musa
|
2
2
|
module GenerativeGrammar
|
3
|
+
# TODO: refactor & reorganize regarding use of include Musa::GenerativeGrammar problems as default consumption mode (it forces the consumer to have new public methods -P, PN- and class names -OptionElement-)
|
4
|
+
|
3
5
|
extend self
|
4
6
|
|
5
7
|
def N(content = nil, **attributes, &block)
|
@@ -6,7 +6,6 @@ module Musa
|
|
6
6
|
|
7
7
|
module Markov
|
8
8
|
class Markov
|
9
|
-
include Musa::Extension::SmartProcBinder
|
10
9
|
include Musa::Series::Serie.base
|
11
10
|
|
12
11
|
def initialize(transitions:, start:, finish: nil, random: nil)
|
@@ -59,7 +58,7 @@ module Musa
|
|
59
58
|
r >= accumulated - probability && r < accumulated }[0]
|
60
59
|
|
61
60
|
when Proc
|
62
|
-
procedure_binder = @procedure_binders[options] ||= SmartProcBinder.new(options)
|
61
|
+
procedure_binder = @procedure_binders[options] ||= Musa::Extension::SmartProcBinder::SmartProcBinder.new(options)
|
63
62
|
@current = procedure_binder.call @history
|
64
63
|
else
|
65
64
|
raise ArgumentError, "Option #{option} is not allowed. Only Array, Hash or Proc are allowed."
|
@@ -2,16 +2,14 @@ require_relative '../core-ext/smart-proc-binder'
|
|
2
2
|
require_relative '../core-ext/arrayfy'
|
3
3
|
require_relative '../core-ext/with'
|
4
4
|
|
5
|
-
using Musa::Extension::Arrayfy
|
6
|
-
using Musa::Extension::ExplodeRanges
|
7
|
-
|
8
5
|
# TODO: permitir definir un variatio a través de llamadas a métodos y/o atributos, además de a través del block del constructor
|
9
6
|
|
10
7
|
module Musa
|
11
8
|
module Variatio
|
12
|
-
|
13
|
-
|
9
|
+
using Musa::Extension::Arrayfy
|
10
|
+
using Musa::Extension::ExplodeRanges
|
14
11
|
|
12
|
+
class Variatio
|
15
13
|
def initialize(instance_name, &block)
|
16
14
|
raise ArgumentError, 'instance_name should be a symbol' unless instance_name.is_a?(Symbol)
|
17
15
|
raise ArgumentError, 'block is needed' unless block
|
@@ -26,8 +24,8 @@ module Musa
|
|
26
24
|
end
|
27
25
|
|
28
26
|
def on(**values)
|
29
|
-
constructor_binder = SmartProcBinder.new @constructor
|
30
|
-
finalize_binder = SmartProcBinder.new @finalize if @finalize
|
27
|
+
constructor_binder = Musa::Extension::SmartProcBinder::SmartProcBinder.new @constructor
|
28
|
+
finalize_binder = Musa::Extension::SmartProcBinder::SmartProcBinder.new @finalize if @finalize
|
31
29
|
|
32
30
|
run_fieldset = @fieldset.clone # TODO: verificar que esto no da problemas
|
33
31
|
|
@@ -202,8 +200,6 @@ module Musa
|
|
202
200
|
private_constant :A2
|
203
201
|
|
204
202
|
class B
|
205
|
-
include Musa::Extension::SmartProcBinder
|
206
|
-
|
207
203
|
attr_reader :parameter_name, :options, :affected_field_names, :blocks, :inner
|
208
204
|
|
209
205
|
def initialize(parameter_name, options, affected_field_names, inner, blocks)
|
@@ -212,7 +208,7 @@ module Musa
|
|
212
208
|
@affected_field_names = affected_field_names
|
213
209
|
@inner = inner
|
214
210
|
|
215
|
-
@procedures = blocks.collect { |proc| SmartProcBinder.new proc }
|
211
|
+
@procedures = blocks.collect { |proc| Musa::Extension::SmartProcBinder::SmartProcBinder.new proc }
|
216
212
|
end
|
217
213
|
|
218
214
|
def run(parameters_with_depth, parent_parameters = nil)
|
@@ -1,37 +1,37 @@
|
|
1
1
|
require 'logger'
|
2
|
-
|
3
2
|
require_relative '../core-ext/inspect-nice'
|
4
3
|
|
4
|
+
module Musa
|
5
|
+
module Logger
|
6
|
+
class Logger < ::Logger
|
7
|
+
using Musa::Extension::InspectNice
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
using Musa::Extension::InspectNice
|
9
|
-
|
10
|
-
def initialize(sequencer: nil, position_format: nil)
|
11
|
-
super STDERR, level: WARN
|
9
|
+
def initialize(sequencer: nil, position_format: nil)
|
10
|
+
super STDERR, level: WARN
|
12
11
|
|
13
|
-
|
14
|
-
|
12
|
+
@sequencer = sequencer
|
13
|
+
@position_format = position_format || 3.3
|
15
14
|
|
16
15
|
|
17
|
-
|
18
|
-
|
16
|
+
self.formatter = proc do |severity, time, progname, msg|
|
17
|
+
level = "[#{severity}] " unless severity == 'DEBUG'
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
if msg
|
20
|
+
position = if @sequencer
|
21
|
+
integer_digits = @position_format.to_i
|
22
|
+
decimal_digits = ((@position_format - integer_digits) * 10).round
|
24
23
|
|
25
|
-
|
26
|
-
|
24
|
+
"%#{integer_digits + decimal_digits + 1}s: " % ("%.#{decimal_digits}f" % sequencer.position.to_f)
|
25
|
+
end
|
27
26
|
|
28
|
-
|
27
|
+
progname = "[#{progname}]" if progname
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
"#{position}#{level}#{progname}#{' ' if position || level || progname}#{msg}\n"
|
30
|
+
else
|
31
|
+
"\n"
|
32
|
+
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
end
|
37
|
+
end
|
@@ -67,8 +67,6 @@ module Musa
|
|
67
67
|
end
|
68
68
|
|
69
69
|
refine ::Matrix do
|
70
|
-
include Musa::Datasets
|
71
|
-
|
72
70
|
def to_p(time_dimension:, keep_time: nil)
|
73
71
|
decompose(self.to_a, time_dimension).collect do |points|
|
74
72
|
line = []
|
@@ -76,7 +74,7 @@ module Musa
|
|
76
74
|
start_point = points[0]
|
77
75
|
start_time = start_point[time_dimension]
|
78
76
|
|
79
|
-
line << start_point.clone.tap { |_| _.delete_at(time_dimension) unless keep_time; _ }.extend(Datasets::V)
|
77
|
+
line << start_point.clone.tap { |_| _.delete_at(time_dimension) unless keep_time; _ }.extend(Musa::Datasets::V)
|
80
78
|
|
81
79
|
(1..points.size-1).each do |i|
|
82
80
|
end_point = points[i]
|
@@ -84,12 +82,12 @@ module Musa
|
|
84
82
|
end_time = end_point[time_dimension]
|
85
83
|
|
86
84
|
line << end_time - start_time
|
87
|
-
line << end_point.clone.tap { |_| _.delete_at(time_dimension) unless keep_time; _ }.extend(Datasets::V)
|
85
|
+
line << end_point.clone.tap { |_| _.delete_at(time_dimension) unless keep_time; _ }.extend(Musa::Datasets::V)
|
88
86
|
|
89
87
|
start_time = end_time
|
90
88
|
end
|
91
89
|
|
92
|
-
line.extend(Datasets::P)
|
90
|
+
line.extend(Musa::Datasets::P)
|
93
91
|
end
|
94
92
|
end
|
95
93
|
|
@@ -36,8 +36,8 @@ module Musa
|
|
36
36
|
@messages.each do |m|
|
37
37
|
mm = m.message
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
case mm
|
40
|
+
when MIDIMessage::NoteOn
|
41
41
|
if last_note[mm.channel]
|
42
42
|
notes << { position: last_note[mm.channel], channel: mm.channel, pitch: :silence, duration: m.position - last_note[mm.channel] }
|
43
43
|
last_note.delete mm.channel
|
@@ -50,8 +50,7 @@ module Musa
|
|
50
50
|
|
51
51
|
notes << note
|
52
52
|
|
53
|
-
|
54
|
-
|
53
|
+
when MIDIMessage::NoteOff
|
55
54
|
note_on[mm.channel] ||= {}
|
56
55
|
|
57
56
|
note = note_on[mm.channel][mm.note]
|
@@ -4,11 +4,11 @@ require 'midi-message'
|
|
4
4
|
require_relative '../core-ext/arrayfy'
|
5
5
|
require_relative '../core-ext/array-explode-ranges'
|
6
6
|
|
7
|
-
using Musa::Extension::Arrayfy
|
8
|
-
using Musa::Extension::ExplodeRanges
|
9
|
-
|
10
7
|
module Musa
|
11
8
|
module MIDIVoices
|
9
|
+
using Musa::Extension::Arrayfy
|
10
|
+
using Musa::Extension::ExplodeRanges
|
11
|
+
|
12
12
|
class MIDIVoices
|
13
13
|
attr_accessor :do_log
|
14
14
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require_relative 'scales'
|
2
2
|
require_relative 'chord-definition'
|
3
3
|
|
4
|
-
using Musa::Extension::Arrayfy
|
5
|
-
|
6
4
|
module Musa
|
7
5
|
module Chords
|
6
|
+
using Musa::Extension::Arrayfy
|
7
|
+
|
8
8
|
class Chord
|
9
9
|
def initialize(name_or_notes_or_pitches = nil, # name | [notes] | [pitches]
|
10
10
|
# definitory
|
@@ -51,7 +51,7 @@ module Musa
|
|
51
51
|
|
52
52
|
allow_chromatic ||= scale.nil?
|
53
53
|
|
54
|
-
if root
|
54
|
+
if root&.is_a?(Scales::NoteInScale)
|
55
55
|
root_pitch = root.pitch
|
56
56
|
scale ||= root.scale
|
57
57
|
end
|
@@ -98,29 +98,27 @@ module Musa
|
|
98
98
|
# Eval definitory atributes
|
99
99
|
#
|
100
100
|
|
101
|
-
if _source.nil?
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
101
|
+
@notes = if _source.nil?
|
102
|
+
compute_notes(name, root_pitch, scale, notes, pitches, features, allow_chromatic)
|
103
|
+
else
|
104
|
+
compute_notes_from_source(_source, name, root_pitch, scale, notes, pitches, features, allow_chromatic)
|
105
|
+
end
|
106
106
|
|
107
107
|
# Eval adding / droping operations
|
108
108
|
#
|
109
109
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
raise ArgumentError, "Can't recognize element to add #{to_add}"
|
123
|
-
end
|
110
|
+
add&.each do |to_add|
|
111
|
+
case to_add
|
112
|
+
when NoteInScale
|
113
|
+
@notes << to_add
|
114
|
+
when Numeric # pitch increment
|
115
|
+
pitch = root_pitch + to_add
|
116
|
+
@notes << scale.note_of_pitch(pitch) || scale.chromatic.note_of_pitch(pitch)
|
117
|
+
when Symbol # interval name
|
118
|
+
pitch = root_pitch + scale.offset_of_interval(to_add)
|
119
|
+
@notes << scale.note_of_pitch(pitch)
|
120
|
+
else
|
121
|
+
raise ArgumentError, "Can't recognize element to add #{to_add}"
|
124
122
|
end
|
125
123
|
end
|
126
124
|
|
@@ -167,14 +165,14 @@ module Musa
|
|
167
165
|
|
168
166
|
def name(name = nil)
|
169
167
|
if name.nil?
|
170
|
-
@chord_definition
|
168
|
+
@chord_definition&.name
|
171
169
|
else
|
172
170
|
Chord.new(_source: self, name: name)
|
173
171
|
end
|
174
172
|
end
|
175
173
|
|
176
174
|
def features
|
177
|
-
@chord_definition
|
175
|
+
@chord_definition&.features
|
178
176
|
end
|
179
177
|
|
180
178
|
def featuring(*values, allow_chromatic: nil, **hash)
|
@@ -220,18 +218,17 @@ module Musa
|
|
220
218
|
def as_scale
|
221
219
|
end
|
222
220
|
|
223
|
-
|
224
221
|
def project_on_all(*scales, allow_chromatic: nil)
|
225
222
|
# TODO add match to other chords... what does it means?
|
226
223
|
allow_chromatic ||= false
|
227
224
|
|
228
225
|
note_sets = {}
|
229
226
|
scales.each do |scale|
|
230
|
-
if allow_chromatic
|
231
|
-
|
227
|
+
note_sets[scale] = if allow_chromatic
|
228
|
+
@notes.values.flatten(1).collect { |n| n.on(scale) || n.on(scale.chromatic) }
|
232
229
|
else
|
233
|
-
|
234
|
-
|
230
|
+
@notes.values.flatten(1).collect { |n| n.on(scale) }
|
231
|
+
end
|
235
232
|
end
|
236
233
|
|
237
234
|
note_sets_in_scale = note_sets.values.reject { |notes| notes.include?(nil) }
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require_relative '../../core-ext/with'
|
2
2
|
require_relative 'helper'
|
3
3
|
|
4
|
-
using Musa::Extension::Arrayfy
|
5
|
-
|
6
4
|
module Musa
|
7
5
|
module MusicXML
|
8
6
|
module Builder
|
9
7
|
module Internal
|
8
|
+
using Musa::Extension::Arrayfy
|
9
|
+
|
10
10
|
class Direction
|
11
11
|
extend Musa::Extension::AttributeBuilder
|
12
12
|
include Musa::Extension::With
|
@@ -11,64 +11,49 @@ module Musa
|
|
11
11
|
module Grammar; end
|
12
12
|
|
13
13
|
module Sentences
|
14
|
-
include Musa::Series
|
15
|
-
include Musa::Neumas
|
16
|
-
|
17
14
|
def value
|
18
|
-
S(*captures(:expression).collect(&:value)).extend(Neuma::Serie)
|
15
|
+
Musa::Series::Constructors.S(*captures(:expression).collect(&:value)).extend(Musa::Neumas::Neuma::Serie)
|
19
16
|
end
|
20
17
|
end
|
21
18
|
|
22
19
|
module BracketedBarSentences
|
23
|
-
include Musa::Series
|
24
|
-
include Musa::Neumas
|
25
|
-
|
26
20
|
def value
|
27
21
|
{ kind: :parallel,
|
28
22
|
parallel: [{ kind: :serie,
|
29
23
|
serie: S(*capture(:aa).value) }] +
|
30
|
-
captures(:bb).collect { |c| { kind: :serie, serie: S(*c.value) } }
|
31
|
-
}.extend(Neuma::Parallel)
|
24
|
+
captures(:bb).collect { |c| { kind: :serie, serie: Musa::Series::Constructors.S(*c.value) } }
|
25
|
+
}.extend(Musa::Neumas::Neuma::Parallel)
|
32
26
|
end
|
33
27
|
end
|
34
28
|
|
35
29
|
module BracketedSentences
|
36
|
-
include Musa::Series
|
37
|
-
include Musa::Neumas
|
38
|
-
|
39
30
|
def value
|
40
31
|
{ kind: :serie,
|
41
|
-
serie: S(*capture(:sentences).value) }.extend Neuma
|
32
|
+
serie: Musa::Series::Constructors.S(*capture(:sentences).value) }.extend Musa::Neumas::Neuma
|
42
33
|
end
|
43
34
|
end
|
44
35
|
|
45
36
|
module ReferenceExpression
|
46
|
-
include Musa::Neumas
|
47
|
-
|
48
37
|
def value
|
49
38
|
{ kind: :reference,
|
50
|
-
reference: capture(:expression).value }.extend Neuma
|
39
|
+
reference: capture(:expression).value }.extend Musa::Neumas::Neuma
|
51
40
|
end
|
52
41
|
end
|
53
42
|
|
54
43
|
module VariableAssign
|
55
|
-
include Musa::Neumas
|
56
|
-
|
57
44
|
def value
|
58
45
|
{ kind: :assign_to,
|
59
46
|
assign_to: captures(:use_variable).collect { |c| c.value[:use_variable] },
|
60
47
|
assign_value: capture(:expression).value
|
61
|
-
}.extend Neuma
|
48
|
+
}.extend Musa::Neumas::Neuma
|
62
49
|
end
|
63
50
|
end
|
64
51
|
|
65
52
|
module Event
|
66
|
-
include Musa::Neumas
|
67
|
-
|
68
53
|
def value
|
69
54
|
{ kind: :event,
|
70
55
|
event: capture(:name).value.to_sym
|
71
|
-
}.merge(capture(:parameters) ? capture(:parameters).value : {}).extend Neuma
|
56
|
+
}.merge(capture(:parameters) ? capture(:parameters).value : {}).extend Musa::Neumas::Neuma
|
72
57
|
end
|
73
58
|
end
|
74
59
|
|
@@ -104,40 +89,31 @@ module Musa
|
|
104
89
|
end
|
105
90
|
|
106
91
|
module BracedCommand
|
107
|
-
include Musa::Neumas
|
108
|
-
|
109
92
|
def value
|
110
93
|
{ kind: :command,
|
111
94
|
command: eval("proc { #{capture(:complex_command).value.strip} }")
|
112
|
-
}.merge(capture(:parameters) ? capture(:parameters).value : {}).extend Neuma
|
95
|
+
}.merge(capture(:parameters) ? capture(:parameters).value : {}).extend Musa::Neumas::Neuma
|
113
96
|
end
|
114
97
|
end
|
115
98
|
|
116
99
|
module CallMethodsExpression
|
117
|
-
include Musa::Neumas
|
118
|
-
|
119
100
|
def value
|
120
101
|
{ kind: :call_methods,
|
121
102
|
call_methods: captures(:method_call).collect(&:value),
|
122
|
-
on: capture(:object_expression).value }.extend Neuma
|
103
|
+
on: capture(:object_expression).value }.extend Musa::Neumas::Neuma
|
123
104
|
end
|
124
105
|
end
|
125
106
|
|
126
107
|
module UseVariable
|
127
|
-
include Musa::Neumas
|
128
|
-
|
129
108
|
def value
|
130
109
|
{ kind: :use_variable,
|
131
|
-
use_variable: "@#{capture(:name).value}".to_sym }.extend Neuma
|
110
|
+
use_variable: "@#{capture(:name).value}".to_sym }.extend Musa::Neumas::Neuma
|
132
111
|
end
|
133
112
|
end
|
134
113
|
|
135
114
|
module NeumaAsAttributes
|
136
|
-
include Musa::Neumas
|
137
|
-
include Musa::Datasets
|
138
|
-
|
139
115
|
def value
|
140
|
-
h = {}.extend GDVd
|
116
|
+
h = {}.extend Musa::Datasets::GDVd
|
141
117
|
|
142
118
|
capture(:grade)&.value&.tap { |_| h.merge! _ if _ }
|
143
119
|
capture(:octave)&.value&.tap { |_| h.merge! _ if _ }
|
@@ -147,46 +123,35 @@ module Musa
|
|
147
123
|
h[:modifiers] = {} unless captures(:modifiers).empty?
|
148
124
|
captures(:modifiers).collect(&:value).each { |_| h[:modifiers].merge! _ if _ }
|
149
125
|
|
150
|
-
{ kind: :gdvd, gdvd: h }.extend Neuma
|
126
|
+
{ kind: :gdvd, gdvd: h }.extend Musa::Neumas::Neuma
|
151
127
|
end
|
152
128
|
end
|
153
129
|
|
154
130
|
module PackedVector
|
155
|
-
include Musa::Neumas
|
156
|
-
|
157
131
|
def value
|
158
|
-
{ kind: :packed_v, packed_v: capture(:raw_packed_vector).value }.extend(Neuma)
|
132
|
+
{ kind: :packed_v, packed_v: capture(:raw_packed_vector).value }.extend(Musa::Neumas::Neuma)
|
159
133
|
end
|
160
134
|
end
|
161
135
|
|
162
136
|
module RawPackedVector
|
163
|
-
include Musa::Datasets
|
164
|
-
|
165
137
|
def value
|
166
|
-
captures(:key_value).collect(&:value).to_h.extend(PackedV)
|
138
|
+
captures(:key_value).collect(&:value).to_h.extend(Musa::Datasets::PackedV)
|
167
139
|
end
|
168
140
|
end
|
169
141
|
|
170
142
|
module Vector
|
171
|
-
include Musa::Neumas
|
172
|
-
|
173
143
|
def value
|
174
|
-
{ kind: :v, v: capture(:raw_vector).value }.extend(Neuma)
|
144
|
+
{ kind: :v, v: capture(:raw_vector).value }.extend(Musa::Neumas::Neuma)
|
175
145
|
end
|
176
146
|
end
|
177
147
|
|
178
148
|
module RawVector
|
179
|
-
include Musa::Datasets
|
180
|
-
|
181
149
|
def value
|
182
|
-
captures(:raw_number).collect(&:value).extend(V)
|
150
|
+
captures(:raw_number).collect(&:value).extend(Musa::Datasets::V)
|
183
151
|
end
|
184
152
|
end
|
185
153
|
|
186
154
|
module ProcessOfVectors
|
187
|
-
include Musa::Datasets
|
188
|
-
include Musa::Neumas
|
189
|
-
|
190
155
|
def value
|
191
156
|
durations_rest = []
|
192
157
|
i = 0
|
@@ -198,8 +163,8 @@ module Musa
|
|
198
163
|
i += 1
|
199
164
|
end
|
200
165
|
|
201
|
-
p = ([ capture(:first).value ] + durations_rest).extend(P)
|
202
|
-
{ kind: :p, p: p }.extend(Neuma)
|
166
|
+
p = ([ capture(:first).value ] + durations_rest).extend(Musa::Datasets::P)
|
167
|
+
{ kind: :p, p: p }.extend(Musa::Neumas::Neuma)
|
203
168
|
end
|
204
169
|
end
|
205
170
|
|
@@ -326,39 +291,31 @@ module Musa
|
|
326
291
|
end
|
327
292
|
|
328
293
|
module Symbol
|
329
|
-
include Musa::Neumas
|
330
|
-
|
331
294
|
def value
|
332
295
|
{ kind: :value,
|
333
|
-
value: capture(:name).value.to_sym }.extend Neuma
|
296
|
+
value: capture(:name).value.to_sym }.extend Musa::Neumas::Neuma
|
334
297
|
end
|
335
298
|
end
|
336
299
|
|
337
300
|
module String
|
338
|
-
include Musa::Neumas
|
339
|
-
|
340
301
|
def value
|
341
302
|
{ kind: :value,
|
342
|
-
value: capture(:everything_except_double_quote).value }.extend Neuma
|
303
|
+
value: capture(:everything_except_double_quote).value }.extend Musa::Neumas::Neuma
|
343
304
|
end
|
344
305
|
end
|
345
306
|
|
346
307
|
module Number
|
347
|
-
include Musa::Neumas
|
348
|
-
|
349
308
|
def value
|
350
309
|
{ kind: :value,
|
351
|
-
value: capture(:raw_number).value }.extend Neuma
|
310
|
+
value: capture(:raw_number).value }.extend Musa::Neumas::Neuma
|
352
311
|
end
|
353
312
|
end
|
354
313
|
|
355
314
|
module Special
|
356
|
-
include Musa::Neumas
|
357
|
-
|
358
315
|
def value
|
359
316
|
v = captures(0)
|
360
317
|
{ kind: :value,
|
361
|
-
value: v == 'nil' ? nil : (v == 'true' ? true : false) }.extend Neuma
|
318
|
+
value: v == 'nil' ? nil : (v == 'true' ? true : false) }.extend Musa::Neumas::Neuma
|
362
319
|
end
|
363
320
|
end
|
364
321
|
end
|
@@ -366,10 +323,11 @@ module Musa
|
|
366
323
|
extend self
|
367
324
|
|
368
325
|
def parse(string_or_file, decode_with: nil, debug: nil)
|
369
|
-
|
326
|
+
case string_or_file
|
327
|
+
when String
|
370
328
|
match = Parser::Grammar::Grammar.parse string_or_file
|
371
329
|
|
372
|
-
|
330
|
+
when File
|
373
331
|
match = Parser::Grammar::Grammar.parse string_or_file.read
|
374
332
|
|
375
333
|
else
|