Class: ToneSeq

Inherits:
Object show all
Defined in:
lib/tone_seq.rb

Overview

a sequence of TonePart that will play sequentially. These are highest level sounds without timing.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeToneSeq

Returns a new instance of ToneSeq.



5
6
7
8
# File 'lib/tone_seq.rb', line 5

def initialize()
  @toneparts = []
  make(1)
end

Instance Attribute Details

#tonepartsObject

Array of TonePart



4
5
6
# File 'lib/tone_seq.rb', line 4

def toneparts
  @toneparts
end

Instance Method Details

#fadeObject



22
23
24
25
26
27
28
# File 'lib/tone_seq.rb', line 22

def fade
  @toneparts.each {|tp| 
    tp.tones.start.fade
    tp.tones.final.fade
    }
  self
end

#framesObject

return the total frames of all toneparts combined.



10
11
12
13
14
# File 'lib/tone_seq.rb', line 10

def frames
  total=0
  toneparts.each {|tp| total+=tp.tone.frames}
  total
end

#frames=(val) ⇒ Object

set the frames of each tonepart to val.



19
20
21
# File 'lib/tone_seq.rb', line 19

def frames= val
  @toneparts.each {|tp| tp.frames = val}
end

#len=(set) ⇒ Object

set length of all toneparts to equally add to set when combined.



30
31
32
33
34
35
# File 'lib/tone_seq.rb', line 30

def len= set
  @toneparts.each {|tp|
    tp.max_frames = set / toneparts.count
    tp.frames = set / toneparts.count
  }
end

#make(num) ⇒ Object

add num TonePart to self, with it’s max allowable frames as #frames.



37
38
39
40
41
# File 'lib/tone_seq.rb', line 37

def make(num)
#  puts "ToneSeq: making #{num} parts in tone"
  num.times { self.toneparts.push TonePart.new }
  self.len= (frames.to_f).round
end

#render(parent_hit_index = nil) ⇒ Object

compile all data on all #toneparts, then write it to file(s)



44
45
46
47
48
49
50
51
52
# File 'lib/tone_seq.rb', line 44

def render(parent_hit_index=nil)
  data = WaveData.new
  toneparts.each do |tp|
    data + tp.out(parent_hit_index).out
  end
  files= FileList.new
  files.write data
  files
end

#tonepart(i = 0) ⇒ Object



15
16
17
# File 'lib/tone_seq.rb', line 15

def tonepart i=0
  @toneparts[i]
end