Commit bf3854d9 authored by Daniel Clarke's avatar Daniel Clarke

had been using old maximilian -> updated js file and examples to match new version of emscripten

parent 4dd91ce1
Maxi_Emscripten/
\ No newline at end of file
Maxi_Emscripten/
src/cpp/Maximilian-master/
\ No newline at end of file
......@@ -5,7 +5,7 @@ CC=../../em++
POST_JS=src/js/maxi_webAudio.js
#the .cpp file that is used
SOURCE=src/cpp/maxi_emscr.cpp
SOURCE=src/cpp/maxi_emscr_new.cpp
# destination .js file
OUTPUT=maxiLib/maxiLib.js
......
This diff is collapsed.
......@@ -49,38 +49,42 @@ var myCounter = new maximJs.maxiOsc(); //these oscillators will help us count an
var mySwitchableOsc = new maximJs.maxiOsc();//
var CurrentCount;//
var myCurrentVolume;
var myOscOutput,myFilteredOutput;//
var myEnvelopeData = GetArrayAsVectorDbl([500,0,1000,500,0,500]); //this data will be used to make an envelope. Value and time to value in ms.
var myEnvelope = new maximJs.maxiEnvelope();
var myEnvelope = new maximJs.maxiEnv();
var myFilter = new maximJs.maxiFilter();
function setup(){
myEnvelope.amplitude=myEnvelopeData.get(0); //initialise the envelope
//Timing is in ms
myEnvelope.setAttack(0);
myEnvelope.setDecay(1); // Needs to be at least 1
myEnvelope.setSustain(1);
myEnvelope.setRelease(1000);
}
function play(){
CurrentCount= Math.floor(myCounter.phasor(1, 1, 9));//phasor can take three arguments; frequency, start value and end value
// currently doing some rounding as it doesn't seem to like otherwise
// CurrentCount = roundToNPlaces( CurrentCount, 0);
// console.log(CurrentCount);
if (CurrentCount<5){//simple if statement
myOscOutput=mySwitchableOsc.square(CurrentCount*100);
}
else if (CurrentCount>=5){//and the 'else' bit.
myOscOutput=mySwitchableOsc.saw(CurrentCount*50);//one osc object can produce whichever waveform you want.
}
if (CurrentCount===1) {
myEnvelope.trigger(0,myEnvelopeData.get(0)); //trigger the envelope
}
myFilteredOutput=myFilter.lores(myOscOutput,(myEnvelope.line(6, myEnvelopeData)),10);//lores takes an audio input, a frequency and a resonance factor (1-100)
output=myFilteredOutput;//point me at your speakers and fire.
myCurrentVolume=myEnvelope.adsr(1.,myEnvelope.trigger);
CurrentCount=Math.round(myCounter.phasor(1, 1, 9));//phasor can take three arguments; frequency, start value and end value.
// You'll notice that these 'if' statements don't require curly braces "{}".
// This is because there is only one outcome if the statement is true.
if (CurrentCount==1) myEnvelope.trigger=1; //trigger the envelope
else myEnvelope.trigger=0;//release the envelope to make it fade out only if it's been triggered
myOscOutput=mySwitchableOsc.sawn(100);
// Below, the oscilator signals are being passed through a low pass filter.
// The middle input is the filter cutoff. It is being controlled by the envelope.
// Notice that the envelope is being amplified so that it scales between 0 and 1000.
// The last input is the resonance.
myFilteredOutput=myFilter.lores(myOscOutput,myCurrentVolume*1000,10);
output=myFilteredOutput;//left speaker
}
......
......@@ -44,27 +44,40 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
var myCounter = new maximJs.maxiOsc(); //these oscillators will help us count and play sound
var mySquare = new maximJs.maxiOsc();
//we're going to put the current count in this variable so that we can use it more easily.
var currentCount;
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.
function setup(){
// change output to an array
// setNumOutputChannels(2);
OutputIsArray(true, 2);
}
function play(){
CurrentCount = Math.floor(myCounter.phasor(1, 1, 9));//phasor can take three arguments; frequency, start value and end value
output=mySquare.square(CurrentCount*100);
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);//
}
// window.onbeforeunload = function () {
// alert('unload');
// }
</script>
</script>
</head>
<body>
<h1> Counting </h1>
<h1> Mixing Example </h1>
<p>
Using phasor to count
</p>
</body></html>
......@@ -57,10 +57,10 @@ loadSample("./beat2.wav", samplePlayer);
function play(){
// 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)/* * mySine.sinewave(260) * mySine.square(440)*/ ;//play the file with a speed setting. 1. is normal speed.
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.
// output=samplePlayer.play4(0.5,0,44100);//cubic interpolation play with a frequency input, start point and end point. Useful for syncing.
}
}
......
<!--
Copyright 2010, Google Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>
Javascript Audio Processing
</title>
<!-- <link rel="stylesheet" type="text/css" href="javascript-processing_files/simple.css"> -->
<script src="../maxiLib.js"></script>
<!-- <script src="../maxi_webAudio.js"></script> -->
<!-- Our javascript code -->
<script type="text/javascript">
var a = new maximJs.maxiOsc();
var xs = [0,0,0], ys = [0,0,0];
var a0, a1, a2, b0, b1, b2;
var f0 = 400; //THE FREQUENCY
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.
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];
}
// window.onbeforeunload = function () {
// alert('unload');
// }
</script>
</head>
<body>
<h1> Advanced Filters </h1>
<p>
</p>
</body></html>
......@@ -54,12 +54,7 @@ var LFO2 = new maximJs.maxiOsc();
var VCF = new maximJs.maxiFilter();
var ADSR = new maximJs.maxiEnvelope();
//These are the control values for the envelope
var adsrEnvArray = [1,5,0.125,250,0.125,125,0,500];
var adsrEnv = GetArrayAsVectorDbl(adsrEnvArray);
var ADSR = new maximJs.maxiEnv();
//This is a bunch of control signals so that we can hear something
......@@ -70,37 +65,41 @@ var currentCount,lastCount;//these values are used to check if we have a new bea
var VCO1out,VCO2out,LFO1out,LFO2out,VCFout,ADSRout;
function setup(){
ADSR.setAttack(1000);
ADSR.setDecay(1);
ADSR.setSustain(1);
ADSR.setRelease(1000);
}
function play(){
//so this first bit is just a basic metronome so we can hear what we're doing.
currentCount=Math.floor(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
if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
ADSR.trigger(0, adsrEnv.get(0));//trigger the envelope from the start
ADSR.trigger = 1;//trigger the envelope from the start
// console.log("tick\n");//the clock ticks
lastCount=0;//set lastCount to 0
}
//and this is where we build the synth
ADSRout=ADSR.line(8,adsrEnv);//our ADSR env has 8 value/time pairs.
LFO1out=LFO1.sinebuf(0.2);//this lfo is a sinewave at 0.2 hz
VCO1out=VCO1.pulse(55,0.6);//here's VCO1. it's a pulse wave at 55 hz, with a pulse width of 0.6
VCO2out=VCO2.pulse(110+LFO1out,0.2);//here's VCO2. it's a pulse wave at 110hz with LFO modulation on the frequency, and width of 0.2
VCFout=VCF.lores((VCO1out+VCO2out)*0.5, 250+(ADSRout*15000), 10);//now we stick the VCO's into the VCF, using the ADSR as the filter cutoff
output=VCFout*ADSRout;//finally we add the ADSR as an amplitude modulator
//and this is where we build the synth
ADSRout=ADSR.adsr(1.0,ADSR.trigger);
LFO1out=LFO1.sinebuf(0.2);//this lfo is a sinewave at 0.2 hz
VCO1out=VCO1.pulse(55,0.6);//here's VCO1. it's a pulse wave at 55 hz, with a pulse width of 0.6
VCO2out=VCO2.pulse(110+LFO1out,0.2);//here's VCO2. it's a pulse wave at 110hz with LFO modulation on the frequency, and width of 0.2
VCFout=VCF.lores((VCO1out+VCO2out)*0.5, ADSRout*10000, 10);//now we stick the VCO's into the VCF, using the ADSR as the filter cutoff
var finalSound=VCFout*ADSRout;//finally we add the ADSR as an amplitude modulator
ADSR.trigger=0;
output=finalSound;
}
......
......@@ -46,91 +46,101 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<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();
var VCO_ArraySize = 6;
//These are the synthesiser bits
var VCO1 = [], VCO2 = [], LFO1 = [], LFO2 = [];
var VCF = [];
var ADSR = [];
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);
var VCF = maximTools.ArrayOfObj(maximJs.maxiFilter, VCO_ArraySize);
var ADSR = maximTools.ArrayOfObj(maximJs.maxiEnv, VCO_ArraySize);
//and these are some variables we can use to pass stuff around
var VCO1out = [], VCO2out = [], LFO1out = [],LFO2out = [], VCFout = [], ADSRout = [];
for(var i = 0; i < VCO_ArraySize; i++){
VCO1.push(new maximJs.maxiOsc());
VCO2.push(new maximJs.maxiOsc());
LFO1.push(new maximJs.maxiOsc());
LFO2.push(new maximJs.maxiOsc());
VCF.push(new maximJs.maxiFilter());
ADSR.push(new maximJs.maxiEnvelope());
var pitch = [];
for(var i = 0; i < VCO_ArraySize; i++){
VCO1out.push(0);
VCO2out.push(0);
LFO1out.push(0);
LFO2out.push(0);
VCFout.push(0);
ADSRout.push(0);
pitch.push(0);
}
//These are the control values for the envelope
// var adsrEnvArray = [1,5,0.125,100,0.125,200,0,1000];
var adsrEnv = GetArrayAsVectorDbl([1,5,0.125,100,0.125,200,0,1000]);
//This is a bunch of control signals so that we can hear something
var timer = new maximJs.maxiOsc();//this is the metronome
var currentCount,lastCount, voice = 0;//these values are used to check if we have a new beat this sample
var currentCount = 0,lastCount = 0, voice = 0;//these values are used to check if we have a new beat this sample
var mix;
var pitch = [1,2,3,4,5,6]; // for some reason this must be done
function setup(){
setNumChannels(true, 2);
}
for (var i=0;i<VCO_ArraySize;i++) {
function play(){
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.
currentCount = Math.floor(timer.phasor(8));//this sets up a metronome that ticks 8 times a second
if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
ADSR[i].setAttack(0);
ADSR[i].setDecay(200);
ADSR[i].setSustain(0.2);
ADSR[i].setRelease(2000);
if (voice>=6) {
voice=0;
}
ADSR[voice].trigger(0, adsrEnv.get(0));//trigger the envelope from the start
pitch[voice]=voice+1;
voice++;
lastCount=0;
}
//and this is where we build the synth
for (var i=0; i<6; i++) {
ADSRout[i]=ADSR[i].line(8,adsrEnv);//our ADSR env has 8 value/time pairs.
LFO1out[i]=LFO1[i].sinebuf(0.2);//this lfo is a sinewave at 0.2 hz
VCO1out[i]=VCO1[i].pulse(55*pitch[i],0.6);//here's VCO1. it's a pulse wave at 55 hz, with a pulse width of 0.6
VCO2out[i]=VCO2[i].pulse((110*pitch[i])+LFO1out[i],0.2);//here's VCO2. it's a pulse wave at 110hz with LFO modulation on the frequency, and width of 0.2
// some kind of NaN problem here !!!
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
setNumChannels(true, 2);
}
output[0]=mix*0.5;//left channel
output[1]=mix*0.5;//right channel
function play(){
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.
currentCount=Math.floor(timer.phasor(8));//this sets up a metronome that ticks 8 times a second
if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
if (voice>=6) {
voice=0;
}
ADSR[voice].trigger=1;//trigger the envelope from the start
pitch[voice]=voice+1;
voice++;
// lastCount = 0;
}
//and this is where we build the synth
for (var i=0; i<6; i++) {
ADSRout[i]=ADSR[i].adsr(1.,ADSR[i].trigger);//our ADSR env is passed a constant signal of 1 to generate the transient.
LFO1out[i]=LFO1[i].sinebuf(0.2);//this lfo is a sinewave at 0.2 hz
VCO1out[i]=VCO1[i].pulse(55*pitch[i],0.6);//here's VCO1. it's a pulse wave at 55 hz, with a pulse width of 0.6
VCO2out[i]=VCO2[i].pulse((110*pitch[i])+LFO1out[i],0.2);//here's VCO2. it's a pulse wave at 110hz with LFO modulation on the frequency, and width of 0.2
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
}
output[0]=mix*0.5;//left channel
output[1]=mix*0.5;//right channel
// This just sends note-off messages.
for (var i=0; i<6; i++) {
ADSR[i].trigger=0;
}
}
......
<!--
Copyright 2010, Google Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>
Javascript Audio Processing
</title>
<!-- <link rel="stylesheet" type="text/css" href="javascript-processing_files/simple.css"> -->
<script src="../maxiLib.js"></script>
<!-- <script src="../maxi_webAudio.js"></script> -->
<!-- Our javascript code -->
<script type="text/javascript">
//This shows how to use maximilian to build a polyphonic synth.
var VCO_ArraySize = 6;
//These are the synthesiser bits
var VCO1 = [], VCO2 = [], LFO1 = [], LFO2 = [];
var VCF = [];
var ADSR = [];
//and these are some variables we can use to pass stuff around
var VCO1out = [], VCO2out = [], LFO1out = [],LFO2out = [], VCFout = [], ADSRout = [];
for(var i = 0; i < VCO_ArraySize; i++){
VCO1.push(new maximJs.maxiOsc());
VCO2.push(new maximJs.maxiOsc());
LFO1.push(new maximJs.maxiOsc());
LFO2.push(new maximJs.maxiOsc());
VCF.push(new maximJs.maxiFilter());
ADSR.push(new maximJs.maxiEnvelope());
VCO1out.push(0);
VCO2out.push(0);
LFO1out.push(0);
LFO2out.push(0);
VCFout.push(0);
ADSRout.push(0);
}
//These are the control values for the envelope
// var adsrEnvArray = [1,5,0.125,100,0.125,200,0,1000];
var adsrEnv = GetArrayAsVectorDbl([1,5,0.125,100,0.125,200,0,1000]);
//This is a bunch of control signals so that we can hear something
var timer = new maximJs.maxiOsc();//this is the metronome
var currentCount,lastCount, voice = 0;//these values are used to check if we have a new beat this sample
var mix;
var pitch = [1,2,3,4,5,6];
function setup(){
setNumChannels(true, 2);
}
function play(){
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.
currentCount = Math.floor(timer.phasor(8));//this sets up a metronome that ticks 8 times a second
if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
if (voice>=6) {
voice=0;
}
ADSR[voice].trigger(0, adsrEnv.get(0));//trigger the envelope from the start
pitch[voice]=voice+1;
voice++;
lastCount=0;
}
//and this is where we build the synth
for (var i=0; i<6; i++) {
ADSRout[i]=ADSR[i].line(8,adsrEnv);//our ADSR env has 8 value/time pairs.
LFO1out[i]=LFO1[i].sinebuf(0.2);//this lfo is a sinewave at 0.2 hz
VCO1out[i]=VCO1[i].pulse(55*pitch[i],0.6);//here's VCO1. it's a pulse wave at 55 hz, with a pulse width of 0.6
VCO2out[i]=VCO2[i].pulse((110*pitch[i])+LFO1out[i],0.2);//here's VCO2. it's a pulse wave at 110hz with LFO modulation on the frequency, and width of 0.2
// some kind of NaN problem here !!!
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
}
output[0]=mix*0.5;//left channel
output[1]=mix*0.5;//right channel
}
</script>
</head>
<body>
<h1> polysynth </h1>
<p>
This shows how to use maximilian to build a polyphonic synth.
</p>
</body></html>
......@@ -82,38 +82,37 @@ function setup(){
}
function play(){
// currentCount=timer.phasor(9);//this sets up a metronome that ticks every so often
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
trigger=1;//play the arpeggiator line
trigger2=leadLineTrigger[playHead%256];//play the lead line
if (trigger2==1) {//if we are going to play a note
leadPitch=mtof.mtof(leadLinePitch[newnote]);//get the next pitch val
newnote++;//and iterate
if (newnote>14) {
newnote=0;//make sure we don't go over the edge of the array
}
}
currentPitch=mtof.mtof(pitch[(playHead%4)]+chord[currentChord%8]);//write the frequency val into currentPitch
playHead++;//iterate the playhead
if (playHead%32==0) {//wrap every 4 bars
currentChord++;//change the chord
}
//cout