Add Tracker Support to Torque (IT, S3M, XM and MOD)
by Ray Gebhardt · 10/31/2005 (2:01 pm) · 8 comments
Download Code File
The first steps are to download the Dumb playback library from http://dumb.sourceforge.net/. This resource is made using TGE 1.3 and Dumb version 0.9.3. It should probably work with other version of Torque and Dumb, but was tested using those versions. The Mac support for this library may or may not work (I was unable to test it). In addition this resource will only work in streamed mode (preload = false). This shouldn't be an issue, because its a better idea to stream the files anyways.
You will have to build Dumb, using the instructions that come with the distrobution, and add it to your Torque build. If you know how to compile programs, this shouldn't be a big deal.
Once you have Torque and Dumb working together, add the trackerAudioSource.cc and trackerAudioSource.h files to the engine/audio directory. You will also have to add these files to your build process. After you have done that, add the following changes to the Torque C++ code.
Change the following in audio/audio.cc Line 13:
To the following:
Change the following in audio/audio.cc Line 2459:
To the following:
Change the following in audio/audioStreamSourceFactory.cc Line 21:
To the following
Once you have those changes added, and you build Torque, you will be able to use Tracker Files inside of Torque. If you want to try it out, add the following to client/scripts/audioProfiles.cs, in TorqueScript:
Now add the include s3m file 4K4K4K4K.S3M into data/music (you will probably have to create that folder, load up Torque and type the following:
If you want to stop the music type:
The first steps are to download the Dumb playback library from http://dumb.sourceforge.net/. This resource is made using TGE 1.3 and Dumb version 0.9.3. It should probably work with other version of Torque and Dumb, but was tested using those versions. The Mac support for this library may or may not work (I was unable to test it). In addition this resource will only work in streamed mode (preload = false). This shouldn't be an issue, because its a better idea to stream the files anyways.
You will have to build Dumb, using the instructions that come with the distrobution, and add it to your Torque build. If you know how to compile programs, this shouldn't be a big deal.
Once you have Torque and Dumb working together, add the trackerAudioSource.cc and trackerAudioSource.h files to the engine/audio directory. You will also have to add these files to your build process. After you have done that, add the following changes to the Torque C++ code.
Change the following in audio/audio.cc Line 13:
#include "audio/audioStreamSourceFactory.h" #ifdef TORQUE_OS_MAC //#define REL_WORKAROUND #endif
To the following:
#include "audio/audioStreamSourceFactory.h" #include "dumb.h" #ifdef TORQUE_OS_MAC //#define REL_WORKAROUND #endif
Change the following in audio/audio.cc Line 2459:
OpenALDLLShutdown(); }
To the following:
OpenALDLLShutdown(); dumb_exit(); }
Change the following in audio/audioStreamSourceFactory.cc Line 21:
if(len > 3 && !dStricmp(filename + len - 4, ".wav")) return new WavStreamSource(filename); else if(len > 3 && !dStricmp(filename + len - 4, ".ogg")) return new VorbisStreamSource(filename);
To the following
if(len > 3 && !dStricmp(filename + len - 4, ".wav")) return new WavStreamSource(filename); else if(len > 3 && !dStricmp(filename + len - 4, ".ogg")) return new VorbisStreamSource(filename); else if(len > 3 && !dStricmp(filename + len - 3, ".it")) return new TrackerStreamSource(filename); else if(len > 3 && !dStricmp(filename + len - 3, ".xm")) return new TrackerStreamSource(filename); else if(len > 3 && !dStricmp(filename + len - 4, ".s3m")) return new TrackerStreamSource(filename); else if(len > 3 && !dStricmp(filename + len - 4, ".mod")) return new TrackerStreamSource(filename);
Once you have those changes added, and you build Torque, you will be able to use Tracker Files inside of Torque. If you want to try it out, add the following to client/scripts/audioProfiles.cs, in TorqueScript:
new AudioDescription(AudioMusic){
volume = 1.0;
isLooping = true;
isStreaming = true;
is3D = false;
type = $GuiAudioType;
};
new AudioProfile(InGameMusic){
filename = "~/data/music/4K4K4K4K.S3M";
description = "AudioMusic";
preload = false;
};Now add the include s3m file 4K4K4K4K.S3M into data/music (you will probably have to create that folder, load up Torque and type the following:
$music = alxplay(InGameMusic);
If you want to stop the music type:
alxstop($music);
About the author
Recent Blogs
• Torque 3D Concerns• Free Music Pack!
• Nool Music Pack 1 Released!
• New Website in a Blog Format
• GID 22 - BeatBlock
#2
11/01/2005 (2:54 pm)
This is exactly what many indie's need to be able to support a greater variety of music in their games without harming the download size - excellent work!
#3
12/04/2005 (6:46 pm)
what exactly is a tracker? i know it's some audio related thing, but can i get a little more specific info? i went to the dumb website and it said it played certain things, but didn't explain what those things were, so i went to their websites and it still wasn't very informative to the noobs out there!
#4
12/04/2005 (10:57 pm)
'The Short' It
#5
12/05/2005 (7:41 am)
great thanks!
#6
"You will have to build Dumb, using the instructions that come with the distrobution, and add it to your Torque build. If you know how to compile programs, this shouldn't be a big deal."
But between the somewhat antiquated instructions that come with DUMB 0.9.3, and my complete unfamiliarity with VS2003, I am a bit lost. If, perchance, someone were to provide a bit more detail, I'd be eternally grateful. *sigh*...I hate not knowing stuff.
08/06/2006 (2:19 pm)
I know that I'm supposed to know how to:"You will have to build Dumb, using the instructions that come with the distrobution, and add it to your Torque build. If you know how to compile programs, this shouldn't be a big deal."
But between the somewhat antiquated instructions that come with DUMB 0.9.3, and my complete unfamiliarity with VS2003, I am a bit lost. If, perchance, someone were to provide a bit more detail, I'd be eternally grateful. *sigh*...I hate not knowing stuff.
#7
I'm an old Amiga fan, so getting tracker support is like... Awesome!
03/24/2009 (12:17 pm)
I just saw this, and I'm gonna try to plug this into TGE 1.5.2I'm an old Amiga fan, so getting tracker support is like... Awesome!
#8
02/11/2010 (7:09 am)
It would be great if it was supported format from Renoise for Torque
Associate James Urquhart
Place the following at the top somewhere in trackerStreamSource.cc :
static int dumb_torque_skip(void *f, long n) { Stream *str = static_cast<Stream*>(f); if (str->setPosition(str->getPosition() + n)) return 0; else return -1; } static int dumb_torque_getc(void *f) { Stream *str = static_cast<Stream*>(f); S8 ret = 0; str->read(&ret); return ret; } static long dumb_torque_getnc(char *ptr, long n, void *f) { Stream *str = static_cast<Stream*>(f); U32 oldPos = str->getPosition(); U32 totalSize = str->getStreamSize(); // If totalSize - oldPos < n, skim it if ((totalSize - oldPos) < n) { totalSize -= oldPos; if (str->read(totalSize, ptr)) return n; else return 0; } if (str->read(n, ptr)) return n; else return 0; } static void *dumb_torque_open(const char *filename) { return ResourceManager->openStream(filename); } static void dumb_torque_close(void *f) { Stream *str = static_cast<Stream*>(f); if (f) ResourceManager->closeStream(str); } static DUMBFILE_SYSTEM torque_dfs = { &dumb_torque_open, &dumb_torque_skip, &dumb_torque_getc, &dumb_torque_getnc, &dumb_torque_close };(Also make sure you ' #include "res/resManager.h" ' if it isn't already).To use these callbacks, replace the call to "dumb_register_stdfiles", as in :
// load a file using dumb //atexit(&dumb_exit); // dumb_register_stdfiles(); register_dumbfile_system(torque_dfs); dumb_it_max_to_mix = 256;Now, *hopefully* the tracker files will work with zipped archives.