Class: Scruby::Audio::Ugens::OperationUgens::MulAdd

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

Constant Summary

Constants inherited from Ugen

Ugen::E_RATES, Ugen::RATES

Constants included from UgenOperations

UgenOperations::BINARY, UgenOperations::OP_SYMBOLS, UgenOperations::UNARY

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, instantiate, #muladd, synthdef, synthdef=, #to_s, #ugen?

Methods included from UgenOperations

included, #valid_ugen_input?

Constructor Details

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

Class Method Details

.new(input, mul, add) ⇒ Object



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

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