Commit 3c1c0fcb authored by Dr-Dan's avatar Dr-Dan

examples mostly fixed to work with changes to maxiAudio

parent 5c9512cd
...@@ -33330,14 +33330,14 @@ maximJs.maxiArray.prototype.clear = (function(useSq) { ...@@ -33330,14 +33330,14 @@ maximJs.maxiArray.prototype.clear = (function(useSq) {
this.length = 0; this.length = 0;
}); });
maximJs.maxiTools = (function() {}); maximJs.maxiTools = (function() {});
maximJs.maxiTools.prototype.arrayOfObj = (function(obj, num) { maximJs.maxiTools.arrayOfObj = (function(obj, num) {
var array = []; var array = [];
for (var i = 0; i < num; i++) { for (var i = 0; i < num; i++) {
array.push(new obj); array.push(new obj);
} }
return array; return array;
}); });
maximJs.maxiTools.prototype.getArrayAsVectorDbl = (function(arrayIn) { maximJs.maxiTools.getArrayAsVectorDbl = (function(arrayIn) {
var vecOut = new Module.VectorDouble; var vecOut = new Module.VectorDouble;
for (var i = 0; i < arrayIn.length; i++) { for (var i = 0; i < arrayIn.length; i++) {
vecOut.push_back(arrayIn[i]); vecOut.push_back(arrayIn[i]);
...@@ -33354,7 +33354,7 @@ maximJs.maxiAudio = (function() { ...@@ -33354,7 +33354,7 @@ maximJs.maxiAudio = (function() {
this.initDone = false; this.initDone = false;
}); });
maximJs.maxiAudio.play = (function() {}); maximJs.maxiAudio.play = (function() {});
maximJs.maxiAudio.prototype.setup = (function() { maximJs.maxiAudio.setup = (function() {
console.log("non-overrided setup"); console.log("non-overrided setup");
}); });
maximJs.maxiAudio.prototype.getNumChannels = (function() { maximJs.maxiAudio.prototype.getNumChannels = (function() {
...@@ -33375,22 +33375,6 @@ maximJs.maxiAudio.prototype.outputIsArray = (function(isArray) { ...@@ -33375,22 +33375,6 @@ maximJs.maxiAudio.prototype.outputIsArray = (function(isArray) {
this.output = 0; this.output = 0;
} }
}); });
maximJs.maxiAudio.prototype.process = (function(event) {
var numChannels = event.outputBuffer.numberOfChannels;
var outputLength = event.outputBuffer.getChannelData(0).length;
for (var i = 0; i < outputLength; ++i) {
this.play();
if (self.output instanceof Array) {
for (var channel = 0; channel < numChannels; channel++) {
event.outputBuffer.getChannelData(channel)[i] = this.output[channel];
}
} else {
for (var channel = 0; channel < numChannels; channel++) {
event.outputBuffer.getChannelData(channel)[i] = this.output;
}
}
}
}).bind(this);
maximJs.maxiAudio.prototype.init = (function() { maximJs.maxiAudio.prototype.init = (function() {
this.context = new (window.AudioContext || window.webkitAudioContext); this.context = new (window.AudioContext || window.webkitAudioContext);
this.source = this.context.createBufferSource(); this.source = this.context.createBufferSource();
...@@ -33400,7 +33384,7 @@ maximJs.maxiAudio.prototype.init = (function() { ...@@ -33400,7 +33384,7 @@ maximJs.maxiAudio.prototype.init = (function() {
var outputLength = event.outputBuffer.getChannelData(0).length; var outputLength = event.outputBuffer.getChannelData(0).length;
for (var i = 0; i < outputLength; ++i) { for (var i = 0; i < outputLength; ++i) {
this.play(); this.play();
if (self.output instanceof Array) { if (this.output instanceof Array) {
for (var channel = 0; channel < numChannels; channel++) { for (var channel = 0; channel < numChannels; channel++) {
event.outputBuffer.getChannelData(channel)[i] = this.output[channel]; event.outputBuffer.getChannelData(channel)[i] = this.output[channel];
} }
...@@ -44,7 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -44,7 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code --> <!-- Our javascript code -->
<script type="text/javascript"> <script type="text/javascript">
maximJs.maxiAudio.init(); var audio = new maximJs.maxiAudio();
audio.init();
var myCounter = new maximJs.maxiOsc(); //these oscillators will help us count and play sound var myCounter = new maximJs.maxiOsc(); //these oscillators will help us count and play sound
var mySwitchableOsc = new maximJs.maxiOsc();// var mySwitchableOsc = new maximJs.maxiOsc();//
...@@ -64,7 +65,7 @@ myEnvelope.setSustain(1); ...@@ -64,7 +65,7 @@ myEnvelope.setSustain(1);
myEnvelope.setRelease(1000); myEnvelope.setRelease(1000);
maximJs.maxiAudio.play = function(){ audio.play = function(){
myCurrentVolume=myEnvelope.adsr(1.,myEnvelope.trigger); myCurrentVolume=myEnvelope.adsr(1.,myEnvelope.trigger);
...@@ -85,7 +86,7 @@ maximJs.maxiAudio.play = function(){ ...@@ -85,7 +86,7 @@ maximJs.maxiAudio.play = function(){
// The last input is the resonance. // The last input is the resonance.
myFilteredOutput=myFilter.lores(myOscOutput,myCurrentVolume*1000,10); myFilteredOutput=myFilter.lores(myOscOutput,myCurrentVolume*1000,10);
output=myFilteredOutput;//left speaker this.output=myFilteredOutput;//left speaker
} }
......
...@@ -43,9 +43,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -43,9 +43,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code --> <!-- Our javascript code -->
<script type="text/javascript"> <script type="text/javascript">
maximJs.maxiAudio.init(); var audio = new maximJs.maxiAudio();
audio.init();
// change output to an array // change output to an array
maximJs.maxiAudio.outputIsArray(true, 2); audio.outputIsArray(true, 2);
var myOsc = new maximJs.maxiOsc(); var myOsc = new maximJs.maxiOsc();
var myAutoPanner = new maximJs.maxiOsc(); var myAutoPanner = new maximJs.maxiOsc();
...@@ -54,10 +55,10 @@ var myOutputs = new maximJs.maxiMix();//this is the stereo mixer channel. ...@@ -54,10 +55,10 @@ var myOutputs = new maximJs.maxiMix();//this is the stereo mixer channel.
maximJs.maxiAudio.play = function(){ audio.play = function(){
myOutputs.stereo(myOsc.noise(),myStereoOutput,(myAutoPanner.sinewave(1)+1)/2);//Stereo, Quad or 8 Channel. Specify the input to be mixed, the output[numberofchannels], and the pan (0-1,equal power). myOutputs.stereo(myOsc.noise(),myStereoOutput,(myAutoPanner.sinewave(1)+1)/2);//Stereo, Quad or 8 Channel. Specify the input to be mixed, the output[numberofchannels], and the pan (0-1,equal power).
output[0]=myStereoOutput.get(0);//When working with mixing, you need to specify the outputs explicitly this.output[0]=myStereoOutput.get(0);//When working with mixing, you need to specify the outputs explicitly
output[1]=myStereoOutput.get(1);// this.output[1]=myStereoOutput.get(1);//
} }
</script> </script>
...@@ -73,24 +74,23 @@ maximJs.maxiAudio.play = function(){ ...@@ -73,24 +74,23 @@ maximJs.maxiAudio.play = function(){
</p> </p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" > <pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
var myOsc = new maximJs.maxiOsc(); var audio = new maximJs.maxiAudio();
var myAutoPanner = new maximJs.maxiOsc(); audio.init();
var myStereoOutput = GetArrayAsVectorDbl([0,0]); // change output to an array
var myOutputs = new maximJs.maxiMix();//this is the stereo mixer channel. audio.outputIsArray(true, 2);
var myOsc = new maximJs.maxiOsc();
var myAutoPanner = new maximJs.maxiOsc();
var myStereoOutput = maximJs.maxiTools.getArrayAsVectorDbl([0,0]);
var myOutputs = new maximJs.maxiMix();//this is the stereo mixer channel.
function setup(){
// change output to an array
// setNumOutputChannels(2);
OutputIsArray(true, 2);
}
maximJs.maxiAudio.play = function(){ audio.play = function(){
myOutputs.stereo(myOsc.noise(),myStereoOutput,(myAutoPanner.sinewave(1)+1)/2);//Stereo, Quad or 8 Channel. Specify the input to be mixed, the output[numberofchannels], and the pan (0-1,equal power).
this.output[0]=myStereoOutput.get(0);//When working with mixing, you need to specify the outputs explicitly
this.output[1]=myStereoOutput.get(1);//
}
myOutputs.stereo(myOsc.noise(),myStereoOutput,(myAutoPanner.sinewave(1)+1)/2);//Stereo, Quad or 8 Channel. Specify the input to be mixed, the output[numberofchannels], and the pan (0-1,equal power).
output[0]=myStereoOutput.get(0);//When working with mixing, you need to specify the outputs explicitly
output[1]=myStereoOutput.get(1);//
}
</pre> </pre>
</body></html> </body></html>
...@@ -43,21 +43,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -43,21 +43,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code --> <!-- Our javascript code -->
<script type="text/javascript"> <script type="text/javascript">
maximJs.maxiAudio.init(); var audio = new maximJs.maxiAudio();
audio.init();
var samplePlayer = new maximJs.maxiSample(); var samplePlayer = new maximJs.maxiSample();
var mySine = new maximJs.maxiOsc(); var mySine = new maximJs.maxiOsc();
maximJs.maxiAudio.loadSample("audio/beat2.wav", samplePlayer); // load sample to 'samplePlayer' using 'audio' object
// maximJs.maxiTools.loadSample("audio/beat2.wav", samplePlayer, maximJs.maxiAudio.context); audio.loadSample("audio/beat2.wav", samplePlayer);
maximJs.maxiAudio.play = function(){ audio.play = function(){
// this is necessary as file loading may not complete in setup // this is necessary as file loading may not complete in setup
if(samplePlayer.isReady()){ if(samplePlayer.isReady()){
output = samplePlayer.play();//just play the file. Looping is default for all play functions. this.output = samplePlayer.play();//just play the file. Looping is default for all play functions.
// output=samplePlayer.play(0.69) ;//play the file with a speed setting. 1. is normal speed. // this.output=samplePlayer.play(0.69) ;//play the file with a speed setting. 1. is normal speed.
// output=samplePlayer.play(0.5,0,44100);//linear interpolationplay with a frequency input, start point and end point. Useful for syncing. // this.output=samplePlayer.play(0.5,0,44100);//linear interpolationplay with a frequency input, start point and end point. Useful for syncing.
// output=samplePlayer.play4(0.5,0,44100);//cubic interpolation play with a frequency input, start point and end point. Useful for syncing. // this.output=samplePlayer.play4(0.5,0,44100);//cubic interpolation play with a frequency input, start point and end point. Useful for syncing.
} }
} }
...@@ -75,20 +76,22 @@ maximJs.maxiAudio.play = function(){ ...@@ -75,20 +76,22 @@ maximJs.maxiAudio.play = function(){
</p> </p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" > <pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
var audio = new maximJs.maxiAudio();
audio.init();
var samplePlayer = new maximJs.maxiSample(); var samplePlayer = new maximJs.maxiSample();
var mySine = new maximJs.maxiOsc(); var mySine = new maximJs.maxiOsc();
function setup(){ // load sample using 'audio' object
loadSample("./beat2.wav", samplePlayer); audio.loadSample("audio/beat2.wav", samplePlayer);
}
maximJs.maxiAudio.play = function(){ audio.play = function(){
// this is necessary as file loading may not complete in setup // this is necessary as file loading may not complete in setup
if(samplePlayer.isReady()){ if(samplePlayer.isReady()){
output = samplePlayer.play();//just play the file. Looping is default for all play functions. this.output = samplePlayer.play();//just play the file. Looping is default for all play functions.
// output=samplePlayer.play(0.69) ;//play the file with a speed setting. 1. is normal speed. // this.output=samplePlayer.play(0.69) ;//play the file with a speed setting. 1. is normal speed.
// output=samplePlayer.play(0.5,0,44100);//linear interpolationplay with a frequency input, start point and end point. Useful for syncing. // this.output=samplePlayer.play(0.5,0,44100);//linear interpolationplay with a frequency input, start point and end point. Useful for syncing.
// output=samplePlayer.play4(0.5,0,44100);//cubic interpolation play with a frequency input, start point and end point. Useful for syncing. // this.output=samplePlayer.play4(0.5,0,44100);//cubic interpolation play with a frequency input, start point and end point. Useful for syncing.
} }
} }
</pre> </pre>
......
...@@ -43,7 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -43,7 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code --> <!-- Our javascript code -->
<script type="text/javascript"> <script type="text/javascript">
maximJs.maxiAudio.init(); var audio = new maximJs.maxiAudio();
audio.init();
var a = new maximJs.maxiOsc(); var a = new maximJs.maxiOsc();
var xs = [0,0,0], ys = [0,0,0]; var xs = [0,0,0], ys = [0,0,0];
...@@ -83,12 +84,12 @@ a2 = 1 - alpha; ...@@ -83,12 +84,12 @@ a2 = 1 - alpha;
maximJs.maxiAudio.play = function() {//this is where the magic happens. Very slow magic. audio.play = function() {//this is where the magic happens. Very slow magic.
xs[0] = mySwitchableOsc.sawn(400); xs[0] = mySwitchableOsc.sawn(400);
ys[0] = (b0/a0)*xs[0] + (b1/a0)*xs[1] + (b2/a0)*xs[2] ys[0] = (b0/a0)*xs[0] + (b1/a0)*xs[1] + (b2/a0)*xs[2]
- (a1/a0)*ys[1] - (a2/a0)*ys[2]; - (a1/a0)*ys[1] - (a2/a0)*ys[2];
output = ys[0]; this.output = ys[0];
ys[2] = ys[1]; ys[1] = ys[0]; ys[2] = ys[1]; ys[1] = ys[0];
xs[2] = xs[1]; xs[1] = xs[0]; xs[2] = xs[1]; xs[1] = xs[0];
...@@ -108,7 +109,8 @@ maximJs.maxiAudio.play = function() {//this is where the magic happens. Very slo ...@@ -108,7 +109,8 @@ maximJs.maxiAudio.play = function() {//this is where the magic happens. Very slo
</p> </p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" > <pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
maximJs.maxiAudio.init(); var audio = new maximJs.maxiAudio();
audio.init();
var a = new maximJs.maxiOsc(); var a = new maximJs.maxiOsc();
var xs = [0,0,0], ys = [0,0,0]; var xs = [0,0,0], ys = [0,0,0];
...@@ -148,15 +150,17 @@ a2 = 1 - alpha; ...@@ -148,15 +150,17 @@ a2 = 1 - alpha;
maximJs.maxiAudio.play = function() {//this is where the magic happens. Very slow magic. audio.play = function() {//this is where the magic happens. Very slow magic.
xs[0] = mySwitchableOsc.sawn(400); xs[0] = mySwitchableOsc.sawn(400);
ys[0] = (b0/a0)*xs[0] + (b1/a0)*xs[1] + (b2/a0)*xs[2] ys[0] = (b0/a0)*xs[0] + (b1/a0)*xs[1] + (b2/a0)*xs[2]
- (a1/a0)*ys[1] - (a2/a0)*ys[2]; - (a1/a0)*ys[1] - (a2/a0)*ys[2];
output = ys[0]; this.output = ys[0];
ys[2] = ys[1]; ys[1] = ys[0]; ys[2] = ys[1]; ys[1] = ys[0];
xs[2] = xs[1]; xs[1] = xs[0]; xs[2] = xs[1]; xs[1] = xs[0];
} }
</pre> </pre>
</body></html> </body></html>
...@@ -44,7 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -44,7 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code --> <!-- Our javascript code -->
<script type="text/javascript"> <script type="text/javascript">
maximJs.maxiAudio.init(); var audio = new maximJs.maxiAudio();
audio.init();
//This shows how to use maximilian to build a monophonic synth //This shows how to use maximilian to build a monophonic synth
//These are the synthesiser bits //These are the synthesiser bits
...@@ -69,7 +70,7 @@ ADSR.setSustain(1); ...@@ -69,7 +70,7 @@ ADSR.setSustain(1);
ADSR.setRelease(1000); ADSR.setRelease(1000);
maximJs.maxiAudio.play = function(){ audio.play = function(){
//so this first bit is just a basic metronome so we can hear what we're doing. //so this first bit is just a basic metronome so we can hear what we're doing.
currentCount=Math.round(timer.phasor(0.5));//this sets up a metronome that ticks every 2 seconds currentCount=Math.round(timer.phasor(0.5));//this sets up a metronome that ticks every 2 seconds
...@@ -96,7 +97,7 @@ maximJs.maxiAudio.play = function(){ ...@@ -96,7 +97,7 @@ maximJs.maxiAudio.play = function(){
var finalSound=VCFout*ADSRout;//finally we add the ADSR as an amplitude modulator var finalSound=VCFout*ADSRout;//finally we add the ADSR as an amplitude modulator
ADSR.trigger=0; ADSR.trigger=0;
output=finalSound; this.output=finalSound;
} }
</script> </script>
...@@ -111,7 +112,7 @@ maximJs.maxiAudio.play = function(){ ...@@ -111,7 +112,7 @@ maximJs.maxiAudio.play = function(){
</p> </p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" > <pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
maximJs.maxiAudio.init(); audio.init();
//This shows how to use maximilian to build a monophonic synth //This shows how to use maximilian to build a monophonic synth
//These are the synthesiser bits //These are the synthesiser bits
...@@ -121,7 +122,6 @@ var LFO1 = new maximJs.maxiOsc(); ...@@ -121,7 +122,6 @@ var LFO1 = new maximJs.maxiOsc();
var LFO2 = new maximJs.maxiOsc(); var LFO2 = new maximJs.maxiOsc();
var VCF = new maximJs.maxiFilter(); var VCF = new maximJs.maxiFilter();
var ADSR = new maximJs.maxiEnv(); var ADSR = new maximJs.maxiEnv();
//This is a bunch of control signals so that we can hear something //This is a bunch of control signals so that we can hear something
...@@ -137,7 +137,7 @@ ADSR.setSustain(1); ...@@ -137,7 +137,7 @@ ADSR.setSustain(1);
ADSR.setRelease(1000); ADSR.setRelease(1000);
maximJs.maxiAudio.play = function(){ audio.play = function(){
//so this first bit is just a basic metronome so we can hear what we're doing. //so this first bit is just a basic metronome so we can hear what we're doing.
currentCount=Math.round(timer.phasor(0.5));//this sets up a metronome that ticks every 2 seconds currentCount=Math.round(timer.phasor(0.5));//this sets up a metronome that ticks every 2 seconds
...@@ -164,7 +164,7 @@ maximJs.maxiAudio.play = function(){ ...@@ -164,7 +164,7 @@ maximJs.maxiAudio.play = function(){
var finalSound=VCFout*ADSRout;//finally we add the ADSR as an amplitude modulator var finalSound=VCFout*ADSRout;//finally we add the ADSR as an amplitude modulator
ADSR.trigger=0; ADSR.trigger=0;
output=finalSound; this.output=finalSound;
} }
</pre> </pre>
</body></html> </body></html>
...@@ -44,9 +44,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -44,9 +44,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code --> <!-- Our javascript code -->
<script type="text/javascript"> <script type="text/javascript">
maximJs.maxiAudio.init(); var audio = new maximJs.maxiAudio();
audio.init();
// change output to an array // change output to an array
maximJs.maxiAudio.outputIsArray(true, 2); audio.outputIsArray(true, 2);
//This shows how to use maximilian to build a polyphonic synth. //This shows how to use maximilian to build a polyphonic synth.
// Chrome doesn't like this one for some reason // Chrome doesn't like this one for some reason
...@@ -93,7 +94,7 @@ for (var i=0;i<VCO_ArraySize;i++) { ...@@ -93,7 +94,7 @@ for (var i=0;i<VCO_ArraySize;i++) {
} }
maximJs.maxiAudio.play = function(){ audio.play = function(){
mix=0;//we're adding up the samples each update and it makes sense to clear them each time first. mix=0;//we're adding up the samples each update and it makes sense to clear them each time first.
//so this first bit is just a basic metronome so we can hear what we're doing. //so this first bit is just a basic metronome so we can hear what we're doing.
...@@ -131,8 +132,8 @@ maximJs.maxiAudio.play = function(){ ...@@ -131,8 +132,8 @@ maximJs.maxiAudio.play = function(){
} }
output[0]=mix*0.5;//left channel this.output[0]=mix*0.5;//left channel
output[1]=mix*0.5;//right channel this.output[1]=mix*0.5;//right channel
// This just sends note-off messages. // This just sends note-off messages.
for (var i=0; i<6; i++) { for (var i=0; i<6; i++) {
...@@ -153,10 +154,11 @@ maximJs.maxiAudio.play = function(){ ...@@ -153,10 +154,11 @@ maximJs.maxiAudio.play = function(){
This shows how to use maximilian to build a polyphonic synth. This shows how to use maximilian to build a polyphonic synth.
</p> </p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" > <pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
maximJs.maxiAudio.init(); var audio = new maximJs.maxiAudio();
audio.init();
// change output to an array // change output to an array
maximJs.maxiAudio.outputIsArray(true, 2); audio.outputIsArray(true, 2);
//This shows how to use maximilian to build a polyphonic synth. //This shows how to use maximilian to build a polyphonic synth.
// Chrome doesn't like this one for some reason // Chrome doesn't like this one for some reason
...@@ -177,6 +179,7 @@ var VCO1out = [], VCO2out = [], LFO1out = [],LFO2out = [], VCFout = [], ADSRout ...@@ -177,6 +179,7 @@ var VCO1out = [], VCO2out = [], LFO1out = [],LFO2out = [], VCFout = [], ADSRout
var pitch = []; var pitch = [];
// fill arrays with 0s
for(var i = 0; i < VCO_ArraySize; i++){ for(var i = 0; i < VCO_ArraySize; i++){
VCO1out.push(0); VCO1out.push(0);
VCO2out.push(0); VCO2out.push(0);
...@@ -202,7 +205,7 @@ for (var i=0;i<VCO_ArraySize;i++) { ...@@ -202,7 +205,7 @@ for (var i=0;i<VCO_ArraySize;i++) {
} }
maximJs.maxiAudio.play = function(){ audio.play = function(){
mix=0;//we're adding up the samples each update and it makes sense to clear them each time first. mix=0;//we're adding up the samples each update and it makes sense to clear them each time first.
//so this first bit is just a basic metronome so we can hear what we're doing. //so this first bit is just a basic metronome so we can hear what we're doing.
...@@ -240,8 +243,8 @@ maximJs.maxiAudio.play = function(){ ...@@ -240,8 +243,8 @@ maximJs.maxiAudio.play = function(){
} }
output[0]=mix*0.5;//left channel this.output[0]=mix*0.5;//left channel
output[1]=mix*0.5;//right channel this.output[1]=mix*0.5;//right channel
// This just sends note-off messages. // This just sends note-off messages.
for (var i=0; i<6; i++) { for (var i=0; i<6; i++) {
......
...@@ -44,34 +44,34 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -44,34 +44,34 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code --> <!-- Our javascript code -->
<script type="text/javascript"> <script type="text/javascript">
maximJs.maxiAudio.init(); var audio = new maximJs.maxiAudio();
audio.init();
var beats = new maximJs.maxiSample(); //We give our sample a name. It's called beats this time. We could have loads of them, but they have to have different names. var beats = new maximJs.maxiSample(); //We give our sample a name. It's called beats this time. We could have loads of them, but they have to have different names.
var compressor = new maximJs.maxiDyn(); //this is a compressor var compressor = new maximJs.maxiDyn(); //this is a compressor
var out = 0; var out = 0;
maximJs.maxiAudio.outputIsArray(true, 2); audio.outputIsArray(true, 2);
compressor.setAttack(100); compressor.setAttack(100);
compressor.setRelease(300); compressor.setRelease(300);
compressor.setThreshold(0.25); compressor.setThreshold(0.25);
compressor.setRatio(5); compressor.setRatio(5);
maximJs.maxiTools.loadSample('audio/beat2.wav', beats); audio.loadSample('audio/beat2.wav', beats);
maximJs.maxiAudio.play = function(){ audio.play = function(){
if(beats.isReady()){ if(beats.isReady()){
//here, we're just compressing the file in real-time //here, we're just compressing the file in real-time
//arguments are input,ratio,threshold,attack,release //arguments are input,ratio,threshold,attack,release
out=compressor.compress(beats.play()); out=compressor.compress(beats.play());
// out=compressor.compress(beats.play(0.66)); // out=compressor.compress(beats.play(0.66));
} }
output[0]=out; this.output[0]=out;
output[1]=out; this.output[1]=out;
} }
...@@ -88,32 +88,35 @@ maximJs.maxiAudio.play = function(){ ...@@ -88,32 +88,35 @@ maximJs.maxiAudio.play = function(){
</p> </p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" > <pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >