I THINK I am pretty much finished with my version of a MIDI Player.
I have posted a YouTube video here:
And, a code page on CodePlex:
http://netduinop2mid...r.codeplex.com/
Basically, this program reads a Standard MIDI file (*.mid) from the SD-card, parses it, and plays the song using all 6 of the PWM outputs. So, that gives you up to 6 note POLYPHONY. This can also be set to use less channels (1-6).
I had posted a video earlier with a simple, crude test using resistors to mix the "audio" out to the speaker... but, it obviously was not the correct way to do such a thing. So, I created a proper audio mixing circuit using an OP-AMP. This mixes all 6 PWM signals and outputs to a 1/8" jack, which can be connected to headphones or as line-level output. It still isn't perfect, but surprisingly it sounds pretty darn good.
The code can be set up to read all *.mid files at the root of the SD card and play in a row, or just play a single file. There is also a switch on the board to SKIP SONGS.
I have optimized the code as best as I can, and it plays pretty smooth. I am not very experienced, so I'm sure there are things that I do not know yet... but I am definitely learning
Here is an image of the Op Amp shield completed: http://ppl.ug/Kjn27rtVTPM/
(it ended up being a little sloppier than my original, due to necessary changes )
------------------------------------------
Here is the TINA-TI simulator file: http://ppl.ug/6lKepOPeloI/
and an image of the SCHEMATIC: http://ppl.ug/jt5jry3cboM/
If you haven't heard of it, this is a great program offered FREE by Texas Instruments (TI):
http://www.ti.com/tool/tina-ti to build and simulate electronic circuits.
---------------------------------------
BTW:
In the video:
I have the 1/8" jack connected as a line-level output to record. I am using the USB connection ONLY to show the debug results on the screen. There is a 12volt supply connected for primary power. I found out that 5volt USB power is very "dirty" and NOT suitable for audio applications at all. The power input is further regulated on the Netduino board, giving very clean results. I also added a 0.1uF cap from pin 4 to 8 on the buttom of the LM358 op-amp IC.
-Ron