JSXGraph and sound

From JSXGraph Wiki
Revision as of 11:32, 12 January 2015 by A WASSERMANN (talk | contribs)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

JSXGraph can be used together with the excellent JavaScript audio library gibberish.

The underlying JavaScript code

Additionally embed gibberish.js:

<script type="text/javascript" src="http://www.charlie-roberts.com/gibberish/build/gibberish.js"></script>
Gibberish.init();
Gibberish.Time.export();
Gibberish.Binops.export();

var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-1,10,10,-10], axis:false});

var sinewave = new Gibberish.Sine( 440, .25 ).connect();

var slide = board.create('slider', [[2, 8], [8, 8], [100, 440, 1000]]);
var sinecurve = board.create('functiongraph', [function(x) { return 5 * Math.sin((sinewave.frequency / 200.0) * 2* Math.PI * x); }]);

board.on('update', function() {
    sinewave.frequency = slide.Value();
});