|
LibXM7
|
A C library to play XM (and MOD) modules on Nintendo DS using only ARM7 resources (thus freeing your ARM9 from that task).
The current version of libXM7 (1.06) can play XMs featuring the following characteristics:
libXM7 has complete effect support. For reference, these are the effects:
0xy Arpeggio1xx Portamento up (M)2xx Portamento down (M)3xx Portamento to note (M)4xy Vibrato (M)5xy Portamento to note with volume slide (M)6xy Vibrato with volume slide (M)7xy Tremolo (M)8xx Set note panning9xx Set sample offset (M)Axy Slide note volume up or down (M)Bxx Jump to positionCxx Set note volumeDxx Pattern breakE1x Fine portamento up (M)E2x Fine portamento down (M)E3x Glissando controlE4x Vibrato controlE5x Instrument finetuneE6x Pattern loopE7x Tremolo controlE8x Set note panningE9x Retrig noteEAx Slide note fine volume up (M)EBx Slide note fine volume down (M)ECx Note cutEDx Note delayEEx Pattern delayFxx Set song speedGxx Set global volumeHxy Slide global volume up or down (M)Kxx Key offLxx Set envelope positionPxy Panning slide (M)Rxy Retrig note with volume slide (M)Txy Tremor (M)X1x Extra fine portamento up (M)X2x Extra fine portamento down (M)(M) Means that this effect has "memory".
The volume column effects support is also complete. For your reference the effects follows:
xx Set note volume (0x10-0x50)Dx Slide note volume down (0x60-0x6F)Ux Slide note volume up (0x70-0x7F)dx Slide note fine volume down (0x80-0x8F)ux Slide note fine volume up (0x90-0x9F)Sx Set vibrato speed (0xA0-0xAF)Vx Vibrato (0xB0-0xBF)Px Set note panning (0xC0-0xCF)Lx Slide note panning left (0xD0-0xDF)Rx Slide note panning right (0xE0-0xEF)Mx Portamento to note (0xF0-0xFF)There's a very good document explaining XM effects (and volume column effects) usage here, on MilkyTracker website.
The library can play also MODs featuring the following characteristics:
M.K., M!K! and FLT4 module subtypes 4 channels modulesOCTA, CD81 and FLT8 (*) module subtypes 8 channels modulesTDZx module subtype 1 to 3 channels modulesxCHN module subtype 2 to 9 channels modulesxxCH module subtype 10 to 16 channels modulesOf course libXM7 has complete MOD effect support (because they're a subset of XM effects).
(*) Yeah, I mean FLT8 really.
Since the library doesn't manipulate the samples data directly but simply uses the Nintendo DS hardware 16 digital channels to replay samples, there are some things you should be aware of when composing tunes especially for this system. First of all, remember that hardware mixing among the channels on a Nintendo DS will result in a 10bits/32kHz stereo sound being reproduced. It's not poor quality, but it isn't exactly CD quality either. In the mixing process the samples don't get resampled when pitched so make sure you disable this feature in your tracker (sample interpolation) if you want to simulate the output you would get on the DS as better as possible.
The DS hardware also wants all the figures to be in 32bit boundaries, which means that the samples should conform to some rules:
A side effect (detuning) is possible when these rules are ignored, and it could be perceivable on samples with loops, especially when the repeating part of the sample is very short.
Finally, it's impossible for the DS hardware to start playing a sample that has a loop from inside the loop from other position but the beginning. This means that you should put some care in preparing your samples having loops if you plan to use the 9xx (Set sample offset) effect on them. Anyway there are no problems if you simply plan to skip samples of the non-repeating part of a sample with loop.
The library consists of one header file (libxm7.h) and two archive files (libxm77.a and libxm79.a). You should add the path with the header file to your include paths, say the include/libxm7 directory. On the other hand, you should add the libs directory to your linker paths. Then you should modify the makefiles for your project: locate the line where the libraries are listed (LIBS := -l<library> -l<library>) and add -lxm77 in the ARM7 makefile and LIBDIRS := path/to/libxm7/libs. Add also -lmx79 in the ARM9 makefile if you plan to use both libXM7 library parts. Make sure that -lxm77 appears before -lnds7 and that -lxm79 appears before -lnds9.
libXM7 is a combined library: it has one part that is linked to the ARM9 executable and another part that is linked to the ARM7 executable. However the library implements no means of communication between the processors. So it's up to the programmer to choose a suitable way to communicate, let's say, to the ARM7 where the ARM9 has loaded the module that the former should play. Also, the programmer is supposed to ensure that the XM7_StopModule() gets executed on ARM7 before XM7_UnloadXM() gets executed on ARM9. By the way, you can even write your own module loader (for instance one that reads directly from FAT) and not use the libXM7 ARM9 part of that library. So, since the ARM7 part is the core of this library, it can be used independently.
libnds comes with a really handy interface for FIFO based Interprocessor Communication. The example sourcecode included above uses this interface.
The ARM7 part of the library interacts directly with the Nintendo DS hardware. More precisely, it interacts with:
As already mentioned, it doesn't interact with anything else, in particular:
So you have to take care of both according to your needs.