Class: Ramekin::Fades

Inherits:
Processor show all
Defined in:
lib/ramekin/fades.rb

Constant Summary collapse

SUPPORTED =
[
  :y, :rely,
  :v, :relv,
  :p,
  :w,
  :t,
]

Instance Attribute Summary

Attributes inherited from Processor

#stream

Instance Method Summary collapse

Methods inherited from Processor

#buffer, call, compose, #each, #flush!, #next!, #peek

Instance Method Details

#call(&b) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ramekin/fades.rb', line 11

def call(&b)
  prev = nil
  each do |el|
    if NoteEvent === el && el.note.type == :fade
      if prev.nil? || !(Token === prev) || !SUPPORTED.include?(prev.type)
        error! 'invalid fade: must follow pan, volume, global volume, tempo, or #echo:vol commands'
      end

      prev.meta[:fade] = el

      prev = nil
    else
      prev = el
      yield el
    end
  end
end