Projects

JSyn - modular synthesis API for Java.
JMSL - Java Music Specification Language
PortAudio - cross platform audio I/O API for 'C'

WebAudio Experiments

Requires Chrome browser for support of proposed Web Audio API.

View Oscillator Waveforms

Use an Analyser to see oscillator waveforms.

status messages

Select a waveform: 

Detune Pitch: 


JavaScript code for this example.


// Example showing how to produce a tone using Web Audio API.
var oscillator;
var amp;
var visualizer

        
// Setup some audio nodes and a visualizer.
function initAudio()
{
    if( context )
    {
        oscillator = context.createOscillator();
        fixOscillator(oscillator);
        oscillator.frequency.value = 440;
        
        amp = context.createGainNode();
        amp.gain.value = 0.8;
    
        // Connect ooscillator to amp and the amp to the mixer of the context.
        // This is like connecting cables between jacks on a modular synth.
        oscillator.connect(amp);
        
        amp.connect(context.destination);
        oscillator.start(0);
        
        writeMessageToID( "soundStatus", "<p>Audio initialized.</p>");
        
        visualizer = new AudioVisualizer(512, 400);
        amp.connect(visualizer.analyser);
        visualizer.startAnimation();
    }
}

function setOscillatorType(oscType)
{
    oscillator.type = oscType;
}

function updatePitch(sliderValue)
{
    oscillator.detune.value = ((sliderValue - 50) * 24);
}

// start and stop the sound when moving between tabs of the browser
document.addEventListener('webkitvisibilitychange', function()
    {
        if (document.webkitHidden) {
            oscillator.stop(0);
        } else {
            initAudio();
        }
    } );

// init once the page has finished loading.
window.onload = initAudio;