Mod Trackers - A programming roadblock

Started by Dullstar, October 05, 2009, 03:39:01 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Dullstar

Yeah, there don't seem to be any good .mod trackers for Linux.  I'm getting a little sick of loading up ModPlug in WINE all the time, so... I would like to go about writing my own.  The only problem is, the documentation of the .mod format is so poorly written, I might as well go in and crack it myself.  How would this be done?

Yeah, I currently don't have the programming experience, but we'll worry about that later.

ccexplore

I doubt you want to go the cracking route.  It's more an art than science.  You need a solid understanding of the various ways various types of data are stored in files, and an eye for noticing patterns.  More importantly, you'd likely end up tweaking a few bytes here and there and then checking what gets changed by, yep, playing back the modified MOD file in a MOD tracker.  So yeah, you'll be loading up ModPlug in WINE dozens and dozens of times during the process of trying to crack the file format yourself.  If you're getting "a little sick" of loading ModPlug right now, you'll be downright dead after the numerous usage of ModPlug you'll likely go through trying to crack the file format. http://www.lemmingsforums.com/Smileys/lemmings/wink.gif" alt=";)" title="Wink" class="smiley" />

And even when you do crack the file format, the task of actually writing your own mod tracker will unfortunately likely be 10 times more complex then the cracking.  Even for someone with general programming experience, audio programming is a whole area of expertise itself.

So yeah, your best bet is probably to do a more thorough search on the Internet for Linux MOD trackers.  But if you still want to get information on the MOD file format, I may have some documents I've downloaded that I could try to dig up and send to you.  I can't guarantee though that it will be "well written" or even complete--incomplete information often comes with the territory.  It may also be that you find them hard to read because of your lack of programming knowledge.

Dullstar

I'm learning how to program currently, and I can currently almost write a calculator in two different languages.  So far, I'm liking C.

Even if I do need to load up ModPlug a lot, the end result would make it worth it - I would pretty much use it for quite a while.

Mindless

What are you looking for in tracker software?  If you just want to sequence music, http://code.google.com/p/aldrin-sequencer/" class="bbc_link" target="_blank">Aldrin looks nice.  Granted, it doesn't load .mod files as far as I know, so you can't edit other peoples .mod files... but you can make nice music with it.

ccexplore

I was actually under the impression that Dullstar was simply looking for something to play back MODs (and works natively in Linux Ubuntu), not to create MODs, but now that I reread his posts I don't really know what he's looking for! http://www.lemmingsforums.com/Smileys/lemmings/tongue.gif" alt=":P" title="Tongue" class="smiley" />

Dullstar

I actually am mainly just looking for one that works in any Linux distro at all that makes .mod.

Although an idea that occurred to me recently is to make my own format that just uses basic effects.  I don't need all the effects the format offers...

Do you guys think that's a good idea (don't worry, I won't keep the format shut down or anything).

GuyPerfect

Making a musical representation of your own is simple enough, but it will require a good knowledge of how you can actually get your program to produce the sounds on the computer. Even something as simple as a beep at Middle C frequency is somewhat complicated with PCM output.

Let's say that you're using a PCM output at 44,100hz, mono, 16 bits per sample, and signed. Let's also say that you're using http://en.wikipedia.org/wiki/A440" class="bbc_link" target="_blank">A440 as your tuning standard, and you will be using a standard http://en.wikipedia.org/wiki/Trigonometric_functions#Sine" class="bbc_link" target="_blank">sine wave for the sound. Lastly, let's say that you want to buffer exactly 1 second of audio data.

  • 16 bits per sample and monaural (1 channel) makes for 16 bits per sample, which is 2 bytes. 44100 samples per second makes for a 88200-byte buffer.
  • With A440 tuning, you can calculate the frequency of any note if you know how many half steps it is from Concert A. Middle C is 9 half steps below Concert A, so you'd use the formula 440 * 2 ^ ((-9) / 12) to calculate Middle C, which is about 261.63hz.
  • You'll need to calculate every sample in the buffer. There are 44100 samples in the buffer we've set up; 2 bytes for each (and 1 channel for each). Let X be a number from 0 to 44099 representing the current sample.
  • Sine has a period of 2 * http://en.wikipedia.org/wiki/Pi" class="bbc_link" target="_blank">π, and you'll need to adjust your input argument X to calculate the value according to the desired frequency. The output frequency is 44100hz and Middle C is defined as above.
  • 16-bit signed values range from -32768 to 32767, so you'll need to normalize the output of the Sine function accordingly. Sine returns values ranging from -1.0 to 1.0, so you can easily just multiply the result by 32767 and use that as the value for current sample X.
  • For each sample X, you calculate its value using the formula Buffer[X] = sin(X / (2 * π * MiddleC * OutputFreq)) * 32767...... I think.
  • Then you'll send the buffer to the speakers, a process which will vary depending on the audio architecture installed.