Class: Musa::Series::Operations::Processor Private
- Includes:
- Serie::Base, Serie::WithSmartBlock, Serie::WithSource
- Defined in:
- lib/musa-dsl/series/main-serie-operations.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Serie operation that processes/transforms values using a block.
Applies transformation function to each value from source serie. The block can return single values or arrays (which are flattened into the output stream).
Uses smart block binding for flexible parameter handling.
Instance Attribute Summary collapse
- #parameters ⇒ Object private
Instance Method Summary collapse
-
#+(other) ⇒ Sequence
included
from Musa::Series::Operations
Appends another serie (operator alias for after).
-
#after(*series) ⇒ Sequence
included
from Musa::Series::Operations
Appends series sequentially.
-
#anticipate {|current, next_value| ... } ⇒ Anticipate
included
from Musa::Series::Operations
Evaluates block one step ahead (anticipate).
-
#autorestart ⇒ Autorestart
included
from Musa::Series::Operations
Auto-restarts serie when exhausted.
-
#buffered(sync: false) ⇒ BufferSerie, SyncBufferSerie
included
from Musa::Series::Operations
Creates a buffered serie allowing multiple independent iterations over same source.
-
#compact_timed ⇒ TimedCompacter
included
from Musa::Series::Operations
Removes timed events where all values are nil.
-
#composer { ... } ⇒ ComposerAsOperationSerie
included
from Musa::Series::Operations
Creates a composer transformation pipeline for complex multi-stage transformations.
-
#cut(length) ⇒ Cutter
included
from Musa::Series::Operations
Cuts serie into chunks of specified length.
-
#defined? ⇒ Boolean
included
from Serie::Prototyping
Checks if serie state is defined (not undefined).
-
#flatten ⇒ Flattener
included
from Musa::Series::Operations
Flattens nested series into single level.
-
#flatten_timed ⇒ TimedFlattener
included
from Musa::Series::Operations
Splits compound timed values into individual timed events.
-
#hashify(*keys) ⇒ HashFromSeriesArray
included
from Musa::Series::Operations
Converts array values to hash with specified keys.
- #infinite? ⇒ Boolean private
-
#initialize(serie, parameters, &processor) ⇒ Processor
constructor
private
A new instance of Processor.
-
#instance ⇒ Serie
(also: #i)
included
from Serie::Prototyping
Creates or returns instance of serie.
-
#instance? ⇒ Boolean
included
from Serie::Prototyping
Checks if serie is in instance state.
-
#lazy {|previous| ... } ⇒ LazySerieEval
included
from Musa::Series::Operations
Delays evaluation to next step (lazy evaluation).
-
#lock ⇒ Locker
included
from Musa::Series::Operations
Locks serie preventing further modifications.
-
#map(isolate_values: nil) {|value| ... } ⇒ ProcessWith
included
from Musa::Series::Operations
Maps values via transformation block.
-
#max_size(length) ⇒ LengthLimiter
included
from Musa::Series::Operations
Limits serie to maximum number of values.
-
#merge ⇒ MergeSerieOfSeries
included
from Musa::Series::Operations
Merges serie of series into single serie.
-
#multiplex(*indexed_series, **hash_series) ⇒ MultiplexSelector
included
from Musa::Series::Operations
Multiplexes values from multiple series based on selector.
-
#proc(&block) ⇒ Object
included
from Serie::WithSmartBlock
Gets or sets the proc with SmartProcBinder wrapping.
-
#proc=(block) ⇒ Object
included
from Serie::WithSmartBlock
Sets the proc with SmartProcBinder wrapping.
-
#process_with(**parameters) {|value, parameters| ... } ⇒ Processor
included
from Musa::Series::Operations
Processes values with parameterized block.
-
#prototype ⇒ Serie
(also: #p)
included
from Serie::Prototyping
Returns prototype of serie.
-
#prototype? ⇒ Boolean
included
from Serie::Prototyping
Checks if serie is in prototype state.
-
#proxy ⇒ Object
included
from Musa::Series::Operations
TODO add test case.
-
#quantize(reference: nil, step: nil, value_attribute: nil, stops: nil, predictive: nil, left_open: nil, right_open: nil) ⇒ RawQuantizer, PredictiveQuantizer
included
from Musa::Series::Operations
Quantizes time-value serie to discrete steps.
-
#queued ⇒ QueueSerie
included
from Musa::Series::Operations
Wraps this serie in a queue.
-
#randomize(random: nil) ⇒ Randomizer
included
from Musa::Series::Operations
Randomizes order of values.
-
#remove(block = nil) {|value| ... } ⇒ Remover
included
from Musa::Series::Operations
Removes values matching condition.
-
#repeat(times = nil, condition: nil) { ... } ⇒ Repeater, InfiniteRepeater
included
from Musa::Series::Operations
Repeats serie multiple times or conditionally.
-
#reverse ⇒ Reverser
included
from Musa::Series::Operations
Reverses order of values.
-
#select(block = nil) {|value| ... } ⇒ Selector
included
from Musa::Series::Operations
Selects values matching condition.
-
#shift(shift) ⇒ Shifter
included
from Musa::Series::Operations
Rotates serie elements circularly.
-
#skip(length) ⇒ Skipper
included
from Musa::Series::Operations
Skips first N values.
-
#source ⇒ Serie?
included
from Serie::WithSource
The upstream source serie.
-
#source=(serie) ⇒ Object
included
from Serie::WithSource
Sets the source serie.
-
#split ⇒ Splitter
included
from Musa::Series::Operations
Serie splitter for decomposing hash/array values into component series.
-
#state ⇒ Symbol
included
from Serie::Prototyping
Returns current state of serie.
-
#switch(*indexed_series, **hash_series) ⇒ Switcher
included
from Musa::Series::Operations
Switches between multiple series based on selector values.
-
#switch_serie(*indexed_series, **hash_series) ⇒ SwitchFullSerie
included
from Musa::Series::Operations
Switches to entirely different series based on selector.
-
#undefined? ⇒ Boolean
included
from Serie::Prototyping
Checks if serie is in undefined state.
-
#union_timed(*other_timed_series, key: nil, **other_key_timed_series) ⇒ TimedUnionOfArrayOfTimedSeries, TimedUnionOfHashOfTimedSeries
included
from Musa::Series::Operations
Combines this timed serie with others via TIMED_UNION.
-
#with(*with_series, on_restart: nil, isolate_values: nil, **with_key_series) {|main_value, with_values, with_key_values| ... } ⇒ With
(also: #eval)
included
from Musa::Series::Operations
Combines multiple series for mapping.
Constructor Details
#initialize(serie, parameters, &processor) ⇒ Processor
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Processor.
1194 1195 1196 1197 1198 1199 1200 1201 |
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 1194 def initialize(serie, parameters, &processor) self.source = serie self.parameters = parameters self.proc = processor if processor init end |
Instance Attribute Details
#parameters ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
1203 1204 1205 |
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 1203 def parameters @parameters end |
Instance Method Details
#+(other) ⇒ Sequence Originally defined in module Musa::Series::Operations
Appends another serie (operator alias for after).
#after(*series) ⇒ Sequence Originally defined in module Musa::Series::Operations
Appends series sequentially.
Alias for MERGE - plays this serie, then others in sequence.
#anticipate {|current, next_value| ... } ⇒ Anticipate Originally defined in module Musa::Series::Operations
Evaluates block one step ahead (anticipate).
Block receives current value and NEXT value (peeked). Enables look-ahead transformations and transitions.
#autorestart ⇒ Autorestart Originally defined in module Musa::Series::Operations
Auto-restarts serie when exhausted.
Creates an infinite serie from an original serie that automatically restarts from beginning when it reaches the end.
#buffered(sync: false) ⇒ BufferSerie, SyncBufferSerie Originally defined in module Musa::Series::Operations
Creates a buffered serie allowing multiple independent iterations over same source.
Provides buffering mechanism enabling multiple "readers" to independently iterate over the same serie source without interfering with each other.
Buffering Modes
- Async (default): Buffers fill independently, each progresses at own pace
- Sync: All buffers synchronized, restart affects all
Use Cases
- Multiple voices reading same melodic sequence at different speeds
- Polyphonic playback from single source
- Canonic structures (rounds, fugues)
- Independent transformations of same base material
Memory Management
History is automatically cleaned when all buffers have progressed past old values, preventing unbounded memory growth.
#compact_timed ⇒ TimedCompacter Originally defined in module Musa::Series::Operations
Removes timed events where all values are nil.
Filters out temporal "gaps" where no sources have active values. Useful after union operations that create nil placeholders, or for cleaning sparse sequences.
Removal logic:
- Direct nil:
{ time: t, value: nil }→ removed - All-nil Hash:
{ time: t, value: { a: nil, b: nil } }→ removed - Partial Hash:
{ time: t, value: { a: 1, b: nil } }→ kept (has non-nil) - All-nil Array:
{ time: t, value: [nil, nil] }→ removed - Partial Array:
{ time: t, value: [1, nil] }→ kept (has non-nil)
#composer { ... } ⇒ ComposerAsOperationSerie Originally defined in module Musa::Series::Operations
Creates a composer transformation pipeline for complex multi-stage transformations.
Composer provides declarative DSL for building transformation pipelines with multiple inputs, outputs, and intermediate processing stages.
Composer Concepts
- Pipelines: Named transformation chains
- Inputs: Named input series (proxied and buffered)
- Outputs: Named output series
- Operations: Transformation steps in pipeline
- Auto-commit: Automatic finalization of pipelines
DSL Structure
composer do
input_name >> operation1 >> operation2 >> :output_name
:other_input >> transform >> :other_output
end
Musical Applications
- Complex multi-voice processing
- Effect chains and routing
- Algorithmic composition pipelines
- Multi-stage transformations
- Modular synthesis-style routing
#cut(length) ⇒ Cutter Originally defined in module Musa::Series::Operations
Cuts serie into chunks of specified length.
Returns serie of arrays, each containing length values.
#defined? ⇒ Boolean Originally defined in module Serie::Prototyping
Checks if serie state is defined (not undefined).
#flatten ⇒ Flattener Originally defined in module Musa::Series::Operations
Flattens nested series into single level.
Recursively consumes series elements that are themselves series.
#flatten_timed ⇒ TimedFlattener Originally defined in module Musa::Series::Operations
Splits compound timed values into individual timed events.
Converts events with Hash or Array values into separate timed events per element, preserving time and extra attributes. Direct values pass through unchanged.
Hash values → Hash of timed events (keyed by original keys):
{ time: 0, value: { a: 1, b: 2 }, velocity: { a: 80, b: 90 } }
# becomes:
{ a: { time: 0, value: 1, velocity: 80 },
b: { time: 0, value: 2, velocity: 90 } }
Array values → Array of timed events (indexed):
{ time: 0, value: [1, 2], velocity: [80, 90] }
# becomes:
[{ time: 0, value: 1, velocity: 80 },
{ time: 0, value: 2, velocity: 90 }]
Direct values → Pass through unchanged (already flat)
Use Cases
- Separate polyphonic events into individual voices
- Split multi-track sequences for independent processing
- Prepare for voice-specific routing via
split - Enable per-voice filtering with
compact_timed
#hashify(*keys) ⇒ HashFromSeriesArray Originally defined in module Musa::Series::Operations
Converts array values to hash with specified keys.
Takes array-valued serie and converts to hash using provided keys.
#infinite? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
1239 1240 1241 |
# File 'lib/musa-dsl/series/main-serie-operations.rb', line 1239 def infinite? @source.infinite? end |
#instance ⇒ Serie Also known as: i Originally defined in module Serie::Prototyping
Creates or returns instance of serie.
- If already instance, returns self
- If prototype, creates new instance by cloning
- If undefined, raises PrototypingError
Cloning Process
- Clones serie structure
- Marks clone as :instance
- Propagates instance creation to sources
- Calls init if defined
Each call creates independent instance with separate state.
#instance? ⇒ Boolean Originally defined in module Serie::Prototyping
Checks if serie is in instance state.
#lazy {|previous| ... } ⇒ LazySerieEval Originally defined in module Musa::Series::Operations
Delays evaluation to next step (lazy evaluation).
Block receives previous value and evaluates for current step. Enables state-dependent transformations.
#lock ⇒ Locker Originally defined in module Musa::Series::Operations
Locks serie preventing further modifications.
Returns locked copy that cannot be transformed further.
#map(isolate_values: nil) {|value| ... } ⇒ ProcessWith Originally defined in module Musa::Series::Operations
Maps values via transformation block.
Simplest and most common transformation. Applies block to each value.
Shorthand for with without additional series.
#max_size(length) ⇒ LengthLimiter Originally defined in module Musa::Series::Operations
Limits serie to maximum number of values.
Stops after N values regardless of source length.
#merge ⇒ MergeSerieOfSeries Originally defined in module Musa::Series::Operations
Merges serie of series into single serie.
Flattens one level: consumes serie where each element is itself a serie, merging them sequentially.
#multiplex(*indexed_series, **hash_series) ⇒ MultiplexSelector Originally defined in module Musa::Series::Operations
Multiplexes values from multiple series based on selector.
Like switch but returns composite values instead of switching.
#proc ⇒ Proc? #proc(&block) ⇒ Extension::SmartProcBinder::SmartProcBinder Originally defined in module Serie::WithSmartBlock
Gets or sets the proc with SmartProcBinder wrapping.
#proc=(block) ⇒ Object Originally defined in module Serie::WithSmartBlock
Sets the proc with SmartProcBinder wrapping.
#process_with(**parameters) {|value, parameters| ... } ⇒ Processor Originally defined in module Musa::Series::Operations
Processes values with parameterized block.
Generic processor passing values and parameters to block.
#prototype ⇒ Serie Also known as: p Originally defined in module Serie::Prototyping
Returns prototype of serie.
- If already prototype, returns self
- If instance, returns original prototype (if available)
- If undefined, raises PrototypingError
#prototype? ⇒ Boolean Originally defined in module Serie::Prototyping
Checks if serie is in prototype state.
#proxy ⇒ Object Originally defined in module Musa::Series::Operations
TODO add test case
#quantize(reference: nil, step: nil, value_attribute: nil, stops: nil, predictive: nil, left_open: nil, right_open: nil) ⇒ RawQuantizer, PredictiveQuantizer Originally defined in module Musa::Series::Operations
Quantizes time-value serie to discrete steps.
Quantization Modes
- Raw: Rounds values to nearest step, interpolates between points
- Predictive: Predicts crossings of quantization boundaries
Applications
- Quantize MIDI controller data to discrete values
- Convert continuous pitch bends to semitones
- Snap timing to grid
- Generate stepped automation curves
- Convert analog input to digital steps
#queued ⇒ QueueSerie Originally defined in module Musa::Series::Operations
Wraps this serie in a queue.
#randomize(random: nil) ⇒ Randomizer Originally defined in module Musa::Series::Operations
Randomizes order of values.
Shuffles values randomly. Requires finite serie.
#remove(block = nil) {|value| ... } ⇒ Remover Originally defined in module Musa::Series::Operations
Removes values matching condition.
Filters out values where block returns true.
#repeat(times = nil, condition: nil) { ... } ⇒ Repeater, InfiniteRepeater Originally defined in module Musa::Series::Operations
Repeats serie multiple times or conditionally.
Three modes:
- times: Repeat exact number of times
- condition: Repeat while condition true
- neither: Infinite repetition
#reverse ⇒ Reverser Originally defined in module Musa::Series::Operations
Reverses order of values.
Consumes entire serie and returns values in reverse order. Requires finite serie.
#select(block = nil) {|value| ... } ⇒ Selector Originally defined in module Musa::Series::Operations
Selects values matching condition.
Keeps only values where block returns true.
#shift(shift) ⇒ Shifter Originally defined in module Musa::Series::Operations
Rotates serie elements circularly.
Performs circular rotation of elements:
- Negative values rotate left (first elements move to end)
- Positive values rotate right (last elements move to beginning)
- Zero performs no rotation
Note: Right rotation (positive values) requires finite series as the entire serie must be loaded into memory for rotation.
#skip(length) ⇒ Skipper Originally defined in module Musa::Series::Operations
Skips first N values.
Discards first length values, returns rest.
#source ⇒ Serie? Originally defined in module Serie::WithSource
Returns the upstream source serie.
#source=(serie) ⇒ Object Originally defined in module Serie::WithSource
Sets the source serie.
#split ⇒ Splitter Originally defined in module Musa::Series::Operations
Serie splitter for decomposing hash/array values into component series.
Splits series of hash or array values into individual component series, enabling independent access to each component.
Splitting Modes
- Hash mode: Split
{pitch: 60, velocity: 96}into separate series for:pitchand:velocity - Array mode: Split
[60, 96]into separate series for indices 0, 1
Component Access
- Hash:
splitter[:pitch],splitter[:velocity] - Array:
splitter[0],splitter[1] - Enumerable:
splitter.each { |component| ... }
Use Cases
- Separate polyphonic voices from single source
- Independent processing of musical parameters
- Extract specific components (pitch, duration, velocity, etc.)
- Multi-track decomposition
#state ⇒ Symbol Originally defined in module Serie::Prototyping
Returns current state of serie.
Attempts to resolve undefined state from sources before returning. State is one of: :prototype, :instance, or :undefined.
#switch(*indexed_series, **hash_series) ⇒ Switcher Originally defined in module Musa::Series::Operations
Switches between multiple series based on selector values.
Uses selector serie to choose which source serie to read from. Selector values can be indices (Integer) or keys (Symbol).
#switch_serie(*indexed_series, **hash_series) ⇒ SwitchFullSerie Originally defined in module Musa::Series::Operations
Switches to entirely different series based on selector.
Changes which serie is being consumed entirely.
#undefined? ⇒ Boolean Originally defined in module Serie::Prototyping
Checks if serie is in undefined state.
#union_timed(*other_timed_series, key: nil, **other_key_timed_series) ⇒ TimedUnionOfArrayOfTimedSeries, TimedUnionOfHashOfTimedSeries Originally defined in module Musa::Series::Operations
Combines this timed serie with others via TIMED_UNION.
Convenience method for unioning series, supporting both array and hash modes. Calls Constructors#TIMED_UNION constructor with appropriate parameters.
Array mode: s1.union_timed(s2, s3)
Hash mode: s1.union_timed(key: :melody, bass: s2, drums: s3)
#with(*with_series, on_restart: nil, isolate_values: nil, **with_key_series) {|main_value, with_values, with_key_values| ... } ⇒ With Also known as: eval Originally defined in module Musa::Series::Operations
Combines multiple series for mapping.
Synchronously iterates multiple series, passing all values to block. Enables multi-voice transformations and combinations.
Parameters
- with_series: Positional series (passed as array to block)
- with_key_series: Named series (passed as keywords to block)
- on_restart: Block called on restart
- isolate_values: Clone values to prevent mutation
Block Parameters
Block receives:
- Main serie value (first argument)
- Positional with_series values (array)
- Keyword with_key_series values (keywords)