Module: Rampi::Helpers
- Included in:
- DSL
- Defined in:
- lib/rampi/helpers.rb
Instance Method Summary collapse
-
#expe(value, len = 16) ⇒ Object
Exponential envelope.
-
#invexpe(value, len = 16) ⇒ Object
Inverse exponential envelope.
-
#len2dur(note_length) ⇒ Object
Converts
note_length
to ramp duration. -
#step(value, len = 16) ⇒ Object
Step counter By default, len is 1000 = semiquaver.
Instance Method Details
#expe(value, len = 16) ⇒ Object
Exponential envelope
13 14 15 16 |
# File 'lib/rampi/helpers.rb', line 13 def expe(value, len=16) dur = len2dur(len) 1 - pow((v1 % dur) / dur, value) end |
#invexpe(value, len = 16) ⇒ Object
Inverse exponential envelope
19 20 21 22 |
# File 'lib/rampi/helpers.rb', line 19 def invexpe(value, len=16) dur = len2dur(len) pow((v1 % dur) / dur, value) end |
#len2dur(note_length) ⇒ Object
Converts note_length
to ramp duration
29 30 31 |
# File 'lib/rampi/helpers.rb', line 29 def len2dur(note_length) 2 * 8000 / note_length end |
#step(value, len = 16) ⇒ Object
Step counter By default, len is 1000 = semiquaver
8 9 10 |
# File 'lib/rampi/helpers.rb', line 8 def step(value, len=16) (v1 / len2dur(len)) % value end |