This uses a Pico with PWM outputs connected to a point using 10 k resistors. The point connects to ground through a parallel combination of a 10k resistor and 1 1.0 uf Capacitor.
An isolated amplifier input is connected beween the point and ground.
A USB microphone and Audacity was used to record the resulting music link is here:
The Rests in the melody seemed to be missing. This is the fix. Relocate the getTime().
if (this.onoff>0) return;
this.start=getTime(); //moved this from below
if(note===null)return; // a rest
this.freq(261.63*tone); //C4 Middle C Midi note 60
// this.start=getTime(); //move this from here
Thanks for posting this up! I kind of wish I was more musical - I think there's a lot of fun stuff you can do with Espruino.
Just to add - if you're using a piezo speaker then you can connect it between two PWM outputs to get two different frequencies at the same time. Obviously what you've done is much better for more channels or an amplified output though!
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem