Class: Chaussettes::EffectChain

Inherits:
Object
  • Object
show all
Defined in:
lib/chaussettes/effect_chain.rb

Overview

A chain of effects to apply

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEffectChain

Returns a new instance of EffectChain.



12
13
14
# File 'lib/chaussettes/effect_chain.rb', line 12

def initialize
  @commands = []
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



10
11
12
# File 'lib/chaussettes/effect_chain.rb', line 10

def commands
  @commands
end

Instance Method Details

#fade(in_len, stop_at = nil, out_len = nil, type: nil) ⇒ Object



16
17
18
19
20
# File 'lib/chaussettes/effect_chain.rb', line 16

def fade(in_len, stop_at = nil, out_len = nil, type: nil)
  effect = Effect::Fade.new(in_len, stop_at, out_len, type: type)
  @commands.concat(effect.commands)
  self
end

#gain(db, *opts) ⇒ Object



22
23
24
25
26
# File 'lib/chaussettes/effect_chain.rb', line 22

def gain(db, *opts)
  effect = Effect::Gain.new(db, *opts)
  @commands.concat(effect.commands)
  self
end

#newfileObject



28
29
30
31
# File 'lib/chaussettes/effect_chain.rb', line 28

def newfile
  @commands << 'newfile'
  self
end

#pad(length, position = nil) ⇒ Object



33
34
35
36
37
# File 'lib/chaussettes/effect_chain.rb', line 33

def pad(length, position = nil)
  length = "#{length}@#{position}" if position
  @commands << 'pad' << length
  self
end

#restartObject



39
40
41
42
# File 'lib/chaussettes/effect_chain.rb', line 39

def restart
  @commands << 'restart'
  self
end

#synth(length = nil, type = nil, &block) ⇒ Object



44
45
46
47
48
# File 'lib/chaussettes/effect_chain.rb', line 44

def synth(length = nil, type = nil, &block)
  effect = Effect::Synth.new(length, type, &block)
  @commands.concat(effect.commands)
  self
end

#trim(*positions) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/chaussettes/effect_chain.rb', line 50

def trim(*positions)
  if positions.empty?
    raise ArgumentError, 'you must specify at least one position for trim'
  end

  @commands << 'trim'
  @commands.concat(positions)
  self
end

#vol(gain, type: nil, limitergain: nil) ⇒ Object



60
61
62
63
64
# File 'lib/chaussettes/effect_chain.rb', line 60

def vol(gain, type: nil, limitergain: nil)
  effect = Effect::Vol.new(gain, type: type, limitergain: limitergain)
  @commands.concat(effect.commands)
  self
end