Powered by Nerd points out this project from Kevin Weekly, the Random Music Box uses a relatively low part count to generate a pleasant pseudo-random song. The cardboard ‘kick drum’ is a nice touch!
14 thoughts on “PIC-based Melody Generator”
Comments are closed.
Impressive! Double points for coding in assembly. Or maybe half credit. I’m not sure, but I don’t want to look at the source code anymore, haha.
I didn’t watch the entire video, but does it explain why the poster bothered to obscure the labeling on the top of his “pic” chip? AFAIK there’s no way to identify someone from the numbers on a chip like that, short of a brute-force police style process of elimination (lot code sold to vendor x, vendor x sold to reseller y, reseller y sold to customer z)
Either that, or it is not the same chip that it is claimed to be?
Does this play notes at random or choose at random from a few stored songs? The docs aren’t clear and I haven’t done pic asm since I discovered JAL about 6 years ago :).
I’m interested espeically since I have an almost full rail for 16F648’s from before I switched to Arduino. I wouldn’t mind something nice and simple to do with those since for new coding I’m going to use the Arduino environment.
a little confused on that point myself
The source code is not easy to understand, being messy ASM, but he seems to use standard chord progressions : major, minor, blues, etc, either 4 or 8 notes long. He picks a random one every 64 beats. Every 4 beats he gets the next note from the current chord progression (root). Every beat, he picks a random note (melody), and plays simultaneously root, root+4, root+7, melody. For minor chords he plays instead root, root+3, root+7, melody.
A fifth voice is used for the bass.
I lack musical knowledge to understand how all of this fits together, but it does sound melodious.
He uses TMR1 as his RNG so it’s not actually random.
(author here) Yeah, I “code for the moment” and have trouble understanding the asm later myself.
Something to add to what vivi said: The five square waves are mixed outside of software to make things easy. The basic idea for generating the notes is that the TMR1 counter counts up at a consistent rate and I just toggle after so many timer ticks (pre-calculated into per_table). Of course there’s a lot of junk to do with rollover and whatnot- here MPLAB’s simulator with logic trace was super helpful.
could someone post the asm code here please? cheers