I am trying to visualise in flash midi file (using an external midi-to-flash library)
Is there a way to tell the difference between Violin, Viola, Cello & Contrabass in a midi file. I get these values for instruments (ignore the numbers):
1 Flute 13
2 Oboe 15
3 Clarinet 14
4 Bassoon 16
5 French Horn 18
6 Trumpet 17
7 Timpani 26
8 String Ensemble 1 3
9 String Ensemble 1 3
10 String Ensemble 1 3
11 String Ensemble 1 3
12 String Ensemble 1 3
13 Acoustic Grand Piano 5
14 Acoustic Grand Piano 5
15 Acoustic Grand Piano 5
16 Acoustic Grand Piano 5
As you can see, all the strings get the same "String Ensemble" value...
one way to do it is to ask for each note if it is high (65>) or low (50<) etc and by that deciding roughly the instrument type (for a specific note). but since these values are random and not accurate - that doesn't seperate them right (especially since diffrent tools still have shared note height values).
Is it written (cello, violin...) somewhere in the midi file?
Is there a way to assume it?
I have 5 tracks of strings. is it possible to assume (for example) that the first 2 are violins, 3rd is Cello etc? or they are all mixed?
In short, no.
What you are seeing are simple General MIDI patches. However, how these instruments sound depend on the synthesizer generating the sound, and are not defined by MIDI. It is completely possible to pick entirely different instruments than the patches shown.
That being said, 41 is defined as violin, 42 is viola, 43 is cello, and 44 contrabass. But, don't expect them to always be used in this manner.
As far as 1st/2nd violins, this depends on how the person decided to make the MIDI file, and there is no programmatic way to find that. For instance, if the instrument patch is the same, I'd expect that all of the usage of that instrument would be on one channel. Unless the software they were using decided to split it up for some reason. (For example, if the source score had it split up.)
I believe a MIDI file has some room for track names and such, but you won't see them in every MIDI file, and they are free-form names, so they won't be labeled in any way that you can use programmatically.
MIDI is only for controlling of synthesizers, and isn't intended to represent a musical score like we humans understand.