Commit 11ad69bf authored by Daniel Clarke's avatar Daniel Clarke

Fixed global init problem and did stuff I can't remember

parent 0c43df36
......@@ -68,13 +68,14 @@ audio.play = function(){
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
var audio = new maximJs.maxiAudio();
// initialise audio
maximJs.maxiAudio.init();
audio.init();
var mySine = new maximJs.maxiOsc();
maximJs.maxiAudio.play = function(){
output = mySine.sinewave(440);
audio.play = function(){
this.output = mySine.sinewave(440);
}
</pre>
</body>
......
......@@ -43,69 +43,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<script src="../maxiLib.js"></script>
<!-- <script src="../maxi_webAudio.js"></script> -->
</head>
<body>
<h1> Two Tones </h1>
<canvas id="myCanvas" width="700" height="700" style="border:1px solid #c3c3c3;">
<!-- It's a good idea to warn people whose browsers don't support the tag -->
Your browser does not support the canvas element.
</canvas>
<script type="text/javascript">
var context;
window.onload = setup;
function setup(){
// fft.setup(fftSize, 512, 256);
// ifft.setup(fftSize, 512, 256);
// mfcc.setup(512, 42, 13, 20, 20000, sampleRate);
// This gets the window in the browser
var canvas=document.getElementById("myCanvas");
// This creates a 2d drawing context in it.
context=canvas.getContext("2d");
//finally, we return setInterval, which wants a function to call,
//and a period in milliseconds to wait between calling it.
return setInterval(draw, 40);
}
//The stuff inside the script tag is very similar to processing code.
function draw() {
//This is basically the same as any other 2D processing draw routine.
//clear the screen
context.clearRect(0,0,700,700);
context.beginPath();
context.fillStyle="#FF0000";
context.rect(0,0,50,50);
context.fill();
// context.stroke();
context.closePath();
}
<!-- Our javascript code -->
<script type="text/javascript">
var audio = new maximJs.maxiAudio();
// initialise audio
maximJs.maxiAudio.init();
audio.init();
var mySine = new maximJs.maxiOsc();
var myOtherSine = new maximJs.maxiOsc();
maximJs.maxiAudio.play = function(){
audio.play = function(){
// these two sines will beat together. They're now a bit too loud though..
output = mySine.sinewave(440) + myOtherSine.sinewave(441);
this.output = mySine.sinewave(440) + myOtherSine.sinewave(441);
}
</script>
</head>
<body>
<h1> Two Tones </h1>
<p>
These sines are taking a beating...
</p>
......
......@@ -151,7 +151,7 @@ maximJs.maxiTools.prototype.getArrayAsVectorDbl = function(arrayIn){
// ------------------------------------------------
maximJs.maxiAudio = function() {
this.numChannels = 2;
this.output = 0;
var output = 0;
this.context = null;
this.source = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment