Commit 292fe4b2 authored by Daniel Clarke's avatar Daniel Clarke

fixed up some more examples

parent 3c1c0fcb
......@@ -103,6 +103,9 @@ audio.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 myCounter = new maximJs.maxiOsc(); //these oscillators will help us count and play sound
var mySwitchableOsc = new maximJs.maxiOsc();//
......@@ -113,15 +116,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);
maximJs.maxiAudio.play = function(){
audio.play = function(){
myCurrentVolume=myEnvelope.adsr(1.,myEnvelope.trigger);
......@@ -142,7 +145,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
}
</pre>
</body></html>
......@@ -54,14 +54,35 @@ audio.init();
var VCO_ArraySize = 6;
//These are the synthesiser bits
// 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 VCO1 = [];
for(var i = 0; i < VCO_ArraySize; ++i){
VCO1.push(new maximJs.maxiOsc());
}
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 ADSR = maximJs. maxiTools.arrayOfObj(maximJs.maxiEnv, VCO_ArraySize);
var LFO1 = [];
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
var VCO1out = [], VCO2out = [], LFO1out = [],LFO2out = [], VCFout = [], ADSRout = [];
......@@ -103,7 +124,7 @@ audio.play = function(){
if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
if (voice>=6) {
if (voice>=VCO_ArraySize) {
voice=0;
}
......@@ -114,7 +135,7 @@ audio.play = function(){
}
//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.
......@@ -127,7 +148,7 @@ audio.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
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
}
......@@ -136,7 +157,7 @@ audio.play = function(){
this.output[1]=mix*0.5;//right channel
// 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;
}
}
......@@ -155,7 +176,7 @@ audio.play = function(){
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
var audio = new maximJs.maxiAudio();
var audio = new maximJs.maxiAudio();
audio.init();
// change output to an array
audio.outputIsArray(true, 2);
......@@ -165,14 +186,35 @@ audio.init();
var VCO_ArraySize = 6;
//These are the synthesiser bits
// 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 VCO1 = [];
for(var i = 0; i < VCO_ArraySize; ++i){
VCO1.push(new maximJs.maxiOsc());
}
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 ADSR = maximJs. maxiTools.arrayOfObj(maximJs.maxiEnv, VCO_ArraySize);
var LFO1 = [];
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
var VCO1out = [], VCO2out = [], LFO1out = [],LFO2out = [], VCFout = [], ADSRout = [];
......@@ -214,7 +256,7 @@ audio.play = function(){
if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
if (voice>=6) {
if (voice>=VCO_ArraySize) {
voice=0;
}
......@@ -225,7 +267,7 @@ audio.play = function(){
}
//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.
......@@ -238,7 +280,7 @@ audio.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
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
}
......@@ -247,9 +289,10 @@ audio.play = function(){
this.output[1]=mix*0.5;//right channel
// 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;
}
}
</pre>
</body></html>
......@@ -43,8 +43,9 @@ 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);
var audio = new maximJs.maxiAudio();
audio.init();
audio.outputIsArray(true, 2);
//Bizarelly, this sounds a little bit like Kraftwerk's 'Metropolis', although it isn't. Funny that.
var sound = new maximJs.maxiOsc();
......@@ -77,7 +78,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];
maximJs.maxiAudio.play = function(){
audio.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
......@@ -107,11 +108,9 @@ maximJs.maxiAudio.play = function(){
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;
audio.output[0]=(bassout + delayout)/2;//sum output
audio.output[1]=(bassout + delayout)/2;
}
</script>
</head>
......@@ -125,11 +124,11 @@ maximJs.maxiAudio.play = function(){
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
maximJs.maxiAudio.init();
maximJs.maxiAudio.outputIsArray(true, 2);
var audio = new maximJs.maxiAudio();
audio.init();
audio.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();
......@@ -160,7 +159,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];
maximJs.maxiAudio.play = function(){
audio.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
......@@ -190,8 +189,8 @@ maximJs.maxiAudio.play = function(){
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;
audio.output[0]=(bassout + delayout)/2;//sum output
audio.output[1]=(bassout + delayout)/2;
}
</pre>
</body></html>
......@@ -107,49 +107,52 @@ audio.play = function(){
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
var sound1 = new maximJs.maxiSample();
var audio = new maximJs.maxiAudio();
audio.init();
var snarePhase = new maximJs.maxiOsc();
var timer = new maximJs.maxiOsc();
var sound1 = new maximJs.maxiSample();
var envelope = new maximJs.maxiEnv();
var currentCount = 0,lastCount = 0,playHead = 0;
var snarePhase = new maximJs.maxiOsc();
var timer = new maximJs.maxiOsc();
var sequence = [1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0]; //This is the sequence for the kick
var envelope = new maximJs.maxiEnv();
var currentCount = 0,lastCount = 0,playHead = 0;
var sequence = [1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0]; //This is the sequence for the kick
var sampleTrigger = 0;
var sampleOut = 0;
function setup(){
OutputIsArray(true, 2);
loadSample('audio/beat2.wav', sound1);
}
var sampleTrigger = 0;
var sampleOut = 0;
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
if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound
sampleTrigger=sequence[playHead%16];
playHead++;//iterate the playhead
lastCount=0;//reset the metrotest
sampleTrigger=sequence[playHead%16];
playHead++;//iterate the playhead
lastCount=0;//reset the metrotest
}
//the envelope we're using here is an AR envelope.
//It has an input (which in this case is a sound)
//It has an attack coefficient, a hold val (in samples)
//and a release coefficient. Finally, it has a trigger input.
//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
}
//the envelope we're using here is an AR envelope.
//It has an input (which in this case is a sound)
//It has an attack coefficient, a hold val (in samples)
//and a release coefficient. Finally, it has a trigger input.
//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); //
sampleTrigger = 0;//set trigger to 0 at the end of each sample to guarantee retriggering.
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.
}
}
</pre>
......
......@@ -44,17 +44,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
// create audio handler
var audio = new maximJs.maxiAudio();
// initialise audio
audio.init();
// create oscillator
var mySine = new maximJs.maxiOsc();
audio.play = function(){
// direct value to output
this.output = mySine.sinewave(440);
}
</script>
</head>
......@@ -68,13 +69,16 @@ audio.play = function(){
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
// create audio handler
var audio = new maximJs.maxiAudio();
// initialise audio
audio.init();
// create oscillator
var mySine = new maximJs.maxiOsc();
audio.play = function(){
// direct value to output
this.output = mySine.sinewave(440);
}
</pre>
......
......@@ -46,7 +46,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
var audio = new maximJs.maxiAudio();
// initialise audio
audio.init();
var mySine = new maximJs.maxiOsc();
......@@ -70,15 +69,15 @@ These sines are taking a beating...
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
// initialise audio
maximJs.maxiAudio.init();
var audio = new maximJs.maxiAudio();
audio.init();
var mySine = new maximJs.maxiOsc();
var myOtherSine = new maximJs.maxiOsc();
maximJs.maxiAudio.play = function(){
// these two sines will beat together. They're now a bit too loud though..
output = mySine.sinewave(440) + myOtherSine.sinewave(441);
audio.play = function(){
// these two sines will beat together. They're now a bit too loud though..
this.output = mySine.sinewave(440) + myOtherSine.sinewave(441);
}
</pre>
</body></html>
......@@ -45,7 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
var audio = new maximJs.maxiAudio();
// initialise audio
audio.init();
//This shows how to use maximilian to do basic amplitude modulation
......@@ -56,8 +55,6 @@ audio.play = function(){
// these two sines will beat together. They're now a bit too loud though..
this.output = mySine.sinewave(440)*myOtherSine.sinewave(1);
}
</script>
</head>
......@@ -70,20 +67,16 @@ audio.play = function(){
Basic amplitude modulation
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
// initialise audio
maximJs.maxiAudio.init();
var audio = new maximJs.maxiAudio();
audio.init();
//This shows how to use maximilian to do basic amplitude modulation
var mySine = new maximJs.maxiOsc();
var myOtherSine = new maximJs.maxiOsc();
maximJs.maxiAudio.play = function(){
audio.play = function(){
// these two sines will beat together. They're now a bit too loud though..
output = mySine.sinewave(440)*myOtherSine.sinewave(1);
}
this.output = mySine.sinewave(440)*myOtherSine.sinewave(1);
}
</pre>
</body></html>
......@@ -45,7 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
var audio = new maximJs.maxiAudio();
// initialise audio
audio.init();
//This shows how to use maximilian to do basic amplitude modulation
......@@ -57,8 +56,6 @@ audio.play = function(){
// these two sines will beat together. They're now a bit too loud though..
this.output = mySine.sinewave(440)*myOtherSine.sinewave(myPhasor.phasor(0.1,0,440));
}
</script>
</head>
......@@ -73,7 +70,6 @@ audio.play = function(){
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
var audio = new maximJs.maxiAudio();
// initialise audio
audio.init();
//This shows how to use maximilian to do basic amplitude modulation
......@@ -85,6 +81,5 @@ audio.play = function(){
// these two sines will beat together. They're now a bit too loud though..
this.output = mySine.sinewave(440)*myOtherSine.sinewave(myPhasor.phasor(0.1,0,440));
}
</pre>
</body></html>
......@@ -45,7 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<!-- Our javascript code -->
<script type="text/javascript">
var audio = new maximJs.maxiAudio();
// initialise audio
audio.init();
//This shows how to use maximilian to do basic amplitude modulation
......@@ -57,8 +56,6 @@ audio.play = function(){
this.output = mySine.sinewave(440+(myOtherSine.sinewave(1)*100));
}
</script>
</head>
......@@ -73,13 +70,16 @@ audio.play = function(){
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
var audio = new maximJs.maxiAudio();
audio.init();
//This shows how to use maximilian to do basic amplitude modulation
var mySine = new maximJs.maxiOsc();
var myOtherSine = new maximJs.maxiOsc();
function play(){
audio.play = function(){
// these two sines will beat together. They're now a bit too loud though.
output = mySine.sinewave(440+(myOtherSine.sinewave(1)*100));
this.output = mySine.sinewave(440+(myOtherSine.sinewave(1)*100));
}
</pre>
......
......@@ -71,14 +71,17 @@ audio.play = function(){
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
var audio = new maximJs.maxiAudio();
audio.init();
//This shows how to use maximilian to do basic frequency modulation
var mySine = new maximJs.maxiOsc();
var myOtherSine = new maximJs.maxiOsc();
var myLastSine = new maximJs.maxiOsc();
var myPhasor = new maximJs.maxiOsc();
maximJs.maxiAudio.play = function(){
output=mySine.sinewave(myOtherSine.sinewave(myLastSine.sinewave(0.1)*30)*440);//awesome bassline
audio.play = function(){
this.output=mySine.sinewave(myOtherSine.sinewave(myLastSine.sinewave(0.1)*30)*440);//awesome bassline
}
</pre>
</body></html>
......@@ -56,8 +56,6 @@ audio.play = function(){
CurrentCount = Math.floor(myCounter.phasor(1, 1, 9));//phasor can take three arguments; frequency, start value and end value
output=mySquare.square(CurrentCount*100);
}
</script>
</head>
......@@ -84,6 +82,5 @@ audio.play = function(){
CurrentCount = Math.floor(myCounter.phasor(1, 1, 9));//phasor can take three arguments; frequency, start value and end value
output=mySquare.square(CurrentCount*100);
}
</pre>
</body></html>
......@@ -78,6 +78,24 @@ audio.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 myCounter = new maximJs.maxiOsc();
var mySwitchableOsc = new maximJs.maxiOsc();//these oscillators will help us count and make sound.
var CurrentCount;//we're going to put the current count in this variable so that we can use it more easily.
var myOscOutput;//we're going to stick the output here to make it easier to mess with stuff.
audio.play = function(){
CurrentCount=Math.floor(myCounter.phasor(1, 1, 9));//phasor can take three arguments; frequency, start value and end value.
if (CurrentCount<5){//simple if statement
myOscOutput=mySwitchableOsc.square(CurrentCount*100);
}
else if (CurrentCount>=5){//and the 'else' bit.
myOscOutput=mySwitchableOsc.sinewave(CurrentCount*50);//one osc object can produce whichever waveform you want.
}
this.output=myOscOutput;//point me at your speakers and fire.
}
</pre>
</body></html>
......@@ -68,10 +68,7 @@ audio.play = function(){
myOscOutput=mySwitchableOsc.sawn(myArray[CurrentCount]);//one osc object can produce whichever waveform you want.
}
this.output=myOscOutput;//point me at your speakers and fire.
}
</script>
</head>
......@@ -85,21 +82,30 @@ audio.play = function(){
</p>
<pre class="prettyprint lang-js linenums:true" id="quine" style="border:4px solid #88c" >
var audio = new maximJs.maxiAudio();
audio.init();
//these oscillators will help us count and make sound.
var myCounter = new maximJs.maxiOsc();
var mySwitchableOsc = new maximJs.maxiOsc();//these oscillators will help us count and make sound.
var mySwitchableOsc = new maximJs.maxiOsc();
var another = new maximJs.maxiOsc();
var CurrentCount;//we're going to put the current count in this variable so that we can use it more easily.
var myOscOutput;//we're going to stick the output here to make it easier to mess with stuff.
maximJs.maxiAudio.play = function(){
CurrentCount=Math.floor(myCounter.phasor(1, 1, 9));//phasor can take three arguments; frequency, start value and end value.
var myArray=[100,200,300,400,300,200,100,240,640,360];
audio.play = function(){
CurrentCount=Math.round(myCounter.phasor(1*((another.sawn(0.1)+1)/2), 1, 9));//phasor can take three arguments; frequency, start value and end value.
if (CurrentCount<5) {//simple if statement
myOscOutput=mySwitchableOsc.square(myArray[CurrentCount]);
}
else if (CurrentCount>=5) {//and the 'else' bit.
if (CurrentCount<5){//simple if statement
myOscOutput=mySwitchableOsc.square(CurrentCount*100);
myOscOutput=mySwitchableOsc.sawn(myArray[CurrentCount]);//one osc object can produce whichever waveform you want.
}
else if (CurrentCount>=5){//and the 'else' bit.
myOscOutput=mySwitchableOsc.sinewave(CurrentCount*50);//one osc object can produce whichever waveform you want.
}
output=myOscOutput;//point me at your speakers and fire.
this.output=myOscOutput;//point me at your speakers and fire.
}
</pre>
</body></html>
......@@ -107,6 +107,10 @@ if (CurrentCount<5){
</p>
<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 mySwitchableOsc = new maximJs.maxiOsc();//
......@@ -115,15 +119,15 @@ var myOscOutput,myCurrentVolume;//
var myEnvelope = new maximJs.maxiEnv();
function setup(){
//Timing is in ms
myEnvelope.setAttack(0);
myEnvelope.setDecay(1); // Needs to be at least 1
myEnvelope.setSustain(1);
myEnvelope.setRelease(1000);
}
maximJs.maxiAudio.play = function(){
//Timing is in ms
myEnvelope.setAttack(0);
myEnvelope.setDecay(1); // Needs to be at least 1
myEnvelope.setSustain(1);
myEnvelope.setRelease(1000);
audio.play = function(){
//notice that we feed in a value of 1. to create an envelope shape we can apply later.
myCurrentVolume=myEnvelope.adsr(1.,myEnvelope.trigger);
......@@ -150,7 +154,7 @@ if (CurrentCount<5){
myOscOutput=mySwitchableOsc.sinewave(CurrentCount*50);//one osc object can produce whichever waveform you want.
}
output=myOscOutput*myCurrentVolume;//left speaker
this.output=myOscOutput*myCurrentVolume;//left speaker
}
</pre>
</body></html>
......@@ -127,14 +127,15 @@ maximJs.maxiArray.prototype.clear = function(useSq){
// tools
maximJs.maxiTools = function(){};
maximJs.maxiTools.arrayOfObj = function(obj, num){
var array = [];
for(var i = 0; i < num; i++){
array.push(new obj());
}
return array;
};
// not sure this is good
// maximJs.maxiTools.arrayOfObj = function(obj, num){
// var array = [];
// for(var i = 0; i < num; i++){
// array.push(new obj());
// }
// return array;
// };
maximJs.maxiTools.getArrayAsVectorDbl = function(arrayIn){
var vecOut = new Module.VectorDouble();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment