Musical Spark Plugs

Thread Starter

geekoftheweek

Joined Oct 6, 2013
1,169
Just a little something I threw together a few years back. After some paint, LEDs, and some 3D printed parts I thought I would make another video for kicks. It still could use some fine tuning, but I need to get on with some other projects instead of spending much more time on this. I had originally wanted to find some wizard or the like figurines and have them arcing between their hands, but Kirk and Spock were the best I could find.

0:00 -- Reveille
0:25 -- Flight of the Bumblebee -- Rimsky Korsakov
1:34 -- Irish Jig
4:14 -- The Entertainer -- Scott Joplin
5:33 -- Hungarian Dance No. 5 -- Johannes Brahms
6:11 -- When the Saints Come Marching In
6:43 -- A couple pictures of the unit

 

Thread Starter

geekoftheweek

Joined Oct 6, 2013
1,169
Just a bit of an overview of how it works...

The music is from MIDI files. For those not familiar it is a protocol used by musical instruments like synthesizers to communicate with computers or other instruments. The files are more or less a series of messages that the device would use to reproduce sound. There are a few different messages, but I am only parsing the "note on" and "note off" messages. A "note on" message contains a pitch number that corresponds to a musical note and a velocity or volume... it would be more or less how hard to hit a piano key. The "note off" is just the pitch number to turn off.

Instead of a physical connection between a computer and instrument I was able to create a program that acts as a MIDI reader that "plugs" into the computer's sound system. Using a separate MIDI player application to play the files I was able to capture the messages, convert them to timer values and send them to a PIC18F24Q10 that uses them as values for the compare function of the CCP to toggle the pin. The original goal was to use the velocity part of the message to vary the spark intensity. It will take some time and research to find the right values to use. I have already programmed the PIC to load different values for the the compare function based on whether the pin is on or off.

The LEDs are also run off the MIDI file on the songs that they change. I created two more tracks in the file (one for the front row, and one for the back) and edited the values to change the LEDs. They are actually strips of WS2812 that are in a printed mountning bracket. The velocity values have a range of 0 - 127 so I simply multiplied them by 2 to vary the LEDs. A PIC18F24K22 handls the LEDs. On the songs that don't change while playing the LEDs are set using a basic program that changes them in between playing a song.

The PICs are connected through the I2C channel available in the DVI port of a laptop.
 

Thread Starter

geekoftheweek

Joined Oct 6, 2013
1,169
@DNA Robotics in ways I like yours better. One problem I have is I can't do chords on the individual plugs. I tried alternating between different frequencies after each "wave", but it wasn't the same as two notes being played at the same time.

I've spent more time than I want to admit watching various things playing Star Wars. In the description of one CNC lathe was the phrase "We won't stop until everything plays this tune"

I wanted to add some stepper motors to the mix, but the ones I have on hand just aren't loud enough.
 

MisterBill2

Joined Jan 23, 2018
17,718
Just a bit of an overview of how it works...

The music is from MIDI files. For those not familiar it is a protocol used by musical instruments like synthesizers to communicate with computers or other instruments. The files are more or less a series of messages that the device would use to reproduce sound. There are a few different messages, but I am only parsing the "note on" and "note off" messages. A "note on" message contains a pitch number that corresponds to a musical note and a velocity or volume... it would be more or less how hard to hit a piano key. The "note off" is just the pitch number to turn off.

Instead of a physical connection between a computer and instrument I was able to create a program that acts as a MIDI reader that "plugs" into the computer's sound system. Using a separate MIDI player application to play the files I was able to capture the messages, convert them to timer values and send them to a PIC18F24Q10 that uses them as values for the compare function of the CCP to toggle the pin. The original goal was to use the velocity part of the message to vary the spark intensity. It will take some time and research to find the right values to use. I have already programmed the PIC to load different values for the the compare function based on whether the pin is on or off.

The LEDs are also run off the MIDI file on the songs that they change. I created two more tracks in the file (one for the front row, and one for the back) and edited the values to change the LEDs. They are actually strips of WS2812 that are in a printed mountning bracket. The velocity values have a range of 0 - 127 so I simply multiplied them by 2 to vary the LEDs. A PIC18F24K22 handls the LEDs. On the songs that don't change while playing the LEDs are set using a basic program that changes them in between playing a song.

The PICs are connected through the I2C channel available in the DVI port of a laptop.
Thanks for the explanation of how MIDI works. I had not bothered to research it previously, it makes perfect sense though.
 

Thread Starter

geekoftheweek

Joined Oct 6, 2013
1,169
Thanks for the explanation of how MIDI works. I had not bothered to research it previously, it makes perfect sense though.
It's pretty simple really. I more or less stumbled on it while trying to find sheet music for an earlier rendition of the project. A lot of sites had MIDI downloads along with the sheets. I can read some sheet music (bass) and with a little patience I can sort out the treble.
 

MisterBill2

Joined Jan 23, 2018
17,718
I can see that MIDI files for keyboard instruments could become rather complex in a hurry. And certainly for producing the multiple tones at the same time. So there must be a scheme for the midi data to be delivered much faster than "real time."
 

Thread Starter

geekoftheweek

Joined Oct 6, 2013
1,169
I never really looked into the electrical side of things before. It does seem like there could be issues with sending 16 channels through the same cord.
What really has me curious is back in the day when MIDI was developed computers were pretty slow themselves.

It does appear that a basic message between devices is only three bytes, but still...

Thanks for sending me down another rabbit hole
 

MisterBill2

Joined Jan 23, 2018
17,718
Possibly there are additional codes for chords. That would be my first guess. And even "back then", machine code would execute quite rapidly. Even a 2 MHz 6809 processor was quite fast, (relatively speaking)
 

Thread Starter

geekoftheweek

Joined Oct 6, 2013
1,169
And even "back then", machine code would execute quite rapidly. Even a 2 MHz 6809 processor was quite fast, (relatively speaking)
I did kind of consider that... I did have some pretty impressive games for a C64 other than it took 15 minutes to load off the cassette... the wait was pure agony!! Unfortunately I was a bit too young to really understand the manual and never got very far with it before it went wonky.

It would be interesting to pick the brains of people familiar with what it really could do.
 
Top