Shop OBEX P1 Docs P2 Docs Learn Events
Convert a "MID" format MIDI file for playback by the BS2? — Parallax Forums

Convert a "MID" format MIDI file for playback by the BS2?

Vern GranerVern Graner Posts: 337
edited 2007-07-14 01:54 in BASIC Stamp
I have a project where I need a one-button solution to play back a classical music composition. I've build a small enclosure with a BSII with a MIDI out jack to drive a small MIDI keyboard.

I have had no trouble producing MIDI output (there's lots of good documentation on how to do this) from this device. However, what I'd like to NOT have to do is note-by-note enter in the music as data statements, but would rather convert a MID file I have of the song.

I've done a bit of looking, but couldn't find a way to read a MID file so I could extract the note values from it. An example of the file I'm talking about is here:

http://www.bachcentral.com/invent/invent8.mid

So, does anyone know of a way to convert the above file type to a bunch of BS2 data statements? [noparse]:)[/noparse]

TIA!

Vern

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Vern Graner CNE/CNA/SSE    | "If the network is down, then you're
Senior Systems Engineer    | obviously incompetent so why are we
Texas Information Services | paying you? Of course,if the network
http://www.txis.com        | is up, then we obviously don't need
Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG

Comments

  • pwillardpwillard Posts: 321
    edited 2007-07-13 19:28
    Unless your song is really short, wouldn't the limited memory space of the Stamp be an issue here? You might have to resort to pulling a stream of data out of an external memory device like an SPI memory. In that case, as long as you can generate MIDI from the stream you pull from memory using a "readable" format you have a lot of options.

    Sort of like what this guy did at his website: http://garden.qc.cuny.edu:9200/articles/MIDI Scores.html
  • Vern GranerVern Graner Posts: 337
    edited 2007-07-13 21:04
    pwillard said...
    Unless your song is really short<snip>
    Yes its just a few measures. [noparse]:)[/noparse] I could just hand-code the song, but it would be fairly labor intensive. I was just hoping someone had already done this.

    I know there are a number of other options for playing back music (i.e. the AP-8 or the uMP3) but in this case I need to have a small box that can plug into a MIDI in jack, play a bit of music and then be removed right afterwards. A way to convert MID to some basic stamp DATA statements would be ideal as it would save me a lot of time. [noparse]:)[/noparse]

    Vern

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Vern Graner CNE/CNA/SSE    | "If the network is down, then you're
    Senior Systems Engineer    | obviously incompetent so why are we
    Texas Information Services | paying you? Of course,if the network
    http://www.txis.com        | is up, then we obviously don't need
    Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG
    
    
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2007-07-14 01:54
    This excel spreadsheet extracts the data and you could us the·excel Concatenate command to create DATA statements and copy and paste them into the Stamp Editor. The problem is that a MID file is not a real time stream, it uses timing offsets to keep the size down. The excel spreadsheet converts the offsets to time stamps for easier synching of multiple tracks.

    The short·file you listed has 1200 notes in 2 tracks (labled right and left hand), add to those notes their timing and velocity and there's not much room left for the·code to play them.


    http://home.comcast.net/~technorobbo/MIDI.xls

    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun


    TR

    Post Edited (TechnoRobbo) : 7/14/2007 1:39:12 PM GMT
Sign In or Register to comment.