The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
Not very practical you say... Well, you could use it for a doorbell playing music whenever somebody's at the door. Other possible applications would be whenever you need audible notification. For instance when receiving a mail, sms or similar - you could have the
The Netduino could be sitting on the wall in your hallway and you could issue HTTP PUT requests to it from whatever networked device you have.
I've got a GSM-board that I'm thinking of using (some day...) and your code might come in handy.
You could also try something like they did on the SID chip of the old C64. I think they switched between different octaves rather quickly during each note to create kind of a vibrating note instead of a regular continuous note. This produced very characteristic sounding chords that became somewhat of a C64 trademark.
I once saw some code to play 8 channel polyphonic sound using a single PWM output. They used a mixer, a lot like yours I guess, that probably switched between different PWM frequencies during overlapping notes.
where he creates audio from ONE or TWO digital PIC outputs.
Its actually a ONE-BIT output from a standard 8-bit audio file....
I downloaded the encoding program, and it sounds "ok"....
but, the key to that requires a stable clock frequency to recreate the sound-stream.
I don't think the Netduino can sustain a 16khz or 44khz data stream with any accuracy to be able to make those sounds.
Originally, with the multiple threads, I was hoping that the timing would be good enough,
to be able to create some sort of a MIDI equivalent.
But, I don't think that is possible, unfortunately, without one of the add-on shields.
SO..ooooooo .... instead:
I did make a different version that generates three notes at the same time
(root, one octave down, and two octave down)
all in the same thread. This maintains the timing needed.
Much, much better results than the multi-threading method.
NOTE: This is still using PWM outputs 11, 10, and 9, so you need to use a 120ohm resistor (or so) from each input, joined together to go to the speaker....
I also added some more example songs, so that there is now 50 to cycle through :-)
And --- similar to my RTTTL player, I am using all 6 of the PWM channels.
An easy way of mixing them is to use a 110ohm resistor from each channel tied together, and then going to the + speaker lead. I also have a potentiometer connected as a main volume control.
(in this video, I only am using 4 channels. You can select the Maximum to use in the program)
The MIDI file should be loaded onto the SD card.
You can also use a HEX convertor, such as HxD Hex Editor, and embed the BYTES into the program:
So you implemented a MIDI file parser on the Netuino then?
I should really try and get this running on the mini, however I need to connect an SD card reader for the MIDI files and suddenly it would require more time than I can afford.
Another idea would be to also implement a real time MIDI player using the UART @ 31250 8N1 connected to a PC and later to the MIDI out of a MIDI enabled keyboard or even a digital piano. This would omit the need of an SD card reader plus I guess parsing MIDI-packets over serials is simpler that parsing MIDI files.
There are cheap separate piano-looking MIDI keypads like this one from Akai:
A bit pointless perhaps but it would be so cool for me to sit on my wife's digital piano and play through a beeper. Love to hear what it would sound like.
Do you implement the effects of notes being played according to how hard the "key was pressed" too and what about not bending and such?
I trust there are no drums, that would be asking too much of course.
From the images, I see you snuck a potentiometer directly into the N+ header, I suppose this is for volume?
Do you use some kind of amplifier to drive that (8 ohm?) loudspeaker or are you actually driving it directly from the PWM pis via the "resistor mixer" - I didn't think that was possible due to the currents and inductiveness of the speaker?
There are these cheap 2 x 3W miniature D-class amplifiers:
Ok, but even as MIDI files are very compact (especially when comared to digitally sampled music), can you really fit whole songs onto flash?
I've been fiddeling with MIDI a bit myself but mostly on the hardware side of things, which (as you know) is basically only 32150 baud 8N1 serial communication.
I still can't help wondering what real time MIDI would sound like when playing it on a digital piano.