Class: TonePart
Overview
one or two Tone that can be morphed between eachother
Instance Attribute Summary collapse
-
#max_frames ⇒ Object
Returns the value of attribute max_frames.
-
#tone_count ⇒ Object
Returns the value of attribute tone_count.
-
#tone_single ⇒ Object
Returns the value of attribute tone_single.
-
#tones ⇒ Object
Fader of Tone.
Instance Method Summary collapse
-
#amp_mult(factor) ⇒ Object
multiply all amplitudes (Tone.amp) by factor.
-
#do_all {|(tone(0))| ... } ⇒ Object
perform the block on all tones.
- #frames=(val) ⇒ Object
-
#freq ⇒ Object
get main freq.
-
#freq=(val) ⇒ Object
set freq of start and final to val.
-
#initialize(m = 0, t1 = Tone.new) ⇒ TonePart
constructor
A new instance of TonePart.
-
#note ⇒ Object
get main note.
-
#note=(val) ⇒ Object
- set freq of start and final to Note.freq val
-
the note to call freq on.
-
#out(into) ⇒ Object
return tone with mixed settings of tones#start with tones#final.
- #tone(i = 0) ⇒ Object
- #two_tones ⇒ Object
Constructor Details
Instance Attribute Details
#max_frames ⇒ Object
Returns the value of attribute max_frames.
5 6 7 |
# File 'lib/tone_part.rb', line 5 def max_frames @max_frames end |
#tone_count ⇒ Object
Returns the value of attribute tone_count.
7 8 9 |
# File 'lib/tone_part.rb', line 7 def tone_count @tone_count end |
#tone_single ⇒ Object
Returns the value of attribute tone_single.
6 7 8 |
# File 'lib/tone_part.rb', line 6 def tone_single @tone_single end |
Instance Method Details
#amp_mult(factor) ⇒ Object
multiply all amplitudes (Tone.amp) by factor.
65 66 67 68 69 70 71 72 73 |
# File 'lib/tone_part.rb', line 65 def amp_mult(factor) tone(0).amp.start *= factor #puts "amp: #{tone.tones.start.amp.start}" tone(0).amp.final *= factor if tone_count > 1 tone(1).amp.start *= factor tone(1).amp.final *= factor end end |
#do_all {|(tone(0))| ... } ⇒ Object
perform the block on all tones
76 77 78 79 |
# File 'lib/tone_part.rb', line 76 def do_all yield (tone(0)) yield (tone(1)) end |
#frames=(val) ⇒ Object
37 38 39 40 |
# File 'lib/tone_part.rb', line 37 def frames= val tone(0).frames = val tone(1).frames = val end |
#freq ⇒ Object
get main freq
43 44 45 |
# File 'lib/tone_part.rb', line 43 def freq tone.freq.start end |
#freq=(val) ⇒ Object
set freq of start and final to val
52 53 54 55 |
# File 'lib/tone_part.rb', line 52 def freq= val tone(0).freq.start = val tone(1).freq.start = val end |
#note=(val) ⇒ Object
set freq of start and final to Note.freq
- val
-
the note to call freq on
59 60 61 62 |
# File 'lib/tone_part.rb', line 59 def note= val tone(0).freq.start = val.freq tone(1).freq.start = val.freq end |
#out(into) ⇒ Object
return tone with mixed settings of tones#start with tones#final.
- into
-
how much of the final tone is mixed in. 0 is none. Range: 0 to 1
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/tone_part.rb', line 84 def out(into) return tone_single if tone_count == 1 out = tones.start.deep_copy #wave range = tones.final.wave.detail.start - tones.start.wave.detail.start out.wave.detail.start += range*into range = tones.final.wave.detail.final - tones.start.wave.detail.final out.wave.detail.final += range*into range = tones.final.wave.saturations.start - tones.start.wave.saturations.start out.wave.saturations.start += range*into range = tones.final.wave.saturations.final - tones.start.wave.saturations.final out.wave.saturations.final += range*into #frames range = tones.final.frames - tones.start.frames out.frames += range*into # puts "frames range #{out.frames}" #freq range = tones.final.freq.start - tones.start.freq.start out.freq.start += range*into range = tones.final.freq.final - tones.start.freq.final out.freq.final += range*into range = tones.final.freq.exp_no_nil - tones.start.freq.exp_no_nil out.freq.exp = out.freq.exp_no_nil + range*into #amp range = tones.final.amp.start - tones.start.amp.start out.amp.start += range*into range = tones.final.amp.final - tones.start.amp.final out.amp.final += range*into range = tones.final.amp.exp_no_nil - tones.start.amp.exp_no_nil out.amp.exp = out.amp.exp_no_nil + range*into out end |
#tone(i = 0) ⇒ Object
16 17 18 19 |
# File 'lib/tone_part.rb', line 16 def tone i=0 return tone_single if tone_count == 1 i==1 ? @tones.final : @tones.start end |
#two_tones ⇒ Object
21 22 23 24 25 |
# File 'lib/tone_part.rb', line 21 def two_tones self.tone_count = 2 tones.start = tone_single tones.final = tone_single.deep_copy end |