musa-dsl 0.41.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +15 -1
  4. data/docs/README.md +1 -0
  5. data/docs/subsystems/datasets.md +75 -0
  6. data/docs/subsystems/generative.md +92 -6
  7. data/docs/subsystems/music.md +33 -14
  8. data/docs/subsystems/transport.md +26 -0
  9. data/lib/musa-dsl/datasets/dataset.rb +2 -0
  10. data/lib/musa-dsl/datasets/gdv.rb +3 -3
  11. data/lib/musa-dsl/datasets/p.rb +1 -1
  12. data/lib/musa-dsl/datasets/score/to-mxml/process-time.rb +4 -2
  13. data/lib/musa-dsl/datasets/score.rb +3 -1
  14. data/lib/musa-dsl/generative/generative-grammar.rb +3 -1
  15. data/lib/musa-dsl/generative/markov.rb +1 -1
  16. data/lib/musa-dsl/midi/midi-voices.rb +3 -1
  17. data/lib/musa-dsl/music/chord-definition.rb +7 -5
  18. data/lib/musa-dsl/music/chord-definitions.rb +37 -0
  19. data/lib/musa-dsl/music/chords.rb +69 -47
  20. data/lib/musa-dsl/music/scale_kinds/major_scale_kind.rb +1 -1
  21. data/lib/musa-dsl/music/scale_kinds/minor_natural_scale_kind.rb +1 -1
  22. data/lib/musa-dsl/music/scales.rb +219 -107
  23. data/lib/musa-dsl/musicxml/builder/note.rb +31 -92
  24. data/lib/musa-dsl/musicxml/builder/pitched-note.rb +33 -94
  25. data/lib/musa-dsl/musicxml/builder/rest.rb +30 -91
  26. data/lib/musa-dsl/musicxml/builder/unpitched-note.rb +31 -91
  27. data/lib/musa-dsl/neumas/array-to-neumas.rb +1 -1
  28. data/lib/musa-dsl/neumas/neuma-gdv-decoder.rb +2 -2
  29. data/lib/musa-dsl/sequencer/sequencer-dsl.rb +367 -3
  30. data/lib/musa-dsl/series/base-series.rb +250 -240
  31. data/lib/musa-dsl/series/buffer-serie.rb +10 -5
  32. data/lib/musa-dsl/series/hash-or-array-serie-splitter.rb +6 -3
  33. data/lib/musa-dsl/series/main-serie-constructors.rb +19 -15
  34. data/lib/musa-dsl/series/main-serie-operations.rb +74 -29
  35. data/lib/musa-dsl/series/proxy-serie.rb +5 -1
  36. data/lib/musa-dsl/series/quantizer-serie.rb +4 -2
  37. data/lib/musa-dsl/series/queue-serie.rb +2 -1
  38. data/lib/musa-dsl/series/series-composer.rb +5 -2
  39. data/lib/musa-dsl/series/timed-serie.rb +8 -4
  40. data/lib/musa-dsl/transport/timer-clock.rb +4 -2
  41. data/lib/musa-dsl/transport/timer.rb +27 -4
  42. data/lib/musa-dsl/version.rb +1 -2
  43. data/musa-dsl.gemspec +0 -2
  44. metadata +1 -1
@@ -59,7 +59,119 @@ module Musa
59
59
  class Sequencer
60
60
  extend Forwardable
61
61
 
62
- # Delegates to BaseSequencer
62
+ # @!method beats_per_bar
63
+ # Returns beats per bar (time signature numerator).
64
+ #
65
+ # Delegated from {BaseSequencer#beats_per_bar}.
66
+ #
67
+ # @return [Integer, nil] beats per bar, or nil for tickless mode
68
+
69
+ # @!method ticks_per_beat
70
+ # Returns ticks per beat (timing resolution).
71
+ #
72
+ # Delegated from {BaseSequencer#ticks_per_beat}.
73
+ #
74
+ # @return [Integer, nil] ticks per beat, or nil for tickless mode
75
+
76
+ # @!method ticks_per_bar
77
+ # Returns total ticks per bar.
78
+ #
79
+ # Delegated from BaseSequencer#ticks_per_bar.
80
+ #
81
+ # @return [Integer, nil] ticks per bar, or nil for tickless mode
82
+
83
+ # @!method tick_duration
84
+ # Returns duration of a single tick.
85
+ #
86
+ # Delegated from BaseSequencer#tick_duration.
87
+ #
88
+ # @return [Rational, nil] tick duration in bars, or nil for tickless mode
89
+
90
+ # @!method offset
91
+ # Returns the sequencer's starting position offset.
92
+ #
93
+ # Delegated from {BaseSequencer#offset}.
94
+ #
95
+ # @return [Rational, nil] position offset
96
+
97
+ # @!method size
98
+ # Returns number of scheduled events.
99
+ #
100
+ # Delegated from {BaseSequencer#size}.
101
+ #
102
+ # @return [Integer] count of pending events
103
+
104
+ # @!method empty?
105
+ # Checks if sequencer has no scheduled events.
106
+ #
107
+ # Delegated from {BaseSequencer#empty?}.
108
+ #
109
+ # @return [Boolean] true if no events scheduled
110
+
111
+ # @!method on_debug_at
112
+ # Registers debug handler for specific position.
113
+ #
114
+ # Delegated from {BaseSequencer#on_debug_at}.
115
+ #
116
+ # @yield block to execute when position is reached in debug mode
117
+
118
+ # @!method on_error
119
+ # Registers error handler for sequencer errors.
120
+ #
121
+ # Delegated from {BaseSequencer#on_error}.
122
+ #
123
+ # @yield [Exception] block to handle errors
124
+
125
+ # @!method on_fast_forward
126
+ # Registers handler called during fast-forward operations.
127
+ #
128
+ # Delegated from {BaseSequencer#on_fast_forward}.
129
+ #
130
+ # @yield block executed during fast-forward
131
+
132
+ # @!method before_tick
133
+ # Registers handler called before each tick.
134
+ #
135
+ # Delegated from {BaseSequencer#before_tick}.
136
+ #
137
+ # @yield block executed before tick processing
138
+
139
+ # @!method raw_at(position, &block)
140
+ # Schedules block at position without DSL context wrapping.
141
+ #
142
+ # Delegated from {BaseSequencer#raw_at}.
143
+ #
144
+ # @param position [Numeric, Rational] bar position
145
+ # @yield block to execute at position
146
+
147
+ # @!method tick
148
+ # Advances sequencer by one tick and processes events.
149
+ #
150
+ # Delegated from BaseSequencer#tick.
151
+ #
152
+ # @return [void]
153
+
154
+ # @!method reset
155
+ # Resets sequencer to initial state.
156
+ #
157
+ # Delegated from {BaseSequencer#reset}.
158
+ #
159
+ # @return [void]
160
+
161
+ # @!method position=(value)
162
+ # Sets the current sequencer position.
163
+ #
164
+ # Delegated from BaseSequencer#position=.
165
+ #
166
+ # @param value [Numeric, Rational] new position in bars
167
+ # @return [void]
168
+
169
+ # @!method event_handler
170
+ # Returns the event handler for launch/on events.
171
+ #
172
+ # Delegated from {BaseSequencer#event_handler}.
173
+ #
174
+ # @return [EventHandler] event handler instance
63
175
  def_delegators :@sequencer,
64
176
  :beats_per_bar, :ticks_per_beat, :ticks_per_bar, :tick_duration,
65
177
  :offset,
@@ -71,7 +183,162 @@ module Musa
71
183
  :position=,
72
184
  :event_handler
73
185
 
74
- # Delegates to DSLContext
186
+ # @!method position
187
+ # Returns current sequencer position in bars.
188
+ #
189
+ # Delegated from {DSLContext#position}.
190
+ #
191
+ # @return [Rational] current position
192
+
193
+ # @!method quantize_position(reference, step, offset: nil)
194
+ # Quantizes a position to a grid.
195
+ #
196
+ # Delegated from {DSLContext#quantize_position}.
197
+ #
198
+ # @param reference [Numeric, Rational] reference position
199
+ # @param step [Numeric, Rational] grid step size
200
+ # @param offset [Numeric, Rational, nil] grid offset
201
+ # @return [Rational] quantized position
202
+
203
+ # @!method logger
204
+ # Returns the sequencer's logger instance.
205
+ #
206
+ # Delegated from {DSLContext#logger}.
207
+ #
208
+ # @return [Logger, nil] logger instance
209
+
210
+ # @!method debug
211
+ # Returns or enables debug mode.
212
+ #
213
+ # Delegated from {DSLContext#debug}.
214
+ #
215
+ # @return [Boolean] debug mode status
216
+
217
+ # @!method now(*value_parameters, **key_parameters, &block)
218
+ # Executes block immediately at current position.
219
+ #
220
+ # Delegated from {DSLContext#now}.
221
+ #
222
+ # @param value_parameters [Array] parameters to pass to block
223
+ # @param key_parameters [Hash] keyword parameters
224
+ # @yield block to execute now
225
+ # @return [void]
226
+
227
+ # @!method at(position, *value_parameters, **key_parameters, &block)
228
+ # Schedules block to execute at specified position.
229
+ #
230
+ # Delegated from {DSLContext#at}.
231
+ #
232
+ # @param position [Numeric, Rational] bar position
233
+ # @param value_parameters [Array] parameters to pass to block
234
+ # @param key_parameters [Hash] keyword parameters
235
+ # @yield block to execute at position
236
+ # @return [void]
237
+
238
+ # @!method wait(duration, *value_parameters, **key_parameters, &block)
239
+ # Schedules block after waiting specified duration.
240
+ #
241
+ # Delegated from {DSLContext#wait}.
242
+ #
243
+ # @param duration [Numeric, Rational] wait duration in bars
244
+ # @param value_parameters [Array] parameters to pass to block
245
+ # @param key_parameters [Hash] keyword parameters
246
+ # @yield block to execute after wait
247
+ # @return [void]
248
+
249
+ # @!method play(serie, decoder: nil, mode: nil, **options, &block)
250
+ # Plays a series using the decoder.
251
+ #
252
+ # Delegated from {DSLContext#play}.
253
+ #
254
+ # @param serie [Serie] series to play
255
+ # @param decoder [Object, nil] decoder for series elements
256
+ # @param mode [Symbol, nil] playback mode (:neumalang, etc.)
257
+ # @param options [Hash] additional play options
258
+ # @yield [element] block to process each element
259
+ # @return [PlayControl] control object for the playing series
260
+
261
+ # @!method play_timed(timed_serie, **options, &block)
262
+ # Plays a timed series with explicit timing.
263
+ #
264
+ # Delegated from {DSLContext#play_timed}.
265
+ #
266
+ # @param timed_serie [Serie] timed series to play
267
+ # @param options [Hash] play options
268
+ # @yield [element, duration] block to process elements
269
+ # @return [PlayControl] control object
270
+
271
+ # @!method every(interval, duration: nil, till: nil, **options, &block)
272
+ # Executes block repeatedly at interval.
273
+ #
274
+ # Delegated from {DSLContext#every}.
275
+ #
276
+ # @param interval [Numeric, Rational] repetition interval in bars
277
+ # @param duration [Numeric, Rational, nil] total duration
278
+ # @param till [Numeric, Rational, nil] end position
279
+ # @param options [Hash] additional options
280
+ # @yield block to execute each interval
281
+ # @return [EveryControl] control object
282
+
283
+ # @!method move(from: nil, to: nil, duration: nil, step: nil, **options, &block)
284
+ # Interpolates values over time.
285
+ #
286
+ # Delegated from {DSLContext#move}.
287
+ #
288
+ # @param from [Numeric, nil] starting value
289
+ # @param to [Numeric, nil] ending value
290
+ # @param duration [Numeric, Rational, nil] interpolation duration
291
+ # @param step [Numeric, Rational, nil] time step
292
+ # @param options [Hash] additional options
293
+ # @yield [value] block receiving interpolated values
294
+ # @return [MoveControl] control object
295
+
296
+ # @!method everying
297
+ # Returns control for active every loops.
298
+ #
299
+ # Delegated from {DSLContext#everying}.
300
+ #
301
+ # @return [EveryingControl] control for active loops
302
+
303
+ # @!method playing
304
+ # Returns control for active play operations.
305
+ #
306
+ # Delegated from {DSLContext#playing}.
307
+ #
308
+ # @return [PlayingControl] control for active plays
309
+
310
+ # @!method moving
311
+ # Returns control for active move interpolations.
312
+ #
313
+ # Delegated from {DSLContext#moving}.
314
+ #
315
+ # @return [MovingControl] control for active moves
316
+
317
+ # @!method launch(event_name, *parameters, **key_parameters)
318
+ # Triggers an event by name.
319
+ #
320
+ # Delegated from {DSLContext#launch}.
321
+ #
322
+ # @param event_name [Symbol] event identifier
323
+ # @param parameters [Array] event parameters
324
+ # @param key_parameters [Hash] event keyword parameters
325
+ # @return [void]
326
+
327
+ # @!method on(event_name, &block)
328
+ # Registers handler for named event.
329
+ #
330
+ # Delegated from {DSLContext#on}.
331
+ #
332
+ # @param event_name [Symbol] event identifier
333
+ # @yield block to execute when event fires
334
+ # @return [void]
335
+
336
+ # @!method run
337
+ # Runs the sequencer until all events complete.
338
+ #
339
+ # Delegated from {DSLContext#run}.
340
+ #
341
+ # @return [void]
75
342
  def_delegators :@dsl, :position, :quantize_position, :logger, :debug
76
343
  def_delegators :@dsl, :now, :at, :wait, :play, :play_timed, :every, :move
77
344
  def_delegators :@dsl, :everying, :playing, :moving
@@ -210,7 +477,104 @@ module Musa
210
477
  # @return [BaseSequencer] underlying sequencer
211
478
  attr_reader :sequencer
212
479
 
213
- # Delegates to BaseSequencer
480
+ # @!method launch(event_name, *parameters, **key_parameters)
481
+ # Triggers an event by name.
482
+ #
483
+ # Delegated from {BaseSequencer#launch}.
484
+ #
485
+ # @param event_name [Symbol] event identifier
486
+ # @param parameters [Array] event parameters
487
+ # @param key_parameters [Hash] event keyword parameters
488
+ # @return [void]
489
+
490
+ # @!method on(event_name, &block)
491
+ # Registers handler for named event.
492
+ #
493
+ # Delegated from {BaseSequencer#on}.
494
+ #
495
+ # @param event_name [Symbol] event identifier
496
+ # @yield block to execute when event fires
497
+ # @return [void]
498
+
499
+ # @!method position
500
+ # Returns current sequencer position in bars.
501
+ #
502
+ # Delegated from BaseSequencer#position.
503
+ #
504
+ # @return [Rational] current position
505
+
506
+ # @!method quantize_position(reference, step, offset: nil)
507
+ # Quantizes a position to a grid.
508
+ #
509
+ # Delegated from {BaseSequencer#quantize_position}.
510
+ #
511
+ # @param reference [Numeric, Rational] reference position
512
+ # @param step [Numeric, Rational] grid step size
513
+ # @param offset [Numeric, Rational, nil] grid offset
514
+ # @return [Rational] quantized position
515
+
516
+ # @!method size
517
+ # Returns number of scheduled events.
518
+ #
519
+ # Delegated from {BaseSequencer#size}.
520
+ #
521
+ # @return [Integer] count of pending events
522
+
523
+ # @!method everying
524
+ # Returns control for active every loops.
525
+ #
526
+ # Delegated from {BaseSequencer#everying}.
527
+ #
528
+ # @return [EveryingControl] control for active loops
529
+
530
+ # @!method playing
531
+ # Returns control for active play operations.
532
+ #
533
+ # Delegated from {BaseSequencer#playing}.
534
+ #
535
+ # @return [PlayingControl] control for active plays
536
+
537
+ # @!method moving
538
+ # Returns control for active move interpolations.
539
+ #
540
+ # Delegated from {BaseSequencer#moving}.
541
+ #
542
+ # @return [MovingControl] control for active moves
543
+
544
+ # @!method ticks_per_bar
545
+ # Returns total ticks per bar.
546
+ #
547
+ # Delegated from BaseSequencer#ticks_per_bar.
548
+ #
549
+ # @return [Integer, nil] ticks per bar, or nil for tickless mode
550
+
551
+ # @!method logger
552
+ # Returns the sequencer's logger instance.
553
+ #
554
+ # Delegated from {BaseSequencer#logger}.
555
+ #
556
+ # @return [Logger, nil] logger instance
557
+
558
+ # @!method debug
559
+ # Returns or enables debug mode.
560
+ #
561
+ # Delegated from {BaseSequencer#debug}.
562
+ #
563
+ # @return [Boolean] debug mode status
564
+
565
+ # @!method inspect
566
+ # Returns string representation of the context.
567
+ #
568
+ # Delegated from BaseSequencer#inspect.
569
+ #
570
+ # @return [String] inspection string
571
+
572
+ # @!method run
573
+ # Runs the sequencer until all events complete.
574
+ #
575
+ # Delegated from {BaseSequencer#run}.
576
+ #
577
+ # @return [void]
214
578
  def_delegators :@sequencer,
215
579
  :launch, :on,
216
580
  :position, :quantize_position,