Commit 3c1c0fcb authored by Daniel Clarke's avatar Daniel Clarke

examples mostly fixed to work with changes to maxiAudio

parent 5c9512cd
......@@ -33330,14 +33330,14 @@ maximJs.maxiArray.prototype.clear = (function(useSq) {
this.length = 0;
});
maximJs.maxiTools = (function() {});
maximJs.maxiTools.prototype.arrayOfObj = (function(obj, num) {
maximJs.maxiTools.arrayOfObj = (function(obj, num) {
var array = [];
for (var i = 0; i < num; i++) {
array.push(new obj);
}
return array;
});
maximJs.maxiTools.prototype.getArrayAsVectorDbl = (function(arrayIn) {
maximJs.maxiTools.getArrayAsVectorDbl = (function(arrayIn) {
var vecOut = new Module.VectorDouble;
for (var i = 0; i < arrayIn.length; i++) {
vecOut.push_back(arrayIn[i]);
......@@ -33354,7 +33354,7 @@ maximJs.maxiAudio = (function() {
this.initDone = false;
});
maximJs.maxiAudio.play = (function() {});
maximJs.maxiAudio.prototype.setup = (function() {
maximJs.maxiAudio.setup = (function() {
console.log("non-overrided setup");
});
maximJs.maxiAudio.prototype.getNumChannels = (function() {
......@@ -33375,22 +33375,6 @@ maximJs.maxiAudio.prototype.outputIsArray = (function(isArray) {
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() {
this.context = new (window.AudioContext || window.webkitAudioContext);
this.source = this.context.createBufferSource();
......@@ -33400,7 +33384,7 @@ maximJs.maxiAudio.prototype.init = (function() {
var outputLength = event.outputBuffer.getChannelData(0).length;
for (var i = 0; i < outputLength; ++i) {
this.play();
if (self.output instanceof Array) {
if (this.output instanceof Array) {
for (var channel = 0; channel < numChannels; 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.
<!-- Our javascript code -->
<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 mySwitchableOsc = new maximJs.maxiOsc();//
......@@ -64,7 +65,7 @@ myEnvelope.setSustain(1);
myEnvelope.setRelease(1000);
maximJs.maxiAudio.play = function(){
audio.play = function(){
myCurrentVolume=myEnvelope.adsr(1.,myEnvelope.trigger);
......@@ -85,7 +86,7 @@ maximJs.maxiAudio.play = function(){
// The last input is the resonance.
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.
<!-- Our javascript code -->
<script type="text/javascript">
maximJs.maxiAudio.init();
var audio = new maximJs.maxiAudio();
audio.init();
// change output to an array
maximJs.maxiAudio.outputIsArray(true, 2);
audio.outputIsArray(true, 2);
var myOsc = new maximJs.maxiOsc();
var myAutoPanner = new maximJs.maxiOsc();
......@@ -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).
output[0]=myStereoOutput.get(0);//When working with mixing, you need to specify the outputs explicitly
output[1]=myStereoOutput.get(1);//
this.output[0]=myStereoOutput.get(0);//When working with mixing, you need to specify the outputs explicitly
this.output[1]=myStereoOutput.get(1);//
}
</script>
......@@ -73,24 +74,23 @@ maximJs.maxiAudio.play = function(){
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
var myOsc = new maximJs.maxiOsc();
var myAutoPanner = new maximJs.maxiOsc();
var myStereoOutput = GetArrayAsVectorDbl([0,0]);
var myOutputs = new maximJs.maxiMix();//this is the stereo mixer channel.
var audio = new maximJs.maxiAudio();
audio.init();
// change output to an array
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>
</body></html>
......@@ -43,21 +43,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
maximJs.maxiAudio.init();
var audio = new maximJs.maxiAudio();
audio.init();
var samplePlayer = new maximJs.maxiSample();
var mySine = new maximJs.maxiOsc();
maximJs.maxiAudio.loadSample("audio/beat2.wav", samplePlayer);
// maximJs.maxiTools.loadSample("audio/beat2.wav", samplePlayer, maximJs.maxiAudio.context);
// load sample to 'samplePlayer' using 'audio' object
audio.loadSample("audio/beat2.wav", samplePlayer);
maximJs.maxiAudio.play = function(){
audio.play = function(){
// this is necessary as file loading may not complete in setup
if(samplePlayer.isReady()){
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.
// 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.play();//just play the file. Looping is default for all play functions.
// this.output=samplePlayer.play(0.69) ;//play the file with a speed setting. 1. is normal speed.
// this.output=samplePlayer.play(0.5,0,44100);//linear interpolationplay 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(){
</p>
<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 mySine = new maximJs.maxiOsc();
function setup(){
loadSample("./beat2.wav", samplePlayer);
}
// load sample using 'audio' object
audio.loadSample("audio/beat2.wav", samplePlayer);
maximJs.maxiAudio.play = function(){
audio.play = function(){
// this is necessary as file loading may not complete in setup
if(samplePlayer.isReady()){
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.
// 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.play();//just play the file. Looping is default for all play functions.
// this.output=samplePlayer.play(0.69) ;//play the file with a speed setting. 1. is normal speed.
// this.output=samplePlayer.play(0.5,0,44100);//linear interpolationplay 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>
......
......@@ -43,7 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
maximJs.maxiAudio.init();
var audio = new maximJs.maxiAudio();
audio.init();
var a = new maximJs.maxiOsc();
var xs = [0,0,0], ys = [0,0,0];
......@@ -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);
ys[0] = (b0/a0)*xs[0] + (b1/a0)*xs[1] + (b2/a0)*xs[2]
- (a1/a0)*ys[1] - (a2/a0)*ys[2];
output = ys[0];
this.output = ys[0];
ys[2] = ys[1]; ys[1] = ys[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
</p>
<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 xs = [0,0,0], ys = [0,0,0];
......@@ -148,15 +150,17 @@ a2 = 1 - alpha;
maximJs.maxiAudio.play = function() {//this is where the magic happens. Very slow magic.
xs[0] = mySwitchableOsc.sawn(400);
ys[0] = (b0/a0)*xs[0] + (b1/a0)*xs[1] + (b2/a0)*xs[2]
- (a1/a0)*ys[1] - (a2/a0)*ys[2];
output = ys[0];
ys[2] = ys[1]; ys[1] = ys[0];
xs[2] = xs[1]; xs[1] = xs[0];
audio.play = function() {//this is where the magic happens. Very slow magic.
xs[0] = mySwitchableOsc.sawn(400);
ys[0] = (b0/a0)*xs[0] + (b1/a0)*xs[1] + (b2/a0)*xs[2]
- (a1/a0)*ys[1] - (a2/a0)*ys[2];
this.output = ys[0];
ys[2] = ys[1]; ys[1] = ys[0];
xs[2] = xs[1]; xs[1] = xs[0];
}
</pre>
</body></html>
......@@ -44,7 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<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
//These are the synthesiser bits
......@@ -69,7 +70,7 @@ ADSR.setSustain(1);
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.
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(){
var finalSound=VCFout*ADSRout;//finally we add the ADSR as an amplitude modulator
ADSR.trigger=0;
output=finalSound;
this.output=finalSound;
}
</script>
......@@ -111,7 +112,7 @@ maximJs.maxiAudio.play = function(){
</p>
<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
//These are the synthesiser bits
......@@ -121,7 +122,6 @@ var LFO1 = new maximJs.maxiOsc();
var LFO2 = new maximJs.maxiOsc();
var VCF = new maximJs.maxiFilter();
var ADSR = new maximJs.maxiEnv();
//This is a bunch of control signals so that we can hear something
......@@ -137,7 +137,7 @@ ADSR.setSustain(1);
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.
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(){
var finalSound=VCFout*ADSRout;//finally we add the ADSR as an amplitude modulator
ADSR.trigger=0;
output=finalSound;
this.output=finalSound;
}
</pre>
</body></html>
......@@ -44,9 +44,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
maximJs.maxiAudio.init();
var audio = new maximJs.maxiAudio();
audio.init();
// 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.
// Chrome doesn't like this one for some reason
......@@ -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.
//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(){
}
output[0]=mix*0.5;//left channel
output[1]=mix*0.5;//right channel
this.output[0]=mix*0.5;//left channel
this.output[1]=mix*0.5;//right channel
// This just sends note-off messages.
for (var i=0; i<6; i++) {
......@@ -153,10 +154,11 @@ maximJs.maxiAudio.play = function(){
This shows how to use maximilian to build a polyphonic synth.
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
maximJs.maxiAudio.init();
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
var audio = new maximJs.maxiAudio();
audio.init();
// 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.
// Chrome doesn't like this one for some reason
......@@ -177,6 +179,7 @@ var VCO1out = [], VCO2out = [], LFO1out = [],LFO2out = [], VCFout = [], ADSRout
var pitch = [];
// fill arrays with 0s
for(var i = 0; i < VCO_ArraySize; i++){
VCO1out.push(0);
VCO2out.push(0);
......@@ -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.
//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(){
}
output[0]=mix*0.5;//left channel
output[1]=mix*0.5;//right channel
this.output[0]=mix*0.5;//left channel
this.output[1]=mix*0.5;//right channel
// This just sends note-off messages.
for (var i=0; i<6; i++) {
......
......@@ -44,34 +44,34 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<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 compressor = new maximJs.maxiDyn(); //this is a compressor
var out = 0;
maximJs.maxiAudio.outputIsArray(true, 2);
audio.outputIsArray(true, 2);
compressor.setAttack(100);
compressor.setRelease(300);
compressor.setThreshold(0.25);
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()){
//here, we're just compressing the file in real-time
//arguments are input,ratio,threshold,attack,release
out=compressor.compress(beats.play());
// out=compressor.compress(beats.play(0.66));
}
output[0]=out;
output[1]=out;
this.output[0]=out;
this.output[1]=out;
}
......@@ -88,32 +88,35 @@ maximJs.maxiAudio.play = function(){
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
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 out = 0;
var audio = new maximJs.maxiAudio();
audio.init();
function setup(){
OutputIsArray(true, 2);
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 out = 0;
compressor.setAttack(100);
compressor.setRelease(300);
compressor.setThreshold(0.25);
compressor.setRatio(5);
loadSample('./beat2.wav', beats);
}
audio.outputIsArray(true, 2);
maximJs.maxiAudio.play = function(){
compressor.setAttack(100);
compressor.setRelease(300);
compressor.setThreshold(0.25);
compressor.setRatio(5);
audio.loadSample('audio/beat2.wav', beats);
audio.play = function(){
if(beats.isReady()){
//here, we're just compressing the file in real-time
//arguments are input,ratio,threshold,attack,release
out=compressor.compress(beats.play());
// out=compressor.compress(beats.play(0.66));
// out=compressor.compress(beats.play(0.66));
}
this.output[0]=out;
this.output[1]=out;
}
output[0]=out;
output[1]=out;
}
</pre>
</body></html>
......@@ -44,8 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
maximJs.maxiAudio.init();
// maximJs.maxiAudio.utputIsArray(true, 2);
var audio = new maximJs.maxiAudio();
audio.init();
var kick = new maximJs.maxiSample();
var snare = new maximJs.maxiSample();
......@@ -61,12 +61,12 @@ var hathit=[0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,1];//This is the sequence for the s
var kicktrigger,snaretrigger, hattrigger;
var sampleOut;
maximJs.maxiTools.loadSample('audio/kick1.wav', kick);
maximJs.maxiTools.loadSample('audio/snare1.wav', snare);
maximJs.maxiTools.loadSample('audio/hat12.wav', hat);
audio.loadSample('audio/kick1.wav', kick);
audio.loadSample('audio/snare1.wav', snare);
audio.loadSample('audio/hat12.wav', hat);
maximJs.maxiAudio.play = function(){
audio.play = function(){
// if(kick.isReady() && snare.isReady()){
currentCount=Math.floor(timer.phasor(8));//this sets up a metronome that ticks 8 times a second
......@@ -97,11 +97,8 @@ maximJs.maxiAudio.play = function(){
sampleOut=hat.playOnce()*0.2+kick.playOnce()+snare.playOnce();//just play the files. No looping.
output=sampleOut;//left channel
this.output=sampleOut;//left channel
// output[0]=sampleOut;//left channel
// output[1]=sampleOut;//right channel
kicktrigger = 0;//set trigger to 0 at the end of each sample to guarantee retriggering.
snaretrigger = 0;
hattrigger = 0;
......@@ -121,8 +118,8 @@ maximJs.maxiAudio.play = function(){
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
maximJs.maxiAudio.init();
// maximJs.maxiAudio.utputIsArray(true, 2);
var audio = new maximJs.maxiAudio();
audio.init();
var kick = new maximJs.maxiSample();
var snare = new maximJs.maxiSample();
......@@ -138,12 +135,12 @@ var hathit=[0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,1];//This is the sequence for the s
var kicktrigger,snaretrigger, hattrigger;
var sampleOut;
maximJs.maxiTools.loadSample('audio/kick1.wav', kick);
maximJs.maxiTools.loadSample('audio/snare1.wav', snare);
maximJs.maxiTools.loadSample('audio/hat12.wav', hat);
audio.loadSample('audio/kick1.wav', kick);
audio.loadSample('audio/snare1.wav', snare);
audio.loadSample('audio/hat12.wav', hat);
maximJs.maxiAudio.play = function(){
audio.play = function(){
// if(kick.isReady() && snare.isReady()){
currentCount=Math.floor(timer.phasor(8));//this sets up a metronome that ticks 8 times a second
......@@ -174,11 +171,8 @@ maximJs.maxiAudio.play = function(){
sampleOut=hat.playOnce()*0.2+kick.playOnce()+snare.playOnce();//just play the files. No looping.
output=sampleOut;//left channel
this.output=sampleOut;//left channel
// output[0]=sampleOut;//left channel
// output[1]=sampleOut;//right channel
kicktrigger = 0;//set trigger to 0 at the end of each sample to guarantee retriggering.
snaretrigger = 0;
hattrigger = 0;
......
......@@ -44,7 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
maximJs.maxiAudio.init();
var audio = new maximJs.maxiAudio();
audio.init();
var sound1 = new maximJs.maxiSample();
......@@ -61,11 +62,11 @@ var sampleTrigger = 0;
var sampleOut = 0;
maximJs.maxiAudio.outputIsArray(true, 2);
maximJs.maxiTools.loadSample('audio/kick1.wav', sound1);
audio.outputIsArray(true, 2);
audio.loadSample('audio/kick1.wav', sound1);
maximJs.maxiAudio.play = function(){
audio.play = function(){
if(sound1.isReady()){
currentCount=Math.floor(timer.phasor(8));//this sets up a metronome that ticks 8 times a second
......@@ -85,8 +86,8 @@ maximJs.maxiAudio.play = function(){
//If you stick a 1 in the trigger input, it retriggers the envelope
sampleOut=envelope.ar(sound1.play(1.), 0.1, 0.9999, 1, sampleTrigger); //
output[0]=sampleOut;//left channel
output[1]=sampleOut;//right channel
this.output[0]=sampleOut;//left channel
this.output[1]=sampleOut;//right channel
sampleTrigger = 0;//set trigger to 0 at the end of each sample to guarantee retriggering.
}
......
......@@ -44,7 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
maximJs.maxiAudio.init();
var audio = new maximJs.maxiAudio();
audio.init();
var sineBank = [];
......@@ -52,7 +53,7 @@ for(var i = 0; i < 10; i++){
sineBank.push(new maximJs.maxiOsc());
}
maximJs.maxiAudio.play = function(){
audio.play = function(){
var wave=0;
var f0 = 100;
for(var i=0; i < 10; i++) {
......@@ -62,7 +63,7 @@ maximJs.maxiAudio.play = function(){
wave = wave + thisSine;
}
wave *= 0.1;
output = wave;//simple as that!
this.output = wave;//simple as that!
}
......@@ -79,17 +80,16 @@ maximJs.maxiAudio.play = function(){
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
var audio = new maximJs.maxiAudio();
audio.init();
var sineBank = [];
for(var i = 0; i < 10; i++){
sineBank.push(new maximJs.maxiOsc());
}
function setup(){ //some inits
//nothing to go here this time
}
maximJs.maxiAudio.play = function(){
audio.play = function(){
var wave=0;
var f0 = 100;
for(var i=0; i < 10; i++) {
......@@ -99,7 +99,7 @@ maximJs.maxiAudio.play = function(){
wave = wave + thisSine;
}
wave *= 0.1;
output = wave;//simple as that!
this.output = wave;//simple as that!
}
</pre>
</body></html>
......@@ -65,7 +65,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</body>
<script type="text/javascript">
maximJs.maxiAudio.init();
var audio = new maximJs.maxiAudio();
audio.init();
var fft = new maximJs.maxiFFT();
// var ifft = new maximJs.maxiIFFT();
......@@ -104,7 +105,7 @@ function setup(){
}
maximJs.maxiAudio.play = function(){
audio.play = function(){
// create wave for fft
var wave = osc.square(220);
......@@ -114,7 +115,7 @@ maximJs.maxiAudio.play = function(){
count++; // increment counter
}
output = wave;
this.output = wave;
}
......@@ -134,13 +135,11 @@ for(var i=0; i < fftSize / 2; i++) {
context.closePath();
}
}
</script>
<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 fft = new maximJs.maxiFFT();
// var ifft = new maximJs.maxiIFFT();
......@@ -179,7 +178,7 @@ function setup(){
}
maximJs.maxiAudio.play = function(){
audio.play = function(){
// create wave for fft
var wave = osc.square(220);
......@@ -189,7 +188,7 @@ maximJs.maxiAudio.play = function(){
count++; // increment counter
}
output = wave;
this.output = wave;