Community
AGI Programming => AGI Development Tools => Topic started by: Sinus on May 19, 2025, 03:33:59 PM
-
While MIDI-to-AGI tools may be the weapon of choice for many of you, I'm an old school tracker musician, so the IT2AGI script I found on the SierraHelp pages was a godsend when I found myself tinkering with an AGI song. But, the tool lacked 4-channel output, and at times kept outputting nonsense when using multiple channels. Knowing some Perl, I went and fixed it. Here it is attached! Good luck tracking those songs :)
Update: the script is now hosted on GitHub (https://github.com/SinusPi/any2agi). You'll find the newest version there.
-
Nice to see you made it here. When I get a chance, I'll make a Wiki entry for it.
-
Right on! Does it translate drums to sounds on the AGI noise channel?
-
Yup. On the fourth channel, every even/odd octave defines noise/pattern, and every 4th note pitch defines frequency. C1=C3=C5=E1=E3=G#1=G#3. Play C1 C#1 D1 D#1 C2 C#2 D2 D#2 for a full range of sounds.
Just to clarify: there are no "drums" in IT, it's not MIDI, in trackers you define instruments as you see fit. But for this script, instruments don't matter. First three channels of the IT files are voices, the fourth channel is noises.
-
Thanks for the in-depth explanation! Not much experience with IT, but that is an amazing feature. I'm doing lots of MIDI to AGI conversions at the moment, and haven't found a way to convert drums / properly use the noise channel yet. Does anyone know how to do that?
Will try the IT to AGI thing. Thanks for your contribution to the toolbox!
-
The specs for the sound chip (http://agi.sierrahelp.com/Documentation/Specifications/7-1-SOUND.html) on SierraHelp proved to be rather clear to me.
Of the five-byte note entry in a SND resource file, first two bytes are duration as usual, then the third is a 00000000, the fourth is 11000NFF where N=0 for zzz and N=1 for shh and FF=00/01/10/11 for four frequencies, and then the fifth byte 1111xxxx for volume attenuation.
You can hear it in action in my rendition of the Wallflowers' Song for the KQ6AGI Demake here:
click (https://vimeo.com/1084364119)
(The song ultimately didn't make it into the game, as Brandon decided not to mess with the project too much anymore, but it was fun to make anyway. :) )
-
Wow, that's a great demake version of that song. Surprised it got cut; sounds done to my ears.
-
Thank you! :)
As for the cut, with 18 years on the project, I'm not entirely surprised Brandon chose to leave it "as is" - I came from nowhere and offered to improve his PC-Speakery version of the song, entirely unsolicited. He did make a good point, too, that including my version would've required him to employ a separate timer to let the player regain control of Alex while the song is still playing, as it's too long to just force the player to sit and listen, and that on the default PC Speaker the song wouldn't've sounded so nice. I did prepare for that, the song did include some "squeezing" of extra notes into the first voice to imitate accompaniment, and AGI does let you check which sound hardware is in use, to conditionally play an appropriately crafted sound piece, dedicated to either speaker or Tandy, if needed. But, bygones. The song's here, everyone's happy. ^_^
-
Tried the script on a number of Mod files, but keep getting an "Invalid IT header" error. Any ideas what I'm doing wrong?
-
Tried the script on a number of Mod files
I think that's the problem exactly. I tried a bunch of IT files myself just now -- some work fine, some give overflow errors. But when I accidentally tried to convert the wrong end I got "invalid IT header", and so I did with an XM file just now.
-
The script works with .IT files, not just any tracker format. It could, quite reasonably, work with MODs (4 channels, baby!), if made to do so, but for the moment it supports .IT files alone.
Would there be interest in a MOD converter, I wonder? I suppose I could whip that up, given a bit of time...
-
Thanks for the quick reply!
Tried an IT file, and it works like a charm. Thanks!
Is there a way to convert MOD to IT files? (No luck with OpenMPT so far...)
-
That's funny. That's exactly what I use to convert MOD to IT. In fact, I literally just now converted a randomly-picked MOD (https://modarchive.org/index.php?request=view_by_moduleid&query=77208) to IT with OpenMPT in just four clicks, not changing a single setting on the way.
-
Is there a way to convert MOD to IT files? (No luck with OpenMPT so far...)
OpenMPT should give you no problem at all - but the workflow isn't obvious.
1. Open your MID/MOD/XM/S3M file
2. Change song type in the tracker's General tab (screenshot attached)
3. Save!
-
Thanks for the heads-up! That was a missing puzzle piece for me.
-
Since it wasn't obvious, I now made the script recognize some wrong tracker formats.
The first post was updated with a link to a GitHub repo where the script shall now live.
-
0.2.2 update: experimental option --channels added to let you pick which channels to pull from the source files. Default is 1,2,3,4. Use: --channels 1,3,5,8
-
I guess I'm going to bite that bullet and tease you guys a bit.
Header: format , tracks, ticksperq=0, negsmpte=, ticksperf=
Reading track 1, 25 bytes
0: Status 11111111 META58
0: Status 11111111 META51 03 TMPO 500000
0: Status 11111111 META59 02 SIGN 0 maj
0: Status 11111111 META2f 00
Reading track 2, 1399 bytes
0: Status 11111111 META21
0: Status 11111111 META03 [ GABRIEL KNIGHT ]
0: Status 11000001 1 PCHG 0
1425: Status 11000001 1 PCHG 33
0: Status 10110001 1 CTRL 7=121
0: ... 10110001 1 CTRL 10=64
1: ... 10110001 1 CTRL 64=0
0: Status 11100001 1 PWHL 64=0
1: Status 10110001 1 CTRL 7=88
1534: Status 10010001 1 N-ON 45=74
0: ... 10010001 1 N-ON 33=74
1: ... 10010001 1 N-ON 52=74
166: Status 10000001 1 N-OF 45=64
26: ... 10000001 1 N-OF 33=64
45: Status 10010001 1 N-ON 45=70
6: ... 10010001 1 N-ON 33=80
1298: Status 10000001 1 N-OF 33=64
0: ... 10000001 1 N-OF 45=64
0: ... 10000001 1 N-OF 52=64
1: Status 10010001 1 N-ON 45=74
We're on our way to having the script read MID files. From there, it's only a short hop towards a direct MID2AGI converter, without going through a ROL, with built-in note overlap fixing, with the ability to pick channels from command line, and - why not? - drum support. We'll see. :)
-
Hey hey my my, Rock N Roll is finally coming to AGI town, it would seem. :)
Thanks to the IT2AGI script, I have now produced an AGI sound file, with drum sounds converted from the original MIDI arrangement. Bass drum and snare already have good sounds / the right noise freqs, but I can't seem to control the length of the noise bit. How can I get these short and snappy sounds like in the KQ6 tune?
Here's what I have so far:
https://www.youtube.com/watch?v=hBWQZ5W9zh4
-
How can I get these short and snappy sounds like in the KQ6 tune?
You need to insert note-off or note-cut commands in the IT patterns where appropriate - by pressing the backtick or equal keys, if you're using OpenMPT. They'll look like ~~ or ^^.
In theory, you should be able to set volume to 0 on the appropriate row, as it was done in Protracker MODs, but that trick isn't supported yet (it may be, perhaps).
-
Thanks man! That helps. Finally I got a workflow that lets me have drums. :) I use Sekaiju for the MIDI handling, then OpenMPT for the IT part. Together with your script I now have control over all 4 AGI sound channels for the first time. Amazing! :)
-
Version 0.2.3 is out on GitHub.
New option:
--tempo-exact - the script should exactly match the BPM of the input file - possibly pushing some rows out of sync, if there's no way to fit the original BPM into the 1/60ths of a second that AGI uses.
With tracker mods, all rows should play evenly, even if slower or faster than the input intended - you'll probably never want to use "exact", unless in very special cases.
For rowless formats like MIDI (soon!), "exact" will be default, and not changeable. Sadly, quantization of some weirdly timed or "crowded" note patterns into 1/60s ticks will always be a mess.
-
And version 0.2.4 is out, too! I'm on a roll.
--auto-drum-offs 1/2/3... - will automatically shorten drum notes to n rows if there's no note-off command in the input file. A good value is 2.
-
Fixed: notes with 0 volume will be properly output. This makes it possible to use the special feature of the drum channel - borrowing frequency from the 3rd channel.
-
I have added a Wiki stubpage for the tool"
http://wiki.sierrahelp.com/index.php/Sinus%27s_Branch_of_Impulse_Tracker_to_AGI_Sound
-
Splendid! May I get edit permission to keep it updated? Or, if not, please correct that it DOES now support volumes, and the noise notes aren't quite correct anymore, as D#1/D#2 has been confirmed to properly borrow frequency from the 3rd channel (enabling effects such as wind blowing, explosions, zaps, etc.)
-
By the way - here's how to make a BZOOOOT sound effect! :)
-
As of 5 minutes ago, the script converted its first MIDI file. A very simple one, with tempo out of whack, and multi-track multi-channels are a menace, but overlaps are handled and it could work in a very pinchy pinch. Work continues! \m/
... Oh, and a MOD file just got converted, too. Of course most samples are hand-tuned, so the result might need commandline args dictating how to detune each sample... So maybe I'll leave _that_ bit out. But hey, MOD reading, even if useless! :D
-
Just go to the "Request account" link at the top of the page and I'll activate it when I see it.
-
Arranging drums is so much fun now, thanks to the script and Sinus's great support.
Here's a tune that went through the MIDI 2 IT 2 AGI pipeline, with --auto-drum-offs set to 2:
https://www.youtube.com/watch?v=HPM0UCLUhz0
-
Rock on! And the solos went through properly, way to go! 🤘
Except for that very last bit, something odd happened there. But aside from that - sounds great!
I still hope to take that IT step out of the equation, though... :P
-
Just go to the "Request account" link at the top of the page and I'll activate it when I see it.
I already did. Awaiting further instructions! :)
-
with --auto-drum-offs set to 2:
Heads up - in the newest version 0.2.6 (https://github.com/SinusPi/any2agi/releases/tag/0.2.6), that I just posted, --auto-drum-offs use AGI ticks for resolution, not IT rows - that means more precision. Now if you set --auto-drum-offs 1, you'll get the shortest drums possible with AGI.
-
I approved you account.
-
I approved you account.
Perfect! But for now I don't have edit rights. I sent you a message at abranscom-at-gmail.com. Perhaps we can continue by email and not pollute this thread with wiki account topics :)
-
Should be OK now.
-
Version 0.3.0 is out, properly interpreting MIDI files!
Use --channels with 0-based MIDI channel values, channel 9 is usually drums. The script cut already playing notes, so keep every voice on a separate channel, obviously.
OR... use the experimental --midipoly parameter, which will try to fit as many polyphonic sounds as it can into the 3 channels we have. Note: the whole file MUST be on 1 MIDI track to try that.
-
I may be insane, but the next version will support Arpeggio in IT. And possibly portamento, too, though quickly changing notes sound badly in ScummVM, only DOSBox plays them legato.
Chiptunes in AGI, huh? :D
-
If you can make it sound nice in the external AGI song player programs, I think there would be a good case for a change in ScummVM.
-
Wow, that's an amazing upgrade yet again! Will try it right away. Thanks so much for your work on this. Our game project "V" is stepping up on the music part extremely, thanks to your work: the game will feature radio stations with different genres (just like in GTA), so if anyone wants to hear their favourite 70s or 80s tune in glorious AGI 4-channel sound, just hit me with your wishes.
-
If you can make it sound nice in the external AGI song player programs, I think there would be a good case for a change in ScummVM.
I guess my main gripe is that in DOSBox notes written end-to-end are played almost seamlessly, which makes it possible to write legato passages or almost smooth glissandos. ScummVM starts every new note with a slight pause or "tick" (I didn't record it to be sure), turning strings of short notes into a scratching mess with a 60Hz buzz.
I wonder - does anyone here own a real PCjr/Tandy machine, and could share their experiences? :)
-
I promised to myself: no more MOD hacking, no-one will convert Amiga MODs.
And then this happened...
Cremona.mod (https://modarchive.org/index.php?request=view_player&query=39649) -> Cremona.AGI (https://soundcloud.com/sinus-pi/cremonamod-in-sierra-agi-format)
Original file wasn't tweaked in any way. Just a couple of command-line parameters to make drums out of samples, and reorder channels :P
--instr-note 5 13 --instr-note 11 14 --instr-shift 7 -12 --auto-drum-offs 1 --channels 2,3,4,1
EDIT: Even better with built-in arpeggio for those chord samples: Cremona.AGI with arps (https://soundcloud.com/sinus-pi/cremonamod-in-sierra-agi-format-with-arps)!
Still, just command line parameters...
--length 500 --instr-note 5 13 --instr-note 6 14 --instr-note 5 13 --instr-note 4 15 --instr-note 11 14 --instr-shift 9 12 --instr-shift 12 12 --instr-shift 13 12 --instr-arp 1 047 --instr-arp 2 037 --instr-arp 12 037 --instr-arp 13 047 --auto-drum-offs 1 --channels 2,3,4,1 cremona.mod out_cremona.ags
Sadly, an AGI sound file that long has problems fitting in memory, I had to add a --length parameter to limit the number of note rows processed. That's unfortunate.
-
Daaaaaaaaaaamn :o
-
Daaaaaaaaaaamn :o
Really? Well, look at that post again, it got updated. :P
-
Daaaaaaaaaaamn!
I'll take "Sounds AGI is not supposed to ever make" for $1000, Alex.
-
New feature in the making: "magic noise" instrument. Mark a specific instrument so that the script automatically generates "play noise, borrowing frequency from channel 3" notes on channel 4. And then go all glissando on channel 3! Many notes, big memory footprint, but WIND!
-
I find myself deeply disappointed that the "borrow frequency" mode isn't precise at all. It generates buzz at something like 10.5-note octaves, or rather an octave that doesn't double the frequency. Perhaps it's a DOSBox emulation issue, I'll have to dig into its sources... :/
-
Sooo, with some frequency trickery, it IS possible to hijack the "periodic" buzz noise and make it work as a bass line.
Bass buzz in AGI! (https://soundcloud.com/sinus-pi/sierra-agi-with-bass-buzz)
How's that "sounds AGI is not supposed to ever make" category doing? :P
This sounds consistently in DOSBox and ScummVM, but does it work on the original PCJr/Tandy SN76489 chip? Who knows.
-
Sounds epic! How would I go about in MIDI or IT to get that effect?
-
In the next version, the script will recognize a [BUZZ] tag in an instrument's name, and will generate appropriate notes on the noise channel magically. Of course you won't be able to use drums at that tick.
-
Well, for what it's worth, a new version is out. Add a separate instrument in IT (my usual choice is the Synth Lead - Square from the MIDI Library), give it a name containing [BUZZ], and play some bass notes on the 3rd channel. Let me know if it works, or maybe sounds horrible if your DOSBox/ScummVM happens to sound differently than mine!
-
More features incoming!
- Global volume (initial setting and effect) - perfect for fade-ins and outs
- Channel volume effect
- Volume slide effect
Also, here's a teaser. Direct IT-to-AGI export, no trickery. The NeverEnding Story (https://soundcloud.com/sinus-pi/sierra-agi-sound-the-neverending-story-that-was-not) in Sierra AGI glory! (Only the beginning so far, but yes, solos are coming.)
(Hey, TNES came out in 1984, if Sierra had the rights, they could've made a TNES adventure! Any takers..? :D)
-
You should do an AGI NeverEnding Story trailer or teaser using that soundtrack.
-
Those not in the know wouldn't believe it's the AGI engine producing those sounds.
-
So here's a hot take. Tandy/PCjr use the same chip that the SMS console has. Consoles have a lively music scene. The VGM format stores bytes for the chip ready-to-play. What the hell stopped AGI musicians from using that as a resource..? 🤔 I'm either missing something, or rediscovering the wheel here...
-
Portability.
-
Portability.
Expand? 🤔
Let me rephrase. It seems that whatever is possible on the chip on consoles, should (well, minus crazy hacks) be possible in AGI. But so far I've seen not a single mention of that approach anywhere, so I wondered why. Why are AGI users happy to hear a single note of bass, while it's commonplace on consoles..?
-
Possibly, because it takes a plain ol' 8086 with just under 5 MHz too much effort to process it all while also running the actual game?
And that goes for all games that support the 3-Voice. In fact, even with the single-voice PC speaker, there's a reason the screen freezes up when some games push sampled audio.
-
It doesn't take much to send a few bytes to a sound chip, that can't take much CPU power...
-
You can only send so many bytes per second. More if that's all you do.
Which is also why 8088 MPH's credits have a much nicer-sounding background song than the main demo.
-
Portability.
A sound file consisting of chip-level commands being played on a platform without that chip would need to be converted to something else in order to play it. If it is even feasible, it would drain the CPU. No, there needs to be a platform-neutral file format.
-
Iskovlun: File format, maybe. But the CHIP itself is exactly the same, or, well, a manageable variant of one. Thus, whatever works on consoles, should work - at least to a good extent - on a PC with the same chip embedded.
Well, I went digging in bits. This is far from complete, but here (https://www.smspower.org/Music/Aladdin-SMS) is Aladdin on a Sega Master System, in VGM format. And it plays in AGI (https://soundcloud.com/sinus-pi/aladdin-in-sierra-agi-horrible-but-recognizable) after being run through a VGM-to-AGS script I jerry-rigged today. It sounds horrible, I've yet to figure out why, but the song structure holds, and it's arguably already far ahead of the usual AGI music complexity. So, my point seems to stand.
-
And on what kind of system did you play the song to record it?
-
DOSBox. Sadly, I don't have a true DOS machine available.
I can record one in ScummVM, too, but it has a raspy sound emulation, similar to a bug I -think- I fixed in WinAGI, but I've yet to understand ScummVM's C++ code well enoug to see if a similar buffer flaw manifests there.
-
DOSBox. That's what I thought.
Unless you have DOSBox set to a cycle count that, on your host system, gives roughly 8088 to 286 speed results, with a game scene that's not just a static image like a title screen, it seems my point still stands.
-
But it's still Sierra AGI, with its 60/sec music timing, nothing more than that! I don't suppose a sound file following AGI rules could possibly "overload" the engine, so that it wouldn't play on a regular hardware.
-
There we go! Attached: 'One Jump Ahead' in AGI sound format, ready to import into a homebrew Sierra for nonbelievers. :P
I guess, with proof of concept like thhis, my VGM2AGI script will be joining IT2AGI in the GitHub repo soon.
-
It's less a matter of overloading the processor and more about the limited heap space. aladdin-onejump.ags is an awesome sound resource, but at 29K, it would take up more than half the heap. AGI game programming has always been about balancing the demands of all the active resources in a room (scripts, views, sounds) and engine overhead (logic0, words.tok, objects and animation) to stay within memory limits.
With the possible exception of an intro scene, there's not much room for large sound resources. Sound effects and short music clips are where AGI sound lives.
-
Oh, I'm well aware of the memory footprint. That little song crashes my tested copy of KQ6AGI :)
That was simply a proof of concept, demonstrating that the VGM and AGI sound formats are very closely related, and the rare AGI authors can benefit from the comparably vast area of VGM chiptunes.
-
New version out, now with Sega VGM support (see SMSPower (https://smspower.org/) for some Sega Master System musics).
-
In related news, my patch enabling 16-bit noise shifting, sounding nice and resonant as in SEGA consoles (as opposed to the discordant noises of true PCjr) is in ScummVM now, for some future release.
-
And another new feature coming up: "disable AGI fading" - generates extra notes to keep sound at target volume, instead of letting AGIv2 start to "dissolve" them after their 5th tick. This should be useful in tandem with IT format's NOTE-OFF and NOTE-CUT commands. NOTE-CUT will still terminate a note instantly, but NOTE-OFF will re-enable the fading (or, rather: stop keeping it alive), letting the note fade as it would. This should make it dead easy to control when and how we want to sustain our notes, instead of letting AGI break stuff.
-
Dude.....I have been waiting DECADES for someone to dive this far into AGI sound resource creation! The reason that some of the crazy SMS shenanigans have never been done in AGI is simply because nobody tried it. Or knew how to do it. As long as the sound resource size itself is manageable and not huge or long (most AGI sounds aren't very long at all), I've always felt this should be possible.
It would have been wonderful (still would be!) to get an AGI demo scene going showing off what it could do.
Thank you for this tool!! As an old tracker myself, this pleases me greatly. ;D
-
Oh, I would like nothing more than to see the AGI scene take off! Sadly, the AGI heap limits are terribly tight, so anything more complex would be limited to a minute tops.
I took a bit of a break on other projects (and life), but I'll pick up soon-ish. Destination: IT being the go-to format for tracking AGI music, with as many effects supported as possible.