My first project for learning the Playdate API and re-learning Lua: Music Box
Place notes on a grid and turn the crank to hear what you created. This was just one of the first things that popped in my head when thinking of uses for the crank.
Most recent version (includes source):
MusicBox_v0.2.0.zip (18.6 MB)
Older versions (incl. source):
MusicBox_v0.1.0.zip (240.9 KB)
- Will not run at stable 30 fps. I blame the particle effects.
- (FIXED) Instruments sound kinda bad
What I want to implement:
- (DONE) Autosave on quit, so your creation stays between sessions
- (DONE) Once there is Autosave then there probably needs to be a “clear” function that clears the whole track
- (DONE) Better instruments: currently I’m using sound effects from sfxr and just adjust their rate in code, probably gonna search for better sound effects and have the sounds be pitch shifted beforehand and not in code
- (DONE) Show in the timeline at the bottom where the current screen is at
I took a crack at improving the instruments. First hurdle was finding recordings of instruments playing specific pitch/frequency. I found FreeWaveSamples.com which provides high quality recordings of instruments, but there is only one sample/pitch per instrument.
With a bit of research of how scales work, and the help of Audacity’s “Effect > Change Pitch” feature I managed to create 8 sound effects for a full musical scale. (it was important to select the “Use high quality stretching (slow)” checkbox, since otherwise it had very noticeable artifacts)
However I had problems when saving them. When saving them as “IMA ADPCM” as recommended by the SDK Docs, I had a very noticable ‘click’ at the end of the sound effect when playing it on the device. So I chose to save them as “Signed 16-bit PCM” which eliminated the ‘clicking’ problem. However this is an uncompressed format and increases file size significantly (~500kB vs ~150kB).
It doesn’t seem to happen anytime something is saved as “IMA ADPCM”, only seems to happen after applying the “Change Pitch” effect.
I’m not gonna lose any more sleep about this and just accept the larger filesize. (just barely still fit under the 20MB upload limit for files here on the forum)
The instruments included are (for no particular reason):
- drums (various percussion)
- steel drums
Everything is autosaved on quit now and loaded again when opening the game. Also used the
playdate.showGameOptions callback and the
playdate.ui.gridview to show the player a small menu where they can clear the whole track.
Besides the performance issue I’ve pretty much addressed everything I wanted to. Probably gonna try to see what exactly is causing the largest frame drops to learn how to prevent those problems, but I’m fine if it runs mostly stable under normal circumstances.
MusicBox_v0.2.0.zip (18.6 MB)
This is very cool!
Would love to see it expanded upon.
Maybe even with a synth instrument/sample creator.
I don’t really have any experience making synth editors, and my audio knowledge is lacking in some places. So I don’t think I’m able to program something like sfxr/bfxr. But the SDK seems to already expose a lot of options for synths, so what I probably can do is simply create an UI that exposes all those functions to the end user (which doesn’t seem to exist in the sample projects, strangely enough, as far as I can tell).
Also I could surely imagine providing one instrument that plays a sample recorded with the microphone. Then the only question is, how to provide the different pitches for the full 8 notes of the musical scale. I’m doubtful that
setRate from the
SamplePlayer is sufficient.
Take alook at https://en.wikipedia.org/wiki/Scientific_pitch_notation
which is what I have been using to code the pitches of some simple notes I play in my game.
Not specific to samples but perhaps useful.
Hey, thanks for sharing this @toni! I did a quick update to MusicBox to make it work with the newly released public SDK and it was really fun to see it work (it was a 2 line change..!)
.pdx & source:
MusicBox_v0.2.1.zip (18.7 MB)
Very nice! I sadly have no time for playdate development at the moment, so this is very appreciated.
Now that the SDK is public, I could probably put my small projects on github or something. Would make it easier to share the code.
Quirky but fun! Kinda confused about playback... keeping tempo on a PS4 controller isn't easy! XD
But I love this concept. Thanks for updating it to the latest release. Excited to see more from you.
Will there be an itch page or is this the only place you are gonna release this app? This app looks awesome and we wanna link to your app from the playdate wiki, though linking to the devforum might not be a best approach due to login requirements.
I was actually thinking about releasing all my early prototypes (including this) as one bundle on itch. Just need to update them all to the newest SDK.
I'm not sure when I will get to that though, but I should probably try to do it before the Playdate will finally get in the hands of more people.
We've been working on a shell project to help run multiple related Playdate games from a single "launcher" UI. It's for a collection of 3 Game Jam games we made last year and are porting to Playdate now, to help us learn the ropes of the SDK. I can let you know when it's finished and share it in case that's something that would help expedite your bundling process.
I was just thinking of putting a bunch of pdx files in a zip file. Although it might be annoying for people to trash their game list with a bunch of prototypes. But that's something that I rather would want to be solved by Panic by just giving us tools to better organize our games (folders, tags, manual sorting).
Your launcher looks nice, but probably more than I need. Additionally I have some C projects, so that might be a problem if it requires Lua.