-
• #2
I'd never come across beepbox - that's really cool!
Looking at the JSON it looks like you'll want to scan over it and change its form a bit first - basically go over all of
patterns.notes.points
and write them intotimes[patterns.notes.points.tick]=patterĀns.notes.pitches
.Then it'd just be a matter of using
setInterval
to scan over thetimes
array one item at a time and do a beep if one was required.Of course you could use Waveform too, but I'd start out simple :)
-
• #3
I'll give it a go. I don't know how they do the 'trill' type sound when two notes are to be played together. I assume they alternate between the two notes very fast and setInterval may not be fast enough. Maybe this isn't how it's done but it doesn't sound like a proper chord. My music knowledge very limited!
-
• #4
In hardware there's a good hack for two notes at the same time - which is just to attach the piezo to two signal pins and use PWM on both (= two channels).
However if you use
Waveform
then that automatically does polyphonic sounds - so you just need multiple Waveform classes and you can set them all playing on the same pin at once (although you have to keep the sample rate low - 4kHz or so - to make sure there's enough CPU time). -
• #5
That's a good tip to use two output pins -- will try it!
I have a little piezo speaker hooked up to a Pico. I'd like to generate some simple 8-bit game-type sounds for it.
What I'd really like to be able to do is export sounds created on http://www.beepbox.co (they have JSON export) and add them to Espruino projects.
The sound would need to play in the background so I think this would need to be implemented as some kind of task, but beyond that am not sure where to start.
Any ideas appreciated!