Make music with gtmidi

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
Post Reply
denjhang
Posts: 54
Joined: 02 May 2021, 01:25
Location: yuenan
Contact:

Make music with gtmidi

Post by denjhang »

Today I learned how to use gtmidi, of course this is a direct result of successfully compiling the latest gtemu in recent days.
(I can't play gtmid directly if using an older version of gtemu)

So I found that gtmid does have some areas to improve.
1. No pitch bend and vibrato (probably miditones have lost this information)
2. All volume changes are almost lost (I used -v parameter)
3. How to set the waveform for each channel? Currently only square waves.
(I know that gtWAV can be loaded to switch waveforms, but can only one waveform be used for each of the four channels?)

Here is the conversion code I use. I hope at the moment it's just because I don't understand the problem of using gtmidi. (I guess there should be some trick to solve the above problem.)

Inside the zip are gtMID music that I made, they play without any problems, they just don't sound very good (because too much detail is lost).
Also I uploaded the mid source file (I can attest that the original track has a lot of details like pitch bends and volume changes etc.)

Code: Select all

cd miditones-master
miditones -t4 -b -s1 -pi -v tp
cd ..
gtmidi tp.bin tp.gtmid tp gtMID 0x8000 0 0 0.5 -v
Attachments
mid_org.zip
(33.27 KiB) Downloaded 93 times
my gtMID.zip
(15.64 KiB) Downloaded 82 times
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: Make music with gtmidi

Post by at67 »

denjhang wrote: 21 Mar 2022, 09:47 So I found that gtmid does have some areas to improve.
No it doesn't, if it's not to your liking, then write your own...
denjhang wrote: 21 Mar 2022, 09:47 1. No pitch bend and vibrato (probably miditones have lost this information)
Correct, but this is a limitation of miditones, it throws that information away.
denjhang wrote: 21 Mar 2022, 09:47 2. All volume changes are almost lost (I used -v parameter)
There are no volume changes in any of the .gtmid files that you produced that I could see, however you are generating volume, miditones is throwing it away, are you using velocity changes? Because looking at the miditones source code, that is how you will get volume control.
denjhang wrote: 21 Mar 2022, 09:47 3. How to set the waveform for each channel? Currently only square waves.
(I know that gtWAV can be loaded to switch waveforms, but can only one waveform be used for each of the four channels?)
Here's some code that runs on ROMv5a or DEVROM both in emu or real hardware, (64K RAM required, if you want to run it on 32K RAM then reduce the number of MIDI's loaded), that shows how to set different waveforms for each channel.

Also if you want to play .gtmid's with volume information then you need to change the 'init midi' to 'init midiv' and the 'play midid' to 'play mididv'

Code: Select all

_runtimePath_ "../runtime"
_runtimeStart_ &hFFFF
_codeRomType_ ROMv5a
_enable6BitAudioEmu_ ON 'experimental

'not using strings
free STRINGWORKAREA


'overwrite interlaced waveform 0 in audio memory
def byte(&h0700, x, 0.0, 360.0, 64, 4) = (sin(x)*0.5 + 0.5)*63.0

load midi, ../../res/audio/midi/denj/062.gtmid,   0
load midi, ../../res/audio/midi/denj/063.gtmid,   1
load midi, ../../res/audio/midi/denj/065.gtmid,   2
load midi, ../../res/audio/midi/denj/066.gtmid,   3
load midi, ../../res/audio/midi/denj/rw.gtmid,    4
load midi, ../../res/audio/midi/denj/tp2.gtmid,   5

init midi


track = 0 : idle = track : wave1 = idle : wave2 = wave1 : wave3 = wave2 : wave4 = wave3

gosub initialise

repeat
    wait
    gosub get("BUTTON_STATE")
    set BUTTON_STATE, 255
    if idle = 0
        idle = 1
        play midid, track
        call setChanWaves, wave1, wave2, wave3, wave4
        at 77, 56 : print track
    endif
forever


49:  track = 0 : idle = 0 : wave1 = 0 : wave2 = 0 : wave3 = 0 : wave4 = 0 : return
50:  track = 1 : idle = 0 : wave1 = 2 : wave2 = 0 : wave3 = 0 : wave4 = 0 : return
51:  track = 2 : idle = 0 : wave1 = 0 : wave2 = 1 : wave3 = 2 : wave4 = 3 : return
52:  track = 3 : idle = 0 : wave1 = 3 : wave2 = 2 : wave3 = 1 : wave4 = 0 : return
53:  track = 4 : idle = 0 : wave1 = 0 : wave2 = 0 : wave3 = 0 : wave4 = 0 : return
54:  track = 5 : idle = 0 : wave1 = 3 : wave2 = 3 : wave3 = 3 : wave4 = 0 : return
255:             idle = 1 :                                                 return


proc setChanWaves, w1, w2, w3, w4
    sound mod, 1, w1
    sound mod, 2, w2
    sound mod, 3, w3
    sound mod, 4, w4
endproc


initialise:
    'audio fix for ROMv5a
    poke &h21, peek(&h21) OR 3
    
    mode 2
    set FGBG_COLOUR, &h3F30
    cls
return
denjhang wrote: 21 Mar 2022, 09:47 Here is the conversion code I use. I hope at the moment it's just because I don't understand the problem of using gtmidi. (I guess there should be some trick to solve the above problem.)
It's either PEBKAC or the tools you are using are presenting volume changes to miditones that it doesn't understand or can't handle.
Post Reply