Famitracker FTM file converter

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Famitracker FTM file converter
by on (#73155)
(split from http://nesdev.com/bbs/viewtopic.php?p=73152#73152)

I was designing my tool to handle multiple output formats, both in terms of assembler syntax and targeted music player.

The general design: The tool is split (internally) into three parts:

  1. The "front-end" just parses the FTM file and loads it into a set of data structures.
  2. The "back-end" is a small set of routines that emits assembler-syntax specific lines of code.
  3. The converter of "middle" is a set of routines that converts the FTM data into calls to the back-end. The middle is back-end agnostic.

I had started the middle targeting famitone with back-ends for nesasm and ca65. I was using "diff" against my output with Shiru's "text2data" output to ensure that I was getting byte-for-byte the correct output.

I then wandered off-path and merged the back and middle pieces targeting a famitone inspired music player with ca65 syntax only. Once I get this working, I will then split the back and middle pieces back out.

My main concern with any music player isn't the size of the runtime, but the CPU cycles that it consumes. For my own personal + immediate use, I have a very limited amount of CPU to give to a music player.

This is an example of what I think the tool will look like from a user's point of view:

Code:
Usage: ftm-exporter -t target -f format [-o filename.asm] [[-i] filename.ftm]

-t (famitone|gradualore|xyzplayer|...)
-f (ca65|nesasm|asm6...)
-o filename.s
[-i] input.ftm [input2.ftm ...]


If input file is not specified, ftm-exporter will read FTM file(s) from stdin. If output file is not specified, asm will be emitted to stdout.

Tool will log warnings and errors to stderr and exit with a non-zero exit code on errors (invalid data in FTM file, etc...). The tool is meant to be Unix / Makefile friendly.

I would like to have a feature where it will intelligently merge multiple FTM files into a single set of emitted assembly. It will identify duplicate instruments and patterns and remove the duplicates. However, I don't need this feature today, so I have not focused on it.

I'll let you guys know when I the tool is stable and I'll put the source somewhere for others to review / modify / use. I host my own subversion server, but I suppose that I could put it on source forge. Ideally, jsr would accept it as a "contribution" to Famitracker, and place the source with Famitracker on source-forge.

by on (#82314)
Nice tool you got there. If you could have it export MIDI, my life would be complete :)
jsr said he can't do it. He said he doesn't have the time and he doesn't see the point in doing so. I can think of a few good reasons.

by on (#82320)
Doommaster1994 wrote:
Nice tool you got there. If you could have it export MIDI, my life would be complete :)
jsr said he can't do it. He said he doesn't have the time and he doesn't see the point in doing so. I can think of a few good reasons.


http://pastebin.com/kbEtTeN2

It compiles with GCC v4.4.5 and MSdev Studio 98 (VC6... yeah, 1998 is calling, I know...)

I was originally going to target Famitone (output format), but changed to my own. Dumping the FTM file is much easier than striping the data out of it. The dumping portion (look for code with the word "emit" in it) can be rewritten. The code is incomplete. Many features were never implemented, and their vestigal parts are still in the source. Feel free to use this code as you guys wish.

In the end, I didn't use this tool. I ended up coding music myself using some ca65 macros and just hand-writing custom bytecode.

I have not touched my project since late May. I wasn't going to finish it on time for the 2011 minigame compo, and I had to focus on some consulting work during my free time.

Doommaster, feel free to add MIDI export capabilities. If you do so successfully, be kind and share the source.

by on (#83011)
LOL
Dude, I don't even know the first thing about programming. I'm taking a game design class next month where I learn C++. I don't know if that will help.