Commit a2a106f8 authored by Jakub Fiala's avatar Jakub Fiala

merged changes from master

parents 351db365 292fe4b2
# change '../../em++' to path to em++ in emscriten folder # change '../../em++' to path to em++ in emscripten folder
EMSCR=../../em++ EMSCR=../../em++
# ---------------------------------------- # ----------------------------------------
......
This diff is collapsed.
...@@ -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
} }
...@@ -102,6 +103,9 @@ maximJs.maxiAudio.play = function(){ ...@@ -102,6 +103,9 @@ 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 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();//
...@@ -112,15 +116,15 @@ var myOscOutput,myFilteredOutput;// ...@@ -112,15 +116,15 @@ var myOscOutput,myFilteredOutput;//
var myEnvelope = new maximJs.maxiEnv(); var myEnvelope = new maximJs.maxiEnv();
var myFilter = new maximJs.maxiFilter(); var myFilter = new maximJs.maxiFilter();
function setup(){
//Timing is in ms //Timing is in ms
myEnvelope.setAttack(0); myEnvelope.setAttack(0);
myEnvelope.setDecay(1); // Needs to be at least 1 myEnvelope.setDecay(1); // Needs to be at least 1
myEnvelope.setSustain(1); 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);
...@@ -141,7 +145,7 @@ maximJs.maxiAudio.play = function(){ ...@@ -141,7 +145,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
} }
</pre> </pre>
</body></html> </body></html>
...@@ -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>
...@@ -42,23 +42,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -42,23 +42,23 @@ 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();
maximJs.maxiAudio.init(); audio.init();
var samplePlayer = new maximJs.maxiSample(); var samplePlayer = new maximJs.maxiSample();
var mySine = new maximJs.maxiOsc(); var mySine = new maximJs.maxiOsc();
maximJs.maxiTools.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,21 +75,23 @@ maximJs.maxiAudio.play = function(){ ...@@ -75,21 +75,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 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>
</body></html> </body></html>
\ No newline at end of file
...@@ -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,23 +44,45 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -44,23 +44,45 @@ 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
var VCO_ArraySize = 6; var VCO_ArraySize = 6;
//These are the synthesiser bits //These are the synthesiser bits
// maxiTools makes it quicker to fill arrays with maxim objects var VCO1 = [];
var VCO1 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize); for(var i = 0; i < VCO_ArraySize; ++i){
var VCO2 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize); VCO1.push(new maximJs.maxiOsc());
var LFO1 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize); }
var LFO2 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var VCO2 = [];
for(var i = 0; i < VCO_ArraySize; ++i){
VCO2.push(new maximJs.maxiOsc());
}
var VCF = maximJs. maxiTools.arrayOfObj(maximJs.maxiFilter, VCO_ArraySize); var LFO1 = [];
var ADSR = maximJs. maxiTools.arrayOfObj(maximJs.maxiEnv, VCO_ArraySize); for(var i = 0; i < VCO_ArraySize; ++i){
LFO1.push(new maximJs.maxiOsc());
}
var LFO2 = [];
for(var i = 0; i < VCO_ArraySize; ++i){
LFO2.push(new maximJs.maxiOsc());
}
var VCF = [];
for(var i = 0; i < VCO_ArraySize; ++i){
VCF.push(new maximJs.maxiFilter());
}
var ADSR = [];
for(var i = 0; i < VCO_ArraySize; ++i){
ADSR.push(new maximJs.maxiEnv());
}
//and these are some variables we can use to pass stuff around //and these are some variables we can use to pass stuff around
var VCO1out = [], VCO2out = [], LFO1out = [],LFO2out = [], VCFout = [], ADSRout = []; var VCO1out = [], VCO2out = [], LFO1out = [],LFO2out = [], VCFout = [], ADSRout = [];
...@@ -93,7 +115,7 @@ for (var i=0;i<VCO_ArraySize;i++) { ...@@ -93,7 +115,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.
...@@ -102,7 +124,7 @@ maximJs.maxiAudio.play = function(){ ...@@ -102,7 +124,7 @@ maximJs.maxiAudio.play = function(){
if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
if (voice>=6) { if (voice>=VCO_ArraySize) {
voice=0; voice=0;
} }
...@@ -113,7 +135,7 @@ maximJs.maxiAudio.play = function(){ ...@@ -113,7 +135,7 @@ maximJs.maxiAudio.play = function(){
} }
//and this is where we build the synth //and this is where we build the synth
for (var i=0; i<6; i++) { for (var i=0; i<VCO_ArraySize; i++) {
ADSRout[i]=ADSR[i].adsr(1.,ADSR[i].trigger);//our ADSR env is passed a constant signal of 1 to generate the transient. ADSRout[i]=ADSR[i].adsr(1.,ADSR[i].trigger);//our ADSR env is passed a constant signal of 1 to generate the transient.
...@@ -126,16 +148,16 @@ maximJs.maxiAudio.play = function(){ ...@@ -126,16 +148,16 @@ maximJs.maxiAudio.play = function(){
VCFout[i]=VCF[i].lores((VCO1out[i]+VCO2out[i])*0.5, 250+((pitch[i]+LFO1out[i])*1000), 10);//now we stick the VCO's into the VCF, using the ADSR as the filter cutoff VCFout[i]=VCF[i].lores((VCO1out[i]+VCO2out[i])*0.5, 250+((pitch[i]+LFO1out[i])*1000), 10);//now we stick the VCO's into the VCF, using the ADSR as the filter cutoff
mix+=VCFout[i]*ADSRout[i]/6;//finally we add the ADSR as an amplitude modulator mix+=VCFout[i]*ADSRout[i]/VCO_ArraySize;//finally we add the ADSR as an amplitude modulator
} }
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<VCO_ArraySize; i++) {
ADSR[i].trigger=0; ADSR[i].trigger=0;
} }
} }
...@@ -153,30 +175,53 @@ maximJs.maxiAudio.play = function(){ ...@@ -153,30 +175,53 @@ 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
var VCO_ArraySize = 6; var VCO_ArraySize = 6;
//These are the synthesiser bits //These are the synthesiser bits
// maxiTools makes it quicker to fill arrays with maxim objects var VCO1 = [];
var VCO1 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize); for(var i = 0; i < VCO_ArraySize; ++i){
var VCO2 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize); VCO1.push(new maximJs.maxiOsc());
var LFO1 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize); }
var LFO2 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var VCF = maximJs. maxiTools.arrayOfObj(maximJs.maxiFilter, VCO_ArraySize); var VCO2 = [];
var ADSR = maximJs. maxiTools.arrayOfObj(maximJs.maxiEnv, VCO_ArraySize); for(var i = 0; i < VCO_ArraySize; ++i){
VCO2.push(new maximJs.maxiOsc());
}
var LFO1 = [];
for(var i = 0; i < VCO_ArraySize;