Class: SMF::VelComp

Inherits:
Object
  • Object
show all
Defined in:
lib/smf/toy/velcomp.rb

Instance Method Summary collapse

Constructor Details

#initializeVelComp

Returns a new instance of VelComp.



10
11
12
13
14
# File 'lib/smf/toy/velcomp.rb', line 10

def initialize
  self.gain = 0
  self.thresh = 80
  self.ratio = 0.9
end

Instance Method Details

#gain=(v) ⇒ Object



25
# File 'lib/smf/toy/velcomp.rb', line 25

def gain=(v) @gain = v end

#ratio=(v) ⇒ Object



27
# File 'lib/smf/toy/velcomp.rb', line 27

def ratio=(v) @ratio = v; @spline = nil end

#thresh=(v) ⇒ Object



26
# File 'lib/smf/toy/velcomp.rb', line 26

def thresh=(v) @thresh = v; @spline = nil end

#velcomp(ev) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/smf/toy/velcomp.rb', line 29

def velcomp(ev)
  init unless @spline
  v = ev.vel + @gain
  v = 127 if v > 127
  v = 1   if v < 1
  v2 = @spline.eval(v)
  v2 = 127 if v > 127
  v2 = 1   if v < 1
  ev.vel = v2.round
end