-
• #2
Oops
The Rests in the melody seemed to be missing. This is the fix. Relocate the getTime().
music.prototype.play=function(note){ // console.log(note,this.Spkr); if (this.onoff>0) return; console.log(note,midi2tone(note)); var octave=Math.log(2); var halftone=octave/12; this.start=getTime(); //moved this from below if(note===null)return; // a rest note=note-60; var tone=Math.exp(note*halftone); this.freq(261.63*tone); //C4 Middle C Midi note 60 // this.start=getTime(); //move this from here };//end play
-
• #3
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!
Musical Steganography
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:
EspruinoSteganography1
Files:
Steganongraphy1.js
1 Attachment