Class: Musicality::ValueComputer

Inherits:
Function::Piecewise show all
Defined in:
lib/musicality/notation/util/value_computer.rb

Overview

Given a start value, and value changes, compute the value at any offset.

Instance Attribute Summary collapse

Attributes inherited from Function::Piecewise

#pieces

Attributes inherited from Function

#domain

Instance Method Summary collapse

Methods inherited from Function::Piecewise

#==, #add_piece, #at, #domain_include?

Methods inherited from Function

#==, #at, #sample, transform_domains

Constructor Details

#initialize(start_value, value_changes = {}) ⇒ ValueComputer

Returns a new instance of ValueComputer.



6
7
8
9
10
11
12
13
14
# File 'lib/musicality/notation/util/value_computer.rb', line 6

def initialize start_value, value_changes = {}
  super()
  set_default_value(start_value)
  if value_changes.any?
    value_changes.sort.each do |offset,change|
      add_change(offset, change)
    end
  end
end

Instance Attribute Details

#piecewise_functionObject (readonly)

Returns the value of attribute piecewise_function.



5
6
7
# File 'lib/musicality/notation/util/value_computer.rb', line 5

def piecewise_function
  @piecewise_function
end