musa-dsl 0.21.0 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/lib/musa-dsl.rb +1 -1
- data/lib/musa-dsl/core-ext.rb +1 -0
- data/lib/musa-dsl/core-ext/arrayfy.rb +9 -9
- data/lib/musa-dsl/core-ext/hashify.rb +42 -0
- data/lib/musa-dsl/core-ext/inspect-nice.rb +6 -1
- data/lib/musa-dsl/datasets/e.rb +22 -5
- data/lib/musa-dsl/datasets/gdv.rb +0 -1
- data/lib/musa-dsl/datasets/p.rb +28 -37
- data/lib/musa-dsl/datasets/pdv.rb +0 -1
- data/lib/musa-dsl/datasets/ps.rb +10 -78
- data/lib/musa-dsl/generative/markov.rb +1 -1
- data/lib/musa-dsl/logger/logger.rb +4 -3
- data/lib/musa-dsl/matrix/matrix.rb +0 -57
- data/lib/musa-dsl/midi/midi-voices.rb +4 -0
- data/lib/musa-dsl/neumas/string-to-neumas.rb +1 -0
- data/lib/musa-dsl/repl/repl.rb +30 -11
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-every.rb +87 -0
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb +439 -0
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-helper.rb +3 -3
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb +210 -0
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-play.rb +178 -0
- data/lib/musa-dsl/sequencer/base-sequencer-implementation.rb +150 -595
- data/lib/musa-dsl/sequencer/base-sequencer-public.rb +58 -5
- data/lib/musa-dsl/sequencer/base-sequencer-tick-based.rb +5 -9
- data/lib/musa-dsl/sequencer/base-sequencer-tickless-based.rb +1 -5
- data/lib/musa-dsl/sequencer/sequencer-dsl.rb +8 -0
- data/lib/musa-dsl/series/base-series.rb +43 -78
- data/lib/musa-dsl/series/flattener-timed-serie.rb +61 -0
- data/lib/musa-dsl/series/hash-or-array-serie-splitter.rb +95 -0
- data/lib/musa-dsl/series/holder-serie.rb +1 -1
- data/lib/musa-dsl/series/main-serie-constructors.rb +29 -83
- data/lib/musa-dsl/series/main-serie-operations.rb +60 -215
- data/lib/musa-dsl/series/proxy-serie.rb +1 -1
- data/lib/musa-dsl/series/quantizer-serie.rb +546 -0
- data/lib/musa-dsl/series/queue-serie.rb +1 -1
- data/lib/musa-dsl/series/series.rb +7 -2
- data/lib/musa-dsl/transport/input-midi-clock.rb +19 -12
- data/lib/musa-dsl/transport/transport.rb +25 -12
- data/musa-dsl.gemspec +2 -2
- metadata +11 -5
- data/lib/musa-dsl/sequencer/base-sequencer-implementation-control.rb +0 -216
- data/lib/musa-dsl/series/hash-serie-splitter.rb +0 -196
@@ -1,196 +0,0 @@
|
|
1
|
-
module Musa
|
2
|
-
# TODO: adapt to series prototyping
|
3
|
-
# TODO: full test cases
|
4
|
-
|
5
|
-
module Series
|
6
|
-
module SerieOperations
|
7
|
-
def split(buffered: nil, master: nil)
|
8
|
-
buffered ||= false
|
9
|
-
|
10
|
-
return HashSplitter.new HashSplitter::KeyProxy.new(self) if master.nil? && !buffered
|
11
|
-
return HashSplitter.new HashSplitter::MasterSlaveKeyProxy.new(self, master) if !master.nil? && !buffered
|
12
|
-
return HashSplitter.new HashSplitter::BufferedKeyProxy.new(self) if buffered
|
13
|
-
end
|
14
|
-
|
15
|
-
class HashSplitter
|
16
|
-
def initialize(proxy)
|
17
|
-
@proxy = proxy
|
18
|
-
@series = {}
|
19
|
-
end
|
20
|
-
|
21
|
-
def [](key)
|
22
|
-
serie = if @series.key? key
|
23
|
-
@series[key]
|
24
|
-
else
|
25
|
-
@series[key] = Splitted.new(@proxy, key: key)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class KeyProxy
|
30
|
-
def initialize(hash_serie)
|
31
|
-
@serie = hash_serie.instance
|
32
|
-
@values = {}
|
33
|
-
end
|
34
|
-
|
35
|
-
def restart
|
36
|
-
@serie.restart
|
37
|
-
@values = {}
|
38
|
-
end
|
39
|
-
|
40
|
-
def next_value(key)
|
41
|
-
return nil unless @values
|
42
|
-
|
43
|
-
value = @values[key]
|
44
|
-
|
45
|
-
if value.nil?
|
46
|
-
before_values = @values.collect { |k, v| [k, v] unless v.nil? }.compact.to_h
|
47
|
-
|
48
|
-
@values = @serie.next_value
|
49
|
-
value = @values[key] if @values
|
50
|
-
|
51
|
-
warn "Warning: splitted serie #{@serie} values #{before_values} are being lost" if !value.nil? && !before_values.empty?
|
52
|
-
end
|
53
|
-
|
54
|
-
@values[key] = nil if @values
|
55
|
-
|
56
|
-
value
|
57
|
-
end
|
58
|
-
|
59
|
-
def peek_next_value(key)
|
60
|
-
value = @values[key]
|
61
|
-
|
62
|
-
if value.nil?
|
63
|
-
peek_values = @serie.peek_next_value
|
64
|
-
value = peek_values[key] if peek_values
|
65
|
-
end
|
66
|
-
|
67
|
-
value
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
class BufferedKeyProxy
|
72
|
-
def initialize(hash_serie)
|
73
|
-
@serie = hash_serie.instance
|
74
|
-
@values = {}
|
75
|
-
end
|
76
|
-
|
77
|
-
def restart
|
78
|
-
@serie.restart
|
79
|
-
@values = {}
|
80
|
-
end
|
81
|
-
|
82
|
-
def next_value(key)
|
83
|
-
value = nil
|
84
|
-
|
85
|
-
if @values[key].nil? || @values[key].empty?
|
86
|
-
hash_value = @serie.next_value
|
87
|
-
|
88
|
-
if hash_value
|
89
|
-
hash_value.each do |k, v|
|
90
|
-
@values[k] = [] if @values[k].nil?
|
91
|
-
@values[k] << v
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
value = @values[key].shift if @values[key]
|
97
|
-
|
98
|
-
value
|
99
|
-
end
|
100
|
-
|
101
|
-
def peek_next_value(key)
|
102
|
-
value = nil
|
103
|
-
|
104
|
-
if @values[key] && !@values[key].empty?
|
105
|
-
value = @values[key].first
|
106
|
-
else
|
107
|
-
peek_values = @serie.peek_next_value
|
108
|
-
value = peek_values[key] if peek_values
|
109
|
-
end
|
110
|
-
|
111
|
-
value
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
class MasterSlaveKeyProxy
|
116
|
-
def initialize(hash_serie, master)
|
117
|
-
@serie = hash_serie.instance
|
118
|
-
@master = master
|
119
|
-
@values = {}
|
120
|
-
@values_counter = {}
|
121
|
-
end
|
122
|
-
|
123
|
-
def restart
|
124
|
-
@serie.restart
|
125
|
-
@values = {}
|
126
|
-
@values_counter = {}
|
127
|
-
end
|
128
|
-
|
129
|
-
def next_value(key)
|
130
|
-
return nil unless @values
|
131
|
-
|
132
|
-
value = @values[key]
|
133
|
-
|
134
|
-
if value.nil?
|
135
|
-
@values = @serie.next_value
|
136
|
-
|
137
|
-
value = @values[key] if @values
|
138
|
-
|
139
|
-
# warn "Info: splitted serie #{@serie} use count on next_value: #{@values_counter}"
|
140
|
-
@values_counter = {}
|
141
|
-
end
|
142
|
-
|
143
|
-
@values_counter[key] ||= 0
|
144
|
-
@values_counter[key] += 1
|
145
|
-
|
146
|
-
@values[key] = nil if key == @master && @values
|
147
|
-
|
148
|
-
value
|
149
|
-
end
|
150
|
-
|
151
|
-
def peek_next_value(key)
|
152
|
-
return nil unless @values
|
153
|
-
|
154
|
-
value = @values[key]
|
155
|
-
|
156
|
-
if value.nil?
|
157
|
-
peek_values = @serie.peek_next_value
|
158
|
-
value = peek_values[key] if peek_values
|
159
|
-
end
|
160
|
-
|
161
|
-
value
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
class Splitted
|
166
|
-
include Serie
|
167
|
-
|
168
|
-
def initialize(proxy, key:)
|
169
|
-
@proxy = proxy
|
170
|
-
@key = key
|
171
|
-
|
172
|
-
mark_as_instance!
|
173
|
-
end
|
174
|
-
|
175
|
-
def _prototype
|
176
|
-
raise PrototypingSerieError, 'Cannot get prototype of a splitted serie'
|
177
|
-
end
|
178
|
-
|
179
|
-
def _restart
|
180
|
-
@proxy.restart
|
181
|
-
end
|
182
|
-
|
183
|
-
def next_value
|
184
|
-
@proxy.next_value(@key)
|
185
|
-
end
|
186
|
-
|
187
|
-
def peek_next_value
|
188
|
-
@proxy.peek_next_value(@key)
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
private_constant :HashSplitter
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|