class SynthBlocks::Mod::Envelope
Simple Attack / Release envelope
Attributes
attack[RW]
attack time in seconds
release[RW]
release time in seconds
Public Class Methods
new(attack,release)
click to toggle source
create new attack/release envelope
# File lib/synth_blocks/mod/envelope.rb, line 15 def initialize(attack,release) @attack = attack @release = release end
Public Instance Methods
run(t, a=@attack, r=@release)
click to toggle source
run the attack/release envelope You can override attack and decay
# File lib/synth_blocks/mod/envelope.rb, line 22 def run(t, a=@attack, r=@release) @a = a @r = r if t > @a + @r return 0 elsif t > @a #release return 1 - ((1 / @r) * (t - @a)) else # attack return 1 / @a * t end end