Class: Dist
Overview
a consecutave sequence of morphable tones (TonePart) of varying lengths, and rate of morphs, played without gaps.
Instance Attribute Summary collapse
-
#dist ⇒ Object
Returns the value of attribute dist.
Instance Method Summary collapse
-
#[](i) ⇒ Object
get a Dist child.
-
#branches ⇒ Object
count children (Dists only).
-
#clear_hits ⇒ Object
delete all hits.
-
#clear_snd ⇒ Object
delete all Snd attached to this Dist.
-
#del(todel) ⇒ Object
delete another Dist.
-
#first_born ⇒ Object
get first child.
-
#hits ⇒ Object
getter for HitSq.
-
#initialize ⇒ Dist
constructor
will have a defult hit at 0 if it has a sound and no hits have been made.
-
#last_born ⇒ Object
get last child.
-
#length ⇒ Object
get the total length in frames.
-
#length=(set) ⇒ Object
set the total length in frames.
-
#make(num = 1, i = 0) ⇒ Object
add num TonePart to Snd at i’s ToneSeq, with my #length as max.
-
#persist_hits ⇒ Object
(internal use only) copy our hits down to the underlining object.
-
#snd(i = 0) ⇒ Object
getter for Snd.
-
#snd_each ⇒ Object
run on all sounds.
-
#sounds ⇒ Object
count sounds.
Methods inherited from Api
Constructor Details
Instance Attribute Details
#dist ⇒ Object
Returns the value of attribute dist.
4 5 6 |
# File 'lib/api/dist.rb', line 4 def dist @dist end |
Instance Method Details
#[](i) ⇒ Object
get a Dist child
41 42 43 44 45 46 47 48 49 |
# File 'lib/api/dist.rb', line 41 def [] i child=@dist.get_children[i] raise "This Dist has no child at index #{i}. " + "It has #{branches} children." if child.nil? d=Dist.new d.dist=child d.make_hits d end |
#branches ⇒ Object
count children (Dists only)
67 68 69 |
# File 'lib/api/dist.rb', line 67 def branches @dist.get_children.count end |
#clear_hits ⇒ Object
delete all hits
35 36 37 38 39 |
# File 'lib/api/dist.rb', line 35 def clear_hits @hits.hits = [] persist_hits self end |
#clear_snd ⇒ Object
delete all Snd attached to this Dist
93 94 95 96 |
# File 'lib/api/dist.rb', line 93 def clear_snd @dist.tss = [] self end |
#del(todel) ⇒ Object
delete another Dist
20 21 22 23 |
# File 'lib/api/dist.rb', line 20 def del todel @dist.snd.delete todel.dist self end |
#first_born ⇒ Object
get first child
59 60 61 62 63 64 65 |
# File 'lib/api/dist.rb', line 59 def first_born child=@dist.get_children.first d=Dist.new d.dist=child d.make_hits d end |
#hits ⇒ Object
getter for HitSq. Will persist any changes you make to it.
71 72 73 |
# File 'lib/api/dist.rb', line 71 def hits @hits end |
#last_born ⇒ Object
get last child
51 52 53 54 55 56 57 |
# File 'lib/api/dist.rb', line 51 def last_born child=@dist.get_children.last d=Dist.new d.dist=child d.make_hits d end |
#length ⇒ Object
get the total length in frames
31 32 33 |
# File 'lib/api/dist.rb', line 31 def length @dist.len end |
#length=(set) ⇒ Object
set the total length in frames
25 26 27 28 29 |
# File 'lib/api/dist.rb', line 25 def length= set @dist.len = set @dist.tss.each {|tss| tss.len = set } self end |
#make(num = 1, i = 0) ⇒ Object
add num TonePart to Snd at i’s ToneSeq, with my #length as max.
15 16 17 |
# File 'lib/api/dist.rb', line 15 def make(num=1, i=0) snd(i).toneseq.make(num) end |
#persist_hits ⇒ Object
(internal use only) copy our hits down to the underlining object
109 110 111 112 113 |
# File 'lib/api/dist.rb', line 109 def persist_hits @dist.hits = hits.hits @dist.hits = [0.0] if hits.hits.count == 0 self end |
#snd(i = 0) ⇒ Object
getter for Snd. Will persist any changes you make to it.
75 76 77 78 79 80 81 82 |
# File 'lib/api/dist.rb', line 75 def snd i=0 snd=Snd.new snd.add_parent self new=@dist.tss[i] raise "Dist has no sound at index #{i}. It has #{sounds} sounds." if new.nil? snd<< new snd end |
#snd_each ⇒ Object
run on all sounds
98 99 100 101 102 103 |
# File 'lib/api/dist.rb', line 98 def snd_each sounds.times {|i| yield(snd i) } self end |
#sounds ⇒ Object
count sounds
105 106 107 |
# File 'lib/api/dist.rb', line 105 def sounds @dist.tss.count end |