Any C programmers wanna help convert code to convert between MIDI + CSV?
#45
(09-01-2022, 06:04 PM)Kernelpanic Wrote:
Quote:One of the challenges I am having, is knowing whether the code we're working with actually works. 
Converting a MIDI file to text, and back again doesn't seem to work, and I'm not sure if that's because the flavor of C the code is in, doesn't translate exactly to what the QB64's compiler expects, or what.
Maybe comparing it to other projects that do the same thing will help. 
I found a bunch in C and also VB6, Python, and other languages. 
I don't know if this will help anyone verify what the code should be doing, but it might help me!
Enjoy... 


If I understand correctly, you want to convert a midi file to text, and then pass it to the C compiler in QB64. Wouldn't it be easier to add something to QB64 that could, for example, call up the media player?

I looked at your list of links again and saw something with VB6 and videos. I only have VB 5, VB 6 cannot be installed, but it also works with VB 5. I have now created a program like this.

I don't know if it helps. The source code:

Code: (Select All)
Option Explicit

Private Sub cmdAbspielen_Click()
  WindowsMediaPlayer1.URL = Text1.Text
End Sub

Private Sub cmdAnhalten_Click()
  WindowsMediaPlayer1.Close
End Sub

Private Sub cmdEnde_Click()
  End
End Sub

Private Sub cmdVideoeffenen_Click()

  Me.CommonDialog1.Filter = "WAV-Dateien (*.wav)|*.wav|" & "MP3-Dateien (*.mp3)|*.mp3|" & "MP4-Dateien (*.mp4)|*.mp4|" &   "Videodateien (*.avi)|*.avi|" & "MPEG-Dateien (*.mpg)|*.mpg|"
  CommonDialog1.ShowOpen
  Text1.Text = CommonDialog1.filename
End Sub

[Image: Video-mit-VB5-2022-09-01.jpg]

Thanks for your reply. Let me explain one more time, since I seem to have confused a lot of people on what my goal is with this. 

I am ultimately looking to write some native QB64 functions that 

1. parse a MIDI file to translate it to a tab-delimited or CSV text file, which could then be easily loaded into Excel or Notepad++ or a custom QB64 editor, where the music can be edited or manipulated (or created from scratch). 

2. convert the MIDI text file to a real MIDI binary file, that can be played or edited by any MIDI compatible media player, sequencer, or DAW that can read MIDI files. 

3. ideally, it could take a MIDI file, translate it to text, and then translate the text back to MIDI, and the resulting MIDI will be exactly the same as the original MIDI file (maybe not byte for byte, but the music will play back the same and the file will be in the standard format)

I don't know the details of MIDI and don't really care to get too deep into it if I can help it (at least currently). I really just want to deal with a friendly text format that I can play with in Excel or my own QB64 programs, and make relatively simple songs in (maybe 1-4 instruments). 

This would be native cross-platform QB64 code, not C. 
The only reason C entered into this was I found existing programs written in C that translate between MIDI and CSV, and I am not a C programmer, and thought since QB64 comes with a C compiler that I might be able to use that to run the C code and play around with it, to understand what statements are doing so I can accurately translate it to QB64. 

With help from the friendly folks of the QB64 community, I was able to utilize QB64's built in C compiler to build working EXEs from the C code. So I can play with C - woohoo! Also there are other (non-MIDI) things I'm looking to do where I have example C code, so it will be similarly helpful for compiling and testing those in the future.

I don't really want to install a dedicated IDE for writing C programs, and being able to do some C with the existing QB64 installation appeals to me (no new installs!) Really, I'm even less interested in learning C than I am in learning MIDI, it's just a necessary evil since the code I found that does the MIDI parsing and translation was written in C! (Although I since found some VB6 code which, if it works, will surely be much much easier for me to work with, since I know and like old school VB6 and VBA,) 

The problem I had when I tested the MIDI<->CSV C code is that although I got it to run, it doesn't seem to be working for step 3 above, converting MIDI to text and back again. The re-converted MIDI file is messed up. That's where I left it, and since then folks have been discussing the finer points of C, but I have been busy and haven't gotten around to getting back into the details of translating it to QB64. Next I will look at the VB code and give that a try. 

I hope this explains everything. Thanks again...
Reply


Messages In This Thread
RE: Any C programmers wanna help convert code to convert between MIDI + CSV? - by madscijr - 09-01-2022, 06:58 PM



Users browsing this thread: 32 Guest(s)