Class: ToneSeq
Overview
a sequence of TonePart that will play sequentially. These are highest level sounds without timing.
Instance Attribute Summary collapse
-
#toneparts ⇒ Object
Array of TonePart.
Instance Method Summary collapse
- #fade ⇒ Object
-
#frames ⇒ Object
return the total frames of all toneparts combined.
-
#frames=(val) ⇒ Object
set the frames of each tonepart to val.
-
#initialize ⇒ ToneSeq
constructor
A new instance of ToneSeq.
-
#len=(set) ⇒ Object
set length of all toneparts to equally add to set when combined.
-
#make(num) ⇒ Object
add num TonePart to self, with it’s max allowable frames as #frames.
-
#render(parent_hit_index = nil) ⇒ Object
compile all data on all #toneparts, then write it to file(s).
- #tonepart(i = 0) ⇒ Object
Constructor Details
Instance Attribute Details
#toneparts ⇒ Object
Array of TonePart
4 5 6 |
# File 'lib/tone_seq.rb', line 4 def toneparts @toneparts end |
Instance Method Details
#fade ⇒ Object
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 |
#frames ⇒ Object
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 |