You can make Midi files with 4tH

23 views
Skip to first unread message

The Beez

unread,
Dec 28, 2025, 3:27:07 PM12/28/25
to 4tH-compiler
Hi 4tH-ers!

Now - don't get overexcited. If you expect to make polyphone tracks with this thing - not quite. But you can enter notes and duration - and even select your instrument.

So the sample files give you an impression of what it can do. For the ZX Spectrum fans - it you still got ZX BASIC programs lying around with lots of BEEPs, you can easily convert those to Midi:

ZX Spectum:
BEEP 0.75, 7
BEEP 0.25, 8
BEEP 0.5, 7
BEEP 0.5, 5
BEEP 0.5, 3
BEEP 0.5, 2
BEEP 1, 0

4tH:
 75 7 m.beep
 25 8 m.beep
 50 7 m.beep
 50 5 m.beep
 50 3 m.beep
 50 2 m.beep
100 0 m.beep

Yeah, no floating point but 1/100s. That's it. You can also select an octave or the attack by changing the mOctave and mAttack values.

A full list of instruments is also available (see source code) and you select them with the m.use command. Just open a file using MIDopen and beep away!

Have phun! Code in SVN.

Hans Bezemer

The Beez

unread,
Dec 28, 2025, 3:47:47 PM12/28/25
to 4tH-compiler
Darn! Forgot the Midi files!

Hans
bornwood.mid
frere.mid

The Beez

unread,
Dec 29, 2025, 12:52:27 PM12/29/25
to 4tH-compiler
Well, I've made numerous small improvements, added a few more examples - and I've written the manual for this one. I guess we're done! Although there's plenty of room for expansion: http://somascape.org/midi/tech/mfile.html

Hans Bezemer
worlduni.mid
ode2joy.mid
jinglebl.mid

The Beez

unread,
Dec 31, 2025, 8:56:02 PM12/31/25
to 4tH-compiler
Happy 2026!

Last few days I've been making demos for the new Midi library from various sources. Now, I'm a lazy kind of guy, so I wanted to preserve as much as possible (which also prevents errors). Due to the variety of sources, I also encountered a few wildly different syntaxes. And to my amazement it stacked up pretty well.

The only major addition I had to make was a frequency to note and octave conversion. Which I didn't make too difficult for myself. Anyways, it worked great. And I was happy with that. It proved once more that "eating your own  dogfood" is the only assurance that what you create is actually usable in the real world!

Enjoy your new years day! I'm hitting the deck!

Hans Bezemer
Reply all
Reply to author
Forward
0 new messages