Any C programmers wanna help convert code to convert between MIDI + CSV? - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://staging.qb64phoenix.com/forumdisplay.php?fid=10) +---- Thread: Any C programmers wanna help convert code to convert between MIDI + CSV? (/showthread.php?tid=803) |
RE: Any C programmers wanna help convert code to convert between MIDI + CSV? - mnrvovrfc - 08-26-2022 (08-26-2022, 02:54 AM)madscijr Wrote: :Might you be the expert we're looking for?Yes, while I used Power C by Mix Software from Richardson, Texas. But this was a few decades ago, without hard disk, VGA, USB, high-speed Internet, live MP3/MP4/OGG/OGV playback and too much we take for granted now. RE: Any C programmers wanna help convert code to convert between MIDI + CSV? - madscijr - 08-26-2022 (08-26-2022, 03:35 AM)mnrvovrfc Wrote:(08-26-2022, 02:54 AM)madscijr Wrote: :Might you be the expert we're looking for?Yes, while I used Power C by Mix Software from Richardson, Texas. But this was a few decades ago, without hard disk, VGA, USB, high-speed Internet, live MP3/MP4/OGG/OGV playback and too much we take for granted now. I remember those days, back when computer storage meant a cassette tape, and getting a 5.25" floppy drive felt like a serious upgrade. I have gone back to code I wrote on a Commodore 64 in the Reagan years, and I remembered more than I thought I would! RE: Any C programmers wanna help convert code to convert between MIDI + CSV? - JRace - 08-26-2022 Is this why you wanted info about C compilers, IDEs, etc? 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. Anyway, I can't help on a conversion project at this time, but I edited the C sources which allow them to compile without error using QB64PE's bundled MinGW compiler. I assumed those multi-statement lines were supposed to be blocks and treated them as such, blocking them up nice & neat for compilation. Hopefully this doesn't break functionality. They both run well enough to display a list of options when run from the command line, but I have no MIDI files to test them on, so no guarantees that they will be bug-free. You will have to test it. 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. (@mnrvovrfc : I heard a lot of good things about Power C back in the day, and Mix Software is still out there selling Power C for DOS! I started out with James E. Hendrix's Small C, myself. Good times!) RE: Any C programmers wanna help convert code to convert between MIDI + CSV? - madscijr - 08-26-2022 (08-26-2022, 04:24 AM)JRace Wrote: Is this why you wanted info about C compilers, IDEs, etc? Well thank you! I shall give this a go. Moving us a little further along. PS Some MIDI files for you https://freemidi.org/artist-465-frank-zappa RE: Any C programmers wanna help convert code to convert between MIDI + CSV? - madscijr - 08-26-2022 @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. 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 PS is it possible to insert tables in this forum editor? RE: Any C programmers wanna help convert code to convert between MIDI + CSV? - TempodiBasic - 08-26-2022 (08-26-2022, 02:00 AM)mnrvovrfc Wrote:(08-26-2022, 01:48 AM)TempodiBasic Wrote: stuffYou need to use the "code" delimeters if you're going to post something very long and annoying like that. You're right! I apologize but I must become confident with new icons in forum's reply page! I clicked on the third icon from left (insert a quote) by excluding Code button and PHP button. And so that long boring post has born! Now I try to put into a code window so I can have scroll bars and not kilometer post! RE: Any C programmers wanna help convert code to convert between MIDI + CSV? - TempodiBasic - 08-26-2022 (08-26-2022, 02:54 AM)bplus Wrote:(08-26-2022, 01:48 AM)TempodiBasic Wrote:(08-25-2022, 11:32 PM)madscijr Wrote: But beyond this MIDI to CSV project, you may have seen my many posts going on about this ridiculous pipe dream of getting the PC to read 2 or more USB mice as separate input devices, for local multiplayer Pong games I have dreamed of for a long time. Well, I found some code that supposedly does that, and it is also in C! I gather that this mouse stuff is much lower level operations, and needs to be in a language like C, so that piece of software will probably be a DLL that a QB64 program calls. So yet another reason I would like a C compiler! And there is at least one other project that similarly has me looking at C code (I don't recall what it was, but it's there!) Hi Bplus, I have had a problem on formatting the previous post... I clicked on "Insert a Quote" button at the place of " Code" Here above I have cancelled the long boring post and it stays the nucleum of my message... in the C code of file Mid2Asc.C I have written , IMHO, the sequential code in QB64 just under each C block of code. So I have type " ' " as starting character and then the QB64 code to get the same result and operations made in C code. first dubt is 1. never seen this way to assign a value to a string variable in C buf[p][0]="CDEFGAB"[(n+700000)%7]; it seems to me buf(p,0) = "CDEFGAB " + ltrim$(str$(n+700000 mod 7)) 2. trying to compile by using G++ or GCC compilers I got a set of Warnings about a deprecated way to use Strings and the suggestion to use Wstring based on Wchar_t type of data. Thanks for reading RE: Any C programmers wanna help convert code to convert between MIDI + CSV? - madscijr - 08-26-2022 (08-26-2022, 08:24 PM)TempodiBasic Wrote:(08-26-2022, 02:00 AM)mnrvovrfc Wrote:(08-26-2022, 01:48 AM)TempodiBasic Wrote: stuffYou need to use the "code" delimeters if you're going to post something very long and annoying like that. No worries! I am also still learning about the new forums editor. I still can't see how to make a simple table! LoL I checked the help page at https://staging.qb64phoenix.com/misc.php?action=help&hid=7 and no tables. ?!? RE: Any C programmers wanna help convert code to convert between MIDI + CSV? - TempodiBasic - 08-26-2022 Now the post has been shortened using the right icon in the editor of reply to posting. Thanks for feedbacks RE: Any C programmers wanna help convert code to convert between MIDI + CSV? - mnrvovrfc - 08-26-2022 (08-26-2022, 08:36 PM)TempodiBasic Wrote: never seen this way to assign a value to a string variable in CThat is a syntax error in C, perhaps not in C++. I've seen stranger things happen with C++ code, perhaps square-bracket operators were overloaded? Otherwise the intention of the programmer looks like one of the letters is being extracted. Just doing buf[p][0]="CDEFGAB"; might not be allowed in C, must allocate memory for pointer for string "array", then more memory for each member of the array and then use "strcpy()" or something like that from "string.h". This is just my near-fundamental knowledge of that programming language... |