05-11-2009 01:37 PM
05-11-2009 01:52 PM
nathand wrote:
Binary is the raw bits - exactly the way the computer handles information. You're not trying to handle it on a character-by-character basis; don't think of it that way. Each character is one byte - 8 bits - but in order for you to get meaningful information out of that file you might need to read 4 bytes and combine them into a 32-bit integer; or maybe you only need to read the first and last 2 bits of each byte and ignore the middle 4, so the way you're displaying the data as text is meaningless, and there's no simple way to convert it to a text representation that would help you. Instead you need to study the MIDI format, then write code that can read a sequence of bytes and get you the information you need out of it.
So would something like this work?
Read the binary file, each time I see 1000**** or 1001****, add the last 4 bits to an array.
Then I should have an array of nnvv (as described in the link I posted).
Then I could work with that data.
.... or is that easier said than done?
Does 'read binary file' read one bit at a time? Or groups of 8 bits (1 byte) at a time?
I ask this because the program may see:
00100000 0******
and not differentiate where the byte starts and ends, thereby seeing 1000000.
Or is that not correct?
05-11-2009 02:13 PM
It looks like people have run into this problem before.
Maybe I'll use this tool to convert the MIDI files to Text files.
They have documented how these text file are formatted, so I will see what I can do from here.
Thanks for your continuing help everyone.
05-11-2009 02:53 PM
05-11-2009 02:54 PM
Read Binary File reads in units of bytes at a minimum, but can read larger chunks of data if you wire a larger type to the data type input.
You probably cannot simply search through the file for those two patterns, since you want to make sure that you're only finding those patterns in the sections of the file where they matter. That is, the same pattern might appear both in a track and in the header; you only want it in the track.
I think you'll find it's easier to write code to parse the MIDI file than to parse a text version of it, because text varies in length and involves a lot of number conversion, whereas the binary format is consistent. For example, a note frequency will always be the same number of bits in the binary version, but could be 1, 2, or 3 characters in text. Also, you'll learn a lot from working in binary and dealing with data on the bit level.
05-11-2009 03:04 PM
..... this is gonna be a lot more difficult than I planned in the beginning. OK, well, I am on summer vacation as of last week, so it looks like I'll be spending a lot of time with my good friend LabVIEW
nathand wrote:Read Binary File reads in units of bytes at a minimum, but can read larger chunks of data if you wire a larger type to the data type input.
You probably cannot simply search through the file for those two patterns, since you want to make sure that you're only finding those patterns in the sections of the file where they matter. That is, the same pattern might appear both in a track and in the header; you only want it in the track.
I think you'll find it's easier to write code to parse the MIDI file than to parse a text version of it, because text varies in length and involves a lot of number conversion, whereas the binary format is consistent. For example, a note frequency will always be the same number of bits in the binary version, but could be 1, 2, or 3 characters in text. Also, you'll learn a lot from working in binary and dealing with data on the bit level.
06-15-2009 11:16 PM - edited 06-15-2009 11:18 PM
OK, after a lot more toil with binary that I would ever like to experience again, I figured out how to get some usable information out of the MIDI files.
I have successfully gotten the VI to read the file, then play the notes (and chords) according to the timing specified in the MIDI file.
I am still having a little trouble playing the sound to accompany the visual.
I have an array of :
Key Hertz_Value
for each piano key.
I use the Beep function, by inputting Hertz and Duration, but it sounds like crap.
From a hertz value, does anyone know how I could output a sound that sounds a little more like a piano key?
Edit: Wait a minute.... I just read Ricardo's post. I'm going to look into that before I post back again.
06-15-2009 11:43 PM
06-16-2009 03:04 PM
I cant figure out why this VI isnt outputting any sound.
I know it worked at one point, because I heard something resembling a piano.
... then I messed with it, and it stopped ![]()
All I did was connect the controls on 'Top-Level.vi' to connectors.
I wired in values for: wait (ms), note, volume, MIDI device.
For some reason, after I did that, it doesnt want to work any more.
06-16-2009 03:12 PM