window.onload = function() {

    var canvas = document.getElementById('can');
    var canvasContext = canvas.getContext('2d');
    var settings = new Settings();
    var dataSource = new DataSource(settings.seed);
    var audioSource = new AudioSource();

    var pane = new Pane(canvas, settings);

    function startRandomAnimation() {

        console.log('starting random Animation');

        $('div#panel').hide();
        update();
    }

    function update() {

        requestAnimationFrame(update);
        pane.nextPixel(dataSource.getRandom());
    }

    function getAudioData() {

        audioSource.play();
        var data = audioSource.getByteFrequencyData();
        console.log(data);
    }

    $('div#randomAnimation').click(function() {
        startRandomAnimation();
    });

    $('div#playsound').click(function() {

        var interval = setInterval(function() {
            getAudioData();
        }, 1000 / 6);
    });
}
