Playing gtmidi Files

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
Post Reply
DarNiem
Posts: 4
Joined: 06 Mar 2023, 16:08

Playing gtmidi Files

Post by DarNiem »

Hello Guys,

I'm a beginner musician and do a little of programming in my free time.
I would love to play around with at67's gtmidi format. Sadly I don't have any knowledge about memory addresses and stuff.
Could anyone tell me what to do to convert simple midis into gtmidi and play them back on my Gigatron. I just want a simple gtbasic programm. It would be great if someone could write that.
Thanks in advance
DarNiem

P.S.:I have 32k of RAM and ROMv5
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: Playing gtmidi Files

Post by at67 »

It's pretty simple to convert .midi files to .gtmidi and even easier to play them back in gtBASIC.

1) Make sure you have gtMIDI and miditones built and available at a command line/terminal.

2) Type gitmidi at the command line and it will tell you exactly what to do.

3) For the Gigatron the maximum channels converted is 4, no percussion available yet, but velocity is available.

4) For playback under ROMv5a, using the vertical blank handler is recommended and it's as easy as the following:

Code: Select all

_runtimePath_ "../runtime"
_runtimeStart_ &h7FFF
_codeRomType_ ROMv5a

' this MIDI was created with the -v option, so contains velocity information
load midi, ../../res/audio/midi/agony.gtmid, 0

' set up the VBlank and audio system to playback MIDI's with velocity
init MIDIV

play MIDIV, 0
There's lots of audio/music examples in the gbas/audio folder.
DarNiem
Posts: 4
Joined: 06 Mar 2023, 16:08

Re: Playing gtmidi Files

Post by DarNiem »

Thanks a lot!

I will try that out.

Edit:Maybe I am a little dumb. The program you sent compiles without any errors, loads flawlessly but doesn't do anything. My sound is working (I can hear the gigatron start sound) but nothing happens with the compiled program. Do I have to implement a loop or something?

Thank you in advance
DarNiem
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: Playing gtmidi Files

Post by at67 »

Because the sound is playing in the background, yeah you need to do something else, i.e. loop and draw some graphics, get some input, or just a busy loop, etc.
DarNiem
Posts: 4
Joined: 06 Mar 2023, 16:08

Re: Playing gtmidi Files

Post by DarNiem »

I'm sorry to bother you again, but I still don't get it.
I get the part about the music playing in the background, so I wrote a program which just loops a print command that says gtmidi. It does print gtmidi endlessly, but still no music. Here's my code:

Code: Select all

_runtimePath_ "../runtime"
_runtimeStart_ &h7FFF
_codeRomType_ ROMv5a

load midi, ../../res/audio/midi/agony.gtmid, 0

init MIDIV

play MIDIV, 0
repeat
	print "gtmidi"
forever
Could you please tell me what I'm doing wrong?
Thank you in advance
DarNiem
Last edited by DarNiem on 11 Mar 2023, 06:22, edited 1 time in total.
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: Playing gtmidi Files

Post by at67 »

Sorry typo, there's different ways of referencing MIDI files, one is through MIDI ID's, (the one we are using in this example), so the play command should look like this:

Code: Select all

play MIDIDV, 0
P.S. I'll add better error output for this in the next release.
DarNiem
Posts: 4
Joined: 06 Mar 2023, 16:08

Re: Playing gtmidi Files

Post by DarNiem »

Thank you!
It works great now!
Post Reply