How to get midi file type (0/1/2) in java?

I am parsing a MIDI file using:

Sequence sequence = MidiSystem.getSequence(paFile);

How to distinguish SMF file type? I did not find a way to return it. Is it possible to assume that a sequence with only one track is of type 0 and several tracks of type 1?

+4
source share
1 answer

It is not possible to find out how tracks in a type 2 file should be processed in the general case, and the only difference between files of type 0 and 1 is the number of tracks allowed. Therefore, it Sequencedoes not remember the file type.

If you really want to know the type of file, you must read it directly from the file using MidiSystem.getMidiFileFormat .

0

Source: https://habr.com/ru/post/1535776/


All Articles