fbpx
Skip to main content

MIDI Forum

Verifying validity ...
 
Notifications
Clear all

Verifying validity of a MIDI file (Windows)

21 Posts
3 Users
0 Reactions
7,892 Views
Jason
Posts: 441
Honorable Member
Topic starter
 

Is there a piece of software that will verify the validity of the data in a MIDI file (in Windows)?

I'm am working towards finishing up my midi file instrument editor, and one of the complications is adding in program changes, bank selects, and SYSEX resets that did not exist in the original un-edited file. This involves updating track lengths and positioning data for lots of stuff in the editor. I am looking for any easy way to validate that my new track lengths are correct, as well as the general integrity of the file. It's not too difficult to manually look it over with a few small test files, but once I start messing with actual full length/complicated files, the ability to tell just by looking becomes too difficult.

Basically, I need a way to see if there is anything wrong with my modified files. (Currently, I modify, save, and reload to see if the reloaded file has the same banks/instruments/ instrument count as prior to saving, and play it to see if there are any obvious goof-ups).

 
Posted : 16/06/2021 1:28 pm
Sema
 Sema
Posts: 182
Reputable Member
 

Try this: https://github.com/jazz-soft/test-midi-files
It reports some problems that it finds in the MIDI files (but probably not all)
And I'm here if you need any help with that tool 🙂

 
Posted : 16/06/2021 3:33 pm
Jason
Posts: 441
Honorable Member
Topic starter
 

I was aware of it from some of the other posts. Does it run in Windows? And if so, is there a pre-compiled version? GitHub is the bane of my existence :p

 
Posted : 16/06/2021 6:31 pm
Sema
 Sema
Posts: 182
Reputable Member
 

It's a Node.js application, it runs pretty much on everything.
1) Install Node.js (unless you already have it)
2) Clone the GIT repo ( git clone https://github.com/jazz-soft/test-midi-files.git )
I believe every developer uses git nowadays, but if you don't, just go to the GitHub page, click the green 'â­³Code' button and download the zip file.
3) Read a README.md
4) go to the downloaded directory and run 'npm install'
5) run 'node . your-midi-file.mid print'

 
Posted : 16/06/2021 8:28 pm
Jason
Posts: 441
Honorable Member
Topic starter
 

I have Windows 7, Node.js does not like Windows 7. I was able to force install it, but it does not run unless I manually set a version skip environment variable, and then manually specify the path to both node and test-midi-files.

I created a batch file so I can drag files on to it:
[code type=markup]
set NODE_SKIP_PLATFORM_CHECK=1
"C:\Program Files\node-v14.17.1-win-x64\node" "C:\Program Files\node-v14.17.1-win-x64\test-midi-files-main\index.js" %1 print > %1.txt
pause
[/code]

This seems to be working.

I already see that in my first few files I was testing, it shows invalid track lengths, and I tried a few others that showed other warnings. I like the full list of events.

Is the number listed on the left side of the output the time offset, or the byte offset? If it is time offset, is it possible to also display byte offset?

 
Posted : 17/06/2021 8:48 am
Sema
 Sema
Posts: 182
Reputable Member
 

Left side shows the time, i.e. the sum of all previous time offsets.
Byte offset is shown only in the warning/error messages.

 
Posted : 17/06/2021 9:25 am
Jason
Posts: 441
Honorable Member
Topic starter
 

It is working well for what I am currently testing, when combined with the "compare" add-on in Notepad++ and my hex editor. It helped me correct my MSB/LSB insertion code (originally had too few in relation to the amount of program changes), and helped me correct my updating of track lengths when inserting bank selects (and soon to be program changes). Thanks!

 
Posted : 19/06/2021 5:18 pm
Jason
Posts: 441
Honorable Member
Topic starter
 

Any chance you can add byte offset display to all lines of the output for test-midi-files? Maybe an option to do it? I am trying to track down where exactly in my file my byte-writing has gone wrong, and have to use a hex editor to do so. I see I have this problem (see attached screenshot)

I've inserted a bank select msb and lsb (and possibly program changes) throughout the file, but something has gone wrong at this spot, and I am unable to find those particular bytes doing a search in the modified file. A byte offset display in the test-mifi-files output would be SUPER helpful. 😉

 
Posted : 01/07/2021 9:22 am
Sema
 Sema
Posts: 182
Reputable Member
 

Cannot promise it fast, but will see what I can do...

 
Posted : 01/07/2021 1:04 pm
Jason
Posts: 441
Honorable Member
Topic starter
 

I was able to figure out how to search for those spots (had to mentally add in the delta times to my search) and I have been able to track down and correct my issue. No rush on that update 😉

I plan on eventually making a test file collection with different banks that you can add to YOUR test files collection, modifying the "all instrument sounds" and "all percussion sounds" files to have a different bank select in each. I already tried it out with bank select msb 1 in the all instrument sounds and it works perfect.

 
Posted : 01/07/2021 6:38 pm
Sema
 Sema
Posts: 182
Reputable Member
 

Please check the latest version from https://github.com/jazz-soft/test-midi-files
Made it especially for you 🙂

[code type=markup]
C:\JZZ\test-midi-files>node . test.mid print
[ 0] SMF:
[ 8] type: 0
[ 10] tracks: 1
[ 12] ppqn: 96
[ 14] MTrk:
[ 23] 0: ff03 -- Sequence Name: C Major Scale Test
[ 45] 96: ff01 -- Text: Now you must hear C5!
[ 71] 96: 90 3c 7f -- Note On
[ 75] 192: 80 3c 40 -- Note Off
[ 79] 192: ff01 -- Text: Now you must hear D5!
[105] 192: 90 3e 7f -- Note On
[109] 288: 80 3e 40 -- Note Off
[113] 288: ff01 -- Text: Now you must hear E5!
[139] 288: 90 40 7f -- Note On
[143] 384: 80 40 40 -- Note Off
[147] 384: ff01 -- Text: Now you must hear F5!
[173] 384: 90 41 7f -- Note On
[177] 480: 80 41 40 -- Note Off
[181] 480: ff01 -- Text: Now you must hear G5!
[207] 480: 90 43 7f -- Note On
[211] 576: 80 43 40 -- Note Off
[215] 576: ff01 -- Text: Now you must hear A5!
[241] 576: 90 45 7f -- Note On
[245] 672: 80 45 40 -- Note Off
[249] 672: ff01 -- Text: Now you must hear B5!
[275] 672: 90 47 7f -- Note On
[279] 768: 80 47 40 -- Note Off
[283] 768: ff01 -- Text: Now you must hear C6!
[309] 768: 90 48 7f -- Note On
[313] 864: 80 48 40 -- Note Off
[317] 864: ff01 -- Text: Thank you!
[331] 864: ff2f -- End of Track
[/code]

 
Posted : 02/07/2021 8:12 pm
Jason
Posts: 441
Honorable Member
Topic starter
 

Fantastic! Thank you so much! I can't tell you how helpful your program has been the past few weeks in helping me with mine. I have 101 text files from at least 101 different tests, plus some I already got rid of, that have helped me sort out my track length changing code, and my bank change msb, lsb, and program change insertion code. Now my program is at least 90% guaranteed not to corrupt a saved MIDI file 😉

 
Posted : 03/07/2021 10:01 am
Jason
Posts: 441
Honorable Member
Topic starter
 

Haha, oh no, any chance you can make it optional, with a command line flag?

Now the compare plugin in Notepad++ chokes because every line is different after I do an update. 😛

It can tell if new lines have been added (or removed) if the ones around it are the same, but with the byte offset, now every line after the first insert is different.

Other than that the update works great though. Thanks.

 
Posted : 03/07/2021 1:09 pm
Jonas
Posts: 207
Reputable Member
 

Is it a plugin you use in Notepad++ to show midi files?

 
Posted : 04/07/2021 12:23 am
Jonas
Posts: 207
Reputable Member
Page 1 / 2
Share: