Class: Scruby::Ugens::MulAdd

Inherits:
Ugen show all
Defined in:
lib/scruby/ugens/operation_ugens.rb

Constant Summary

Constants inherited from Ugen

Ugen::E_RATES, Ugen::RATES, Ugen::VALID_INPUTS

Instance Attribute Summary

Attributes inherited from Ugen

#channels, #index, #inputs, #output_index, #rate, #special_index

Class Method Summary collapse

Methods inherited from Ugen

#==, #encode, #initialize, #muladd, params, synthdef, synthdef=, valid_input?

Constructor Details

This class inherits a constructor from Scruby::Ugens::Ugen

Class Method Details

.new(input, mul, add) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/scruby/ugens/operation_ugens.rb', line 49

def self.new input, mul, add
  no_mul = mul == 1.0
  minus  = mul == -1.0
  return add         if mul == 0
  return input       if no_mul and add == 0
  return input.neg   if minus  and add == 0
  return input * mul if add == 0
  return add - input if minus
  return input + add if no_mul
  super input.rate, input, mul, add
end