Any C programmers wanna help convert code to convert between MIDI + CSV?
#3
(08-25-2022, 10:48 PM)TempodiBasic Wrote:
(08-23-2022, 05:41 PM)madscijr Wrote: 1.   Question
I was looking to have QB64 convert MIDI files to CSV and vice-versa and found some C code that looks like it does the job.

It's just 2 files (asc2mid.c and mid2asc.c) and I figure regular C code with no fancy OO, it should be pretty straightforward to convert to BASIC, right?


Answer:
do you know that your QB64 code will be translated into C/C++ that will be compiled  by G++ /gcc
that are the C/C++ gnu compilers in the folder named internal.
So you can open your C/C++ IDE or your multilanguage IDE (Notepad++, Visual Studio,  JetBrain/IntelliJ IDEA) and after setting IDE to work with the specific language you will be able to compile C/C++ programs.
Moreover you can build an header file to include original C/C++ code as External library.
 (this sentence answers also to the question 2)


2.
Which leads me to a second question - QB64 comes with a C compiler "bundled" with it, right? Is there some way to use it to compile straight C programs? 

Answer:
see answer to  question 1

3.
Question
Is anyone interested in helping make sense of some C code?  :-D

Answer:

your QB64 code will be translated into C/C++, why do you want to translate a C program in QB64 to be translated again in C/C++?
However it seems to me  straight C programs, but this doesn't means that it is easy to translate them into QB64...starting from the point that these 2 simple programs use these other programs (Libraries) written in C and used as included file!

-------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <string.h>
--------------------------------------------
so do you want translate also these libraries or do you want include them as External Libraries?

Good thinking about this last point.

Thank you for your answers! 

I should explain a little more, because I can see how my questions might leave one confused about what it is I am actually trying to do. 

My main goal is to write some native QB64 routines that translate a MIDI file to CSV (or tab-delimited), and vice-versa, so I can play around with editing or creating MIDI music in Excel or in my own QB64 programs. 

For this purpose, I don't want to have to deal with C code at all, I want my program to be pure BASIC, and be cross-platform. Someone should just be abme to paste it into QB64 and it will just work! 

So why all this nonsense about C, you ask? 

I don't know a lot about the technical details of reading and writing MIDI files - how to read or parse the bytes, etc. I'm not too interested in getting into all that, and if someone has already figured it out in some other language (like C) then I'm perfectly happy just taking it and converting to QB64. 

I don't know C too well, but I am familiar enough to recognize those libraries it uses (stdio, stdlib, math, assert, string) are mostly basic functionality for working with strings, math and files. 

The only one _not_ doing stuff that I've already done in QB64 a zillion times is Assert. That's a weird one, but I read that it's basically C's way of handling illegal values, which we can do in QB64 with some regular IF/THEN logic. 

Anyway, the code is just reading a binary file into some values, looking at it, and writing it out to a CSV, which is something QB64 can easily do. So I am confident it can be done in pure QB64. 

The trick is, I am _not_ very knowledgable about C (I don't even like it!) Even though I'm familiar with the syntax (having done JavaScript and C#, and some C back in school), it still is alien to me, and all the manual work you have to worry about in C is painful for someone whose favorite languages are VBA and QuickBasic! 

But if I am going to understand and translate code that parses a format I don't understand, in a language I don't know very well, to a language I do sort of know, then it would probably be helpful to be able to run some of that code in a test environment - just to see (just to "c"! lol) what it does. I learn by experimenting. And it eliminates the guesswork by being able to try out a line of code to see what it does. 

So I would want a C compiler for that purpose. But I want to avoid downloading and installing yet more unknown applications on my laptop, because who knows what malware is out there, etc. I already trust and love QB64, so if I can use its already installed C compiler, great! 

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!)

Really, I am not that excited about doing C. It's a necessary evil and I just want to get the dirty work done, so I can get back to writing QB64 code! 

Anyway I hope that explains where I'm coming from a little more. Thanks again for your reply!
Reply


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



Users browsing this thread: 49 Guest(s)