Commit c52a542b authored by Daniel Clarke's avatar Daniel Clarke

all js functions are wrapped in class/namespace. No longer mandatory to use...

all js functions are wrapped in class/namespace. No longer mandatory to use maxim webAudio implementation.
parent d80bb324
......@@ -3,6 +3,7 @@ src/cpp/Maximilian-master/
Recordings/
maxiLib/maximilian_examples_web/load_sample_test.html
maxiLib/sed_addText.sh
maxiLib/sed_replace.sh
maxiLib/sed_text_stuff/
maximilian_examples_cpp/
old_stuff/
\ No newline at end of file
......@@ -5,15 +5,15 @@ EMSCR=../../em++
# Maximilian base stuff
# POST_JS is all the external js stuff that handles web audio etc
POST_JS_webAudio_all=src/js/maxi_webAudio_wExtras.js
POST_JS_extras=src/js/maxi_extras.js
POST_JS_webAudio_all=src/js/maxi_webAudio_Complete.js
# POST_JS_extras=src/js/maxi_extras.js
#the .cpp file that is used
SOURCE_MAXI=src/cpp/maxi_emscr_new.cpp
# destination .js file
OUTPUT_MAXI=maxiLib/maxiLib.js
OUTPUT_MAXI_noAudio=maxiLib/maxiLib_noWebAudio.js
# OUTPUT_MAXI_noAudio=maxiLib/maxiLib_noWebAudio.js
# ----------------------------------------
# extra libs stuff
......@@ -36,7 +36,8 @@ CFLAGS=-O3 -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1 -s ASSERTION
full:
$(EMSCR) $(CFLAGS) --post-js $(POST_JS_webAudio_all) --bind -o $(OUTPUT_MAXI) $(SOURCE_MAXI) $(SOURCES_LIBS)
basic:
$(EMSCR) $(CFLAGS) --post-js $(POST_JS_extras) --bind -o $(OUTPUT_MAXI_noAudio) $(SOURCE_MAXI) $(SOURCES_LIBS)
# without webAudio stuff
# basic:
# $(EMSCR) $(CFLAGS) --post-js $(POST_JS_extras) --bind -o $(OUTPUT_MAXI_noAudio) $(SOURCE_MAXI) $(SOURCES_LIBS)
all: full
\ No newline at end of file
......@@ -2,6 +2,4 @@ An implementation of maximilian in javascript using emscripten to compile code f
To use: move the maxiLib.js file from the maxiLib folder to an appropriate location and include using the <script> tag right now.
If you want to use without webAudio API setup for you, include maxiLib_noWebAudio.js. You can still include the maxi_webAudio file (from the src/js folder) after this and all will function as usual.
Examples are in maxiLib/maximilian_examples_web.
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
maximJs.maxiAudio.init();
var myCounter = new maximJs.maxiOsc(); //these oscillators will help us count and play sound
var mySwitchableOsc = new maximJs.maxiOsc();//
......@@ -55,15 +56,15 @@ var myOscOutput,myFilteredOutput;//
var myEnvelope = new maximJs.maxiEnv();
var myFilter = new maximJs.maxiFilter();
function setup(){
//Timing is in ms
myEnvelope.setAttack(0);
myEnvelope.setDecay(1); // Needs to be at least 1
myEnvelope.setSustain(1);
myEnvelope.setRelease(1000);
}
myEnvelope.setAttack(0);
myEnvelope.setDecay(1); // Needs to be at least 1
myEnvelope.setSustain(1);
myEnvelope.setRelease(1000);
function play(){
maximJs.maxiAudio.play = function(){
myCurrentVolume=myEnvelope.adsr(1.,myEnvelope.trigger);
......@@ -84,7 +85,7 @@ function play(){
// The last input is the resonance.
myFilteredOutput=myFilter.lores(myOscOutput,myCurrentVolume*1000,10);
output=myFilteredOutput;//left speaker
this.output=myFilteredOutput;//left speaker
}
......@@ -119,7 +120,7 @@ function setup(){
myEnvelope.setRelease(1000);
}
function play(){
maximJs.maxiAudio.play = function(){
myCurrentVolume=myEnvelope.adsr(1.,myEnvelope.trigger);
......@@ -140,7 +141,7 @@ function play(){
// The last input is the resonance.
myFilteredOutput=myFilter.lores(myOscOutput,myCurrentVolume*1000,10);
output=myFilteredOutput;//left speaker
this.output=myFilteredOutput;//left speaker
}
</pre>
</body></html>
......@@ -43,25 +43,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
maximJs.maxiAudio.init();
// change this.output to an array
maximJs.maxiAudio.outputIsArray(true, 2);
var myOsc = new maximJs.maxiOsc();
var myAutoPanner = new maximJs.maxiOsc();
var myStereoOutput = GetArrayAsVectorDbl([0,0]);
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
OutputIsArray(true, 2);
}
function play(){
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);//
maximJs.maxiAudio.play = function(){
myOutputs.stereo(myOsc.noise(),myStereoOutput,(myAutoPanner.sinewave(1)+1)/2);//Stereo, Quad or 8 Channel. Specify the input to be mixed, the this.output[numberofchannels], and the pan (0-1,equal power).
this.output[0]=myStereoOutput.get(0);//When working with mixing, you need to specify the this.outputs explicitly
this.output[1]=myStereoOutput.get(1);//
}
</script>
......@@ -84,17 +80,17 @@ function play(){
function setup(){
// change output to an array
// change this.output to an array
// setNumOutputChannels(2);
OutputIsArray(true, 2);
}
function play(){
maximJs.maxiAudio.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);//
myOutputs.stereo(myOsc.noise(),myStereoOutput,(myAutoPanner.sinewave(1)+1)/2);//Stereo, Quad or 8 Channel. Specify the input to be mixed, the this.output[numberofchannels], and the pan (0-1,equal power).
this.output[0]=myStereoOutput.get(0);//When working with mixing, you need to specify the this.outputs explicitly
this.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();
maximJs.maxiAudio.init();
var samplePlayer = new maximJs.maxiSample();
var mySine = new maximJs.maxiOsc();
function setup(){
loadSample("./beat2.wav", samplePlayer);
}
maximJs.maxiTools.loadSample("audio/beat2.wav", samplePlayer);
// maximJs.maxiTools.loadSample("audio/beat2.wav", samplePlayer, maximJs.maxiAudio.context);
function play(){
maximJs.maxiAudio.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.
}
}
......@@ -82,13 +83,13 @@ function setup(){
loadSample("./beat2.wav", samplePlayer);
}
function play(){
maximJs.maxiAudio.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,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
maximJs.maxiAudio.init();
var a = new maximJs.maxiOsc();
var xs = [0,0,0], ys = [0,0,0];
......@@ -52,48 +53,49 @@ var Q = 1.0;
var mySwitchableOsc = new maximJs.maxiOsc();
function setup() {//some inits
var cos = Math.cos;
var w0 = 2*Math.PI*f0/44100;
var alpha = Math.sin(w0)/(2*Q);
//Band-pass reson:
// b0 = alpha;
// b1 = 0;
// b2 = -1 * alpha;
// a0 = 1 + alpha;
// a1 = -2*cos(w0);
// a2 = 1 - alpha;
//Notch:
b0 = 1;
b1 = -2*cos(w0);
b2 = 1;
a0 = 1 + alpha;
a1 = -2*cos(w0);
a2 = 1 - alpha;
//LPF:
// b0 = (1 - cos(w0))/2;
// b1 = 1 - cos(w0);
// b2 = (1 - cos(w0))/2;
// a0 = 1 + alpha;
// a1 = -2*cos(w0);
// a2 = 1 - alpha;
}
function play() {//this is where the magic happens. Very slow magic.
var cos = Math.cos;
var w0 = 2*Math.PI*f0/44100;
var alpha = Math.sin(w0)/(2*Q);
// Band-pass reson:
// b0 = alpha;
// b1 = 0;
// b2 = -1 * alpha;
// a0 = 1 + alpha;
// a1 = -2*cos(w0);
// a2 = 1 - alpha;
//Notch:
b0 = 1;
b1 = -2*cos(w0);
b2 = 1;
a0 = 1 + alpha;
a1 = -2*cos(w0);
a2 = 1 - alpha;
//LPF:
// b0 = (1 - cos(w0))/2;
// b1 = 1 - cos(w0);
// b2 = (1 - cos(w0))/2;
// a0 = 1 + alpha;
// a1 = -2*cos(w0);
// 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];
this.output = ys[0];
ys[2] = ys[1]; ys[1] = ys[0];
xs[2] = xs[1]; xs[1] = xs[0];
}
</script>
</script>
</head>
......@@ -105,7 +107,9 @@ function play() {//this is where the magic happens. Very slow magic.
</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 a = new maximJs.maxiOsc();
var xs = [0,0,0], ys = [0,0,0];
var a0, a1, a2, b0, b1, b2;
......@@ -114,44 +118,45 @@ var Q = 1.0;
var mySwitchableOsc = new maximJs.maxiOsc();
function setup() {//some inits
var cos = Math.cos;
var w0 = 2*Math.PI*f0/44100;
var alpha = Math.sin(w0)/(2*Q);
//Band-pass reson:
// b0 = alpha;
// b1 = 0;
// b2 = -1 * alpha;
// a0 = 1 + alpha;
// a1 = -2*cos(w0);
// a2 = 1 - alpha;
//Notch:
b0 = 1;
b1 = -2*cos(w0);
b2 = 1;
a0 = 1 + alpha;
a1 = -2*cos(w0);
a2 = 1 - alpha;
//LPF:
// b0 = (1 - cos(w0))/2;
// b1 = 1 - cos(w0);
// b2 = (1 - cos(w0))/2;
// a0 = 1 + alpha;
// a1 = -2*cos(w0);
// a2 = 1 - alpha;
}
function play() {//this is where the magic happens. Very slow magic.
var cos = Math.cos;
var w0 = 2*Math.PI*f0/44100;
var alpha = Math.sin(w0)/(2*Q);
// Band-pass reson:
// b0 = alpha;
// b1 = 0;
// b2 = -1 * alpha;
// a0 = 1 + alpha;
// a1 = -2*cos(w0);
// a2 = 1 - alpha;
//Notch:
b0 = 1;
b1 = -2*cos(w0);
b2 = 1;
a0 = 1 + alpha;
a1 = -2*cos(w0);
a2 = 1 - alpha;
//LPF:
// b0 = (1 - cos(w0))/2;
// b1 = 1 - cos(w0);
// b2 = (1 - cos(w0))/2;
// a0 = 1 + alpha;
// a1 = -2*cos(w0);
// 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];
this.output = ys[0];
ys[2] = ys[1]; ys[1] = ys[0];
xs[2] = xs[1]; xs[1] = xs[0];
}
</pre>
</pre>
</body></html>
......@@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
maximJs.maxiAudio.init();
//This shows how to use maximilian to build a monophonic synth
//These are the synthesiser bits
......@@ -53,7 +54,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
......@@ -63,16 +63,14 @@ var currentCount,lastCount;//these values are used to check if we have a new bea
//and these are some variables we can use to pass stuff around
var VCO1out,VCO2out,LFO1out,LFO2out,VCFout,ADSRout;
function setup(){
ADSR.setAttack(1000);
ADSR.setDecay(1);
ADSR.setSustain(1);
ADSR.setRelease(1000);
}
ADSR.setAttack(1000);
ADSR.setDecay(1);
ADSR.setSustain(1);
ADSR.setRelease(1000);
function play(){
maximJs.maxiAudio.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
if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
......@@ -98,10 +96,8 @@ function play(){
var finalSound=VCFout*ADSRout;//finally we add the ADSR as an amplitude modulator
ADSR.trigger=0;
output=finalSound;
this.output=finalSound;
}
</script>
</head>
......@@ -115,6 +111,7 @@ function play(){
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
maximJs.maxiAudio.init();
//This shows how to use maximilian to build a monophonic synth
//These are the synthesiser bits
......@@ -134,16 +131,14 @@ var currentCount,lastCount;//these values are used to check if we have a new bea
//and these are some variables we can use to pass stuff around
var VCO1out,VCO2out,LFO1out,LFO2out,VCFout,ADSRout;
function setup(){
ADSR.setAttack(1000);
ADSR.setDecay(1);
ADSR.setSustain(1);
ADSR.setRelease(1000);
}
ADSR.setAttack(1000);
ADSR.setDecay(1);
ADSR.setSustain(1);
ADSR.setRelease(1000);
function play(){
maximJs.maxiAudio.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
if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
......@@ -169,7 +164,7 @@ function play(){
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,28 +44,30 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
//This shows how to use maximilian to build a polyphonic synth.
// for some reason, chrome doesn't like this example?
// maximTools will make it quicker to fill arrays with maxim objects
var maximTools = new maximJs.maximTools();
maximJs.maxiAudio.init();
// change this.output to an array
maximJs.maxiAudio.outputIsArray(true, 2);
//This shows how to use maximilian to build a polyphonic synth.
// Chrome doesn't like this one for some reason
var VCO_ArraySize = 6;
//These are the synthesiser bits
var VCO1 = maximTools.ArrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var VCO2 = maximTools.ArrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var LFO1 = maximTools.ArrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var LFO2 = maximTools.ArrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
// maxiTools makes it quicker to fill arrays with maxim objects
var VCO1 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var VCO2 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var LFO1 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var LFO2 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var VCF = maximTools.ArrayOfObj(maximJs.maxiFilter, VCO_ArraySize);
var ADSR = maximTools.ArrayOfObj(maximJs.maxiEnv, VCO_ArraySize);
var VCF = maximJs. maxiTools.arrayOfObj(maximJs.maxiFilter, VCO_ArraySize);
var ADSR = maximJs. maxiTools.arrayOfObj(maximJs.maxiEnv, VCO_ArraySize);
//and these are some variables we can use to pass stuff around
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);
......@@ -82,20 +84,16 @@ var currentCount = 0,lastCount = 0, voice = 0;//these values are used to check i
var mix;
for (var i=0;i<VCO_ArraySize;i++) {
function setup(){
for (var i=0;i<VCO_ArraySize;i++) {
ADSR[i].setAttack(0);
ADSR[i].setDecay(200);
ADSR[i].setSustain(0.2);
ADSR[i].setRelease(2000);
ADSR[i].setAttack(0);
ADSR[i].setDecay(200);
ADSR[i].setSustain(0.2);
ADSR[i].setRelease(2000);
}
OutputIsArray(true, 2);
}
function play(){
maximJs.maxiAudio.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.
......@@ -115,7 +113,6 @@ function play(){
}
//and this is where we build the synth
for (var i=0; i<6; i++) {
......@@ -134,8 +131,8 @@ function play(){
}
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++) {
......@@ -156,23 +153,24 @@ function play(){
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" >
//This shows how to use maximilian to build a polyphonic synth.
// for some reason, chrome doesn't like this example?
// maximTools will make it quicker to fill arrays with maxim objects
var maximTools = new maximJs.maximTools();
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
maximJs.maxiAudio.init();
// change this.output to an array
maximJs.maxiAudio.outputIsArray(true, 2);
//This shows how to use maximilian to build a polyphonic synth.
// Chrome doesn't like this one for some reason
var VCO_ArraySize = 6;
//These are the synthesiser bits
var VCO1 = maximTools.ArrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var VCO2 = maximTools.ArrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var LFO1 = maximTools.ArrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var LFO2 = maximTools.ArrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
// maxiTools makes it quicker to fill arrays with maxim objects
var VCO1 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var VCO2 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var LFO1 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var LFO2 = maximJs. maxiTools.arrayOfObj(maximJs.maxiOsc, VCO_ArraySize);
var VCF = maximTools.ArrayOfObj(maximJs.maxiFilter, VCO_ArraySize);
var ADSR = maximTools.ArrayOfObj(maximJs.maxiEnv, VCO_ArraySize);
var VCF = maximJs. maxiTools.arrayOfObj(maximJs.maxiFilter, VCO_ArraySize);
var ADSR = maximJs. maxiTools.arrayOfObj(maximJs.maxiEnv, VCO_ArraySize);
//and these are some variables we can use to pass stuff around
var VCO1out = [], VCO2out = [], LFO1out = [],LFO2out = [], VCFout = [], ADSRout = [];
......@@ -195,20 +193,16 @@ var currentCount = 0,lastCount = 0, voice = 0;//these values are used to check i
var mix;
for (var i=0;i<VCO_ArraySize;i++) {
function setup(){
for (var i=0;i<VCO_ArraySize;i++) {
ADSR[i].setAttack(0);
ADSR[i].setDecay(200);
ADSR[i].setSustain(0.2);
ADSR[i].setRelease(2000);
ADSR[i].setAttack(0);
ADSR[i].setDecay(200);
ADSR[i].setSustain(0.2);
ADSR[i].setRelease(2000);
}
OutputIsArray(true, 2);
}
function play(){
maximJs.maxiAudio.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.
......@@ -228,7 +222,6 @@ function play(){
}
//and this is where we build the synth
for (var i=0; i<6; i++) {
......@@ -247,13 +240,13 @@ function play(){
}
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++) {
ADSR[i].trigger=0;
}
}
</pre>
</pre>
</body></html>
......@@ -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();
maximJs.maxiAudio.outputIsArray(true, 2);
//Bizarelly, this sounds a little bit like Kraftwerk's 'Metropolis', although it isn't. Funny that.
var sound = new maximJs.maxiOsc();
var bass = new maximJs.maxiOsc();
var timer = new maximJs.maxiOsc();
......@@ -76,12 +77,7 @@ var leadLineTrigger=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0
var leadLinePitch=[69,67,65,64,67,66,64,62,65,64,62,57,55,60,57];
function setup(){
OutputIsArray(true, 2);
}
function play(){
maximJs.maxiAudio.play = function(){
currentCount=Math.floor(timer.phasor(9));//this sets up a metronome that ticks every so often
if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
......@@ -111,8 +107,8 @@ function play(){
if(trigger!=0)trigger=0;//set the trigger to off if you want it to trigger immediately next time.
output[0]=(bassout + delayout)/2;//sum output
output[1]=(bassout + delayout)/2;
this.output[0]=(bassout + delayout)/2;//sum this.output
this.output[1]=(bassout + delayout)/2;
}
......@@ -129,6 +125,9 @@ function play(){
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
maximJs.maxiAudio.init();
maximJs.maxiAudio.outputIsArray(true, 2);
//Bizarelly, this sounds a little bit like Kraftwerk's 'Metropolis', although it isn't. Funny that.
var sound = new maximJs.maxiOsc();
......@@ -161,12 +160,7 @@ var leadLineTrigger=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0
var leadLinePitch=[69,67,65,64,67,66,64,62,65,64,62,57,55,60,57];
function setup(){
OutputIsArray(true, 2);
}
function play(){
maximJs.maxiAudio.play = function(){
currentCount=Math.floor(timer.phasor(9));//this sets up a metronome that ticks every so often
if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
......@@ -196,8 +190,8 @@ function play(){
if(trigger!=0)trigger=0;//set the trigger to off if you want it to trigger immediately next time.
output[0]=(bassout + delayout)/<