Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Any C programmers wanna help convert code to convert between MIDI + CSV?
#15
@JRace
@TempodiBasic
@mnrvovrfc
@bplus
@Jack
@Kernelpanic
(08-26-2022, 04:24 AM)JRace Wrote: Ugh, that's pretty densely packed C, so conversion to a different language might take a minute or three and induce a few headaches.
Unguarded, unblocked multi-statement lines following for() statements?.  Good God why?  That's a invitation for bugs.  Thankfully GCC complains about that.
...
Zip file attached which includes original source from your post, compileable source, and MinGW-compiled Windows 32-bit executables.  That compilable source includes a batch file to automate compilation using QB64's bundled MinGW.

With your help and batch file, I got it compiling and it runs.
(So first I want to say thank you to all you guys for helping me get that working!)

Now for the MIDI conversion... 

PHASE 1
Using a free online MIDI composer at I created a simple test MIDI file with a simple song 
(only 1 instrument/track) "mary had a little lamb",
and downloaded it, named "mary1.mid".

mid2asc did convert a MIDI file to a text file named "mary2.txt",
but something must be off in the code, 
because when I tried converting it back to MIDI "mary3.mid"
with asc2mid, it just produces an empty file (0 bytes).

PHASE 2
I then tried it with my "prettified" code, and that also compiled and runs.
mid2asc converts "mary1.mid" to "mary2.txt". 

Using Beyond Compare, I compared this "mary2.txt" with 
the "mary2.txt" converted by JRace's mid2asc, 
and it appears their version has some extra line breaks, 
which must break the conversion back to MIDI. 

When I tried converting the 2nd "mary2.txt" back to MIDI with asc2mid,
it produces a MIDI file "mary3.mid" and this time it isn't empty. 
However, something is wonky, because the file is silent until about 16 seconds in.
Using mid2asc again, I converted that back to text "mary4.txt",
and using Beyond Compare, compared it to "mary2.txt"
and the first half of the file is very different.

I went back to the JRace version, and tried converting the text file "mary2.txt"
that my version made (that had no extra line breaks) to MIDI "mary3.mid",
which is no longer empty, but that file is also silent until 16 seconds in.
So the asc2mid in both our versions must have the same problem.

PHASE 3
I also started trying to convert both progams to QB64.

CODE AND RESULTS
I have attached all the code and test files and results in the following ZIP files. 

Code: (Select All)
FILE                                     CONTENTS
--------------------------------------   ---------------------------------------------------------
MIDI_TO_CSV_v1_JRACE.zip                 JRace's version and test files and results.
MIDI_TO_CSV_v2_MADSCIJR.zip              MadSciJr's prettified version and test files and results.
MIDI_TO_CSV_TO_QB64_v0-01_MADSCIJR.zip   MadSciJr's WIP conversion to QB64.

PS is it possible to insert tables in this forum editor?


Attached Files
.zip   MIDI_TO_CSV_v1_JRACE.zip (Size: 14.12 KB / Downloads: 39)
.zip   MIDI_TO_CSV_v2_MADSCIJR.zip (Size: 38.77 KB / Downloads: 37)
.zip   MIDI_TO_CSV_TO_QB64_v0-01_MADSCIJR.zip (Size: 29.05 KB / Downloads: 38)
Reply


Messages In This Thread
RE: Any C programmers wanna help convert code to convert between MIDI + CSV? - by madscijr - 08-26-2022, 07:10 PM



Users browsing this thread: 52 Guest(s)