Timbre.js

JavaScript Library for Objective Sound Programming
system requirements: Chrome 14- or Firefox 4-

PhaseOscillator

Linear interpolating wavetable lookup oscillator with phase input

Constructor

oscx = T("oscx", wave="sin", phase=0, mul=1, add=0);

// wave  [String / Function / Float32Array]
// phase [Object] Phase
// mul   [Number] Multiply the output  (default is 1)
// add   [Number]   and add the output (default is 0)

oscx.set("phase", T("phasor", 440)).play();
        

Properties

oscx.wave   // [String / Function / Float32Array]
oscx.phase  // [Object] Phase
oscx.mul    // [Number] Output will be multiplied by this value
oscx.add    // [Number]    and will be added to the output
oscx.fb     // [Number] Feedback
        

Methods

// Reset phase          
oscx.bang(); // == oscx.phase.bang();
        

Events

        

Example: Feedback

T("sinx", T("phasor", 440)).set("fb", 0.25).play();
        

Example: FM-Synth

freq = T("phasor", 440);
op1 = T("*", T("oscx", freq),              // modulator
             T("adsr", 100, 4900));
op2 = T("*", T("oscx", T("+", freq, op1)), // carrier
             T("adsr", 0, 10000, 0.6));

synth = op2;
synth.onplay = function() {
    op1.args[1].bang();
    op2.args[1].bang();
};
synth.onbang = function() {
    op1.args[1].bang();
    op2.args[1].bang();
};
synth.play();
        

See Also:

T("osc") T("phasor") FM Synthesis