Shop OBEX P1 Docs P2 Docs Learn Events
SX48 mini MIDI music player. — Parallax Forums

SX48 mini MIDI music player.

Lord SteveLord Steve Posts: 206
edited 2010-12-04 03:10 in Robotics
This project uses an SX48 microcontroller at 75 MHz·as an 8-channel frequency-synthesis music player with three instruments (selectable per channel): square wave, triangle wave, sinwave.· Each channel can play an different pitch.· The desired pitch is used to lookup how far to step along the sample waveform each 1/44100 second tick, thereby playing back the waveform at that pitch's frequency.· The waveform is 1024 bytes long (only one-quarter is stored).· The music data comes from stripping a bare-bones set of events from a MIDI file:· NOTE ON, NOTE OFF, TEMPO, PROGRAM CHANGE.· Each active channel contributes a 13-bit, signed, 2's complement sample to a 16-bit accumulator.· The accumulator is then DC-biased to an unsigned format and then the most-significant 12-bits are serially written to a 12-bit MCP4922 dual serial DAC.· (I only use one channel).· The output sample frequency is approximately 44.1 KHz.· The actual value is (75,000,000 / 8) / 212.· The output of the DAC is fed to one side of a 10K trimpot, the other end being tied to ground and the wiper being the input to the positive input of an LM386 audio amplifier.· The trimpot is used to attentuate the DAC output to a level that the LM386 can amplify properly with its default minimum gain of 20.· As can be seen in the schematic, the LM386 is in a minimal configuration.· The output of the LM386 is connected to an 8 ohm speaker via a 220 uF polarized electrolytic capacitor.· This capacitor blocks the DC bias of the previous stages.· This is important to not damage the coil of your speaker.· (A constant current through the coil is bad.· It could melt the coil.)· It is worth noting that the output of the LM386 is DC-Biased to one half of the input supply voltage.· This project uses 5 volts.· I wrote the little doodad song and ran·the MIDI·file·through·my C++ hack job of a program that created the SX-friendly events file.

I put a small video on YouTube to demonstrate.· Also, I have attached a rough schematic and all SX code files.

http://www.youtube.com/watch?v=Gw6-UOhNJck

Comments and corrections are welcome.

Post Edited (Lord Steve) : 3/21/2008 3:45:16 AM GMT

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-03-21 14:03
    Steve,

    Very nice project! As a musician who plays keyboards I can appreciate anything with MIDI.

    One note I wanted to make…It looks like you’re powering the PDB from the SX48 proto board…I’m not sure on whether that regulator on the PDB can handle that scenario.· The one on the SX48 proto board can (being powered from Vdd), but we never checked into the one on the PDB.· I would be powering the PDB and sending Vdd to the SX48 proto board since the PDB regulator can also handle more current.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support


    Post Edited (Chris Savage (Parallax)) : 3/21/2008 2:10:03 PM GMT
  • Lord SteveLord Steve Posts: 206
    edited 2008-03-21 14:28
    Thanks for your words, Chris.· [noparse]:D[/noparse]· The PDB is powered by connecting the proto board's Vin to the PDB's Vin.· I believe all this does is bypass the power switch on the PDB.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-03-21 15:22
    Ah yes, I had forgotten about the extra VIN connection at the bottom. =)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2008-04-05 02:39
    Lord Steve,

    I enjoyed looking at your project. Excellent job! I wonder what the propeller chip could do with that assignment turn.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Aka: CosmicBob
  • Lord SteveLord Steve Posts: 206
    edited 2008-04-05 16:00
    Thanks for looking. [noparse]:)[/noparse]

    I think the propeller could do MIDI in and at least 16-note polyphony.
  • JLSJLS Posts: 76
    edited 2010-11-24 00:23
    Hi all

    Is possible port this code to Propeller chip ?

    Thanks help
  • Lord SteveLord Steve Posts: 206
    edited 2010-11-24 20:59
    I think someone already made a synth for the Prop. Check the Object Exchange (OBEX). I think it was ALE that made it.
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2010-12-04 03:10
    re:I think someone already made a synth for the Prop.

    Music Synthesizer object with General MIDI sound set


    http://forums.parallax.com/showthread.php?111867-Music-Synthesizer-object-with-General-MIDI-sound-set&highlight=synth+Prop

    Toughts about a Propeller based synthesizer


    http://forums.parallax.com/showthread.php?126780-Toughts-about-a-Propeller-based-synthesizer&highlight=6581
Sign In or Register to comment.