ok. changed the setPhase to 0 and it works. but not sure if the frequency is OK. it sounds very high to me.
2 oscs 20+49Hz for a bassdrum sample sketch.
/* Example playing an enveloped noise source
* using Mozzi sonification library.
*
* Demonstrates Ead (exponential attack decay).
*
* Circuit: Audio output on digital pin 9 (on a Uno or similar), or
* check the README or
http://sensorium.github.com/Mozzi/ *
* Mozzi help/discussion/announcements:
*
https://groups.google.com/forum/#!forum/mozzi-users *
* Tim Barrass 2012.
* This example code is in the public domain.
*/
#include <MozziGuts.h>
#include <Oscil.h> // oscillator template
#include <tables/sin1024_int8.h> // sine table for oscillator
#include <Ead.h> // exponential attack decay
#include <EventDelay.h>
#define CONTROL_RATE 256 // powers of 2 please
Oscil <SIN1024_NUM_CELLS, AUDIO_RATE> aSin(SIN1024_DATA);
Oscil <SIN1024_NUM_CELLS, AUDIO_RATE> bSin(SIN1024_DATA);
EventDelay <CONTROL_RATE> kDelay; // for triggering envelope start
Ead kEnvelope(CONTROL_RATE); // resolution will be CONTROL_RATE
int gain;
void setup(){
startMozzi(CONTROL_RATE);
aSin.setFreq(49);
bSin.setFreq(20);
kDelay.start(1000);
}
void updateControl(){
// jump around in audio noise table to disrupt obvious looping
//aNoise.setPhase(rand((uint)WHITENOISE8192_NUM_CELLS));
//aSin.setPhase(0);
//bSin.setPhase(0);
if(kDelay.ready()){
aSin.setPhase(0);
bSin.setPhase(0);
unsigned int attack = 10;
unsigned int decay = 400;
unsigned int duration = attack +decay ;
kEnvelope.start(attack,decay);
kDelay.start(duration+100);
}
gain = (int) kEnvelope.next();
}
int updateAudio(){
int out=aSin.next();
+bSin.next();
return (gain*out>>4);
}
void loop(){
audioHook(); // required here
}