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.
- #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, t2 = 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
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.
59 60 61 62 63 64 65 66 67 |
# File 'lib/tone_part.rb', line 59 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 |
#frames=(val) ⇒ Object
31 32 33 34 |
# File 'lib/tone_part.rb', line 31 def frames= val tone(0).frames = val tone(1).frames = val end |
#freq ⇒ Object
get main freq
37 38 39 |
# File 'lib/tone_part.rb', line 37 def freq tone.freq.start end |
#freq=(val) ⇒ Object
set freq of start and final to val
46 47 48 49 |
# File 'lib/tone_part.rb', line 46 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
53 54 55 56 |
# File 'lib/tone_part.rb', line 53 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
72 73 74 75 76 77 78 79 80 81 82 83 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 |
# File 'lib/tone_part.rb', line 72 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 |