Class: Synthesizer::OscillatorSource::Base
- Inherits:
-
Object
- Object
- Synthesizer::OscillatorSource::Base
- Defined in:
- lib/synthesizer/oscillator_source/base.rb
Defined Under Namespace
Classes: Context
Instance Method Summary collapse
- #generate_context(soundinfo, note_perform, init_phase) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #next(context, rate, sym, sync, l_gain, r_gain) ⇒ Object
- #sample(context, phase) ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
4 5 |
# File 'lib/synthesizer/oscillator_source/base.rb', line 4 def initialize end |
Instance Method Details
#generate_context(soundinfo, note_perform, init_phase) ⇒ Object
31 32 33 |
# File 'lib/synthesizer/oscillator_source/base.rb', line 31 def generate_context(soundinfo, note_perform, init_phase) Context.new(soundinfo, note_perform, init_phase) end |
#next(context, rate, sym, sync, l_gain, r_gain) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/synthesizer/oscillator_source/base.rb', line 7 def next(context, rate, sym, sync, l_gain, r_gain) soundinfo = context.soundinfo channels = context.channels window_size = context.window_size pos = context.pos hz = rate.freq(soundinfo) dst = window_size.times.map {|i| sample(context, pos.next(hz, sym, sync)) } dst = Vdsp::DoubleArray.create(dst) case channels when 1 Buffer.new(dst * l_gain) when 2 Buffer.new(dst * l_gain, dst * r_gain) end end |
#sample(context, phase) ⇒ Object
27 28 29 |
# File 'lib/synthesizer/oscillator_source/base.rb', line 27 def sample(context, phase) raise Error, "not implemented abstruct method: #{self.class.name}.sample(context, phase)" end |