Maxmod
Functions
NDS: ARM9 Initialization/Main Functions

Functions

void mmInit (mm_ds_system *system)
 Initializes Maxmod with the settings specified. More...
 
void mmInitDefault (char *soundbank_file)
 Initialize Maxmod with default settings. More...
 
void mmInitDefaultMem (mm_addr soundbank)
 Initialize Maxmod with default settings. More...
 
void mmLoad (mm_word module_ID)
 Loads a module into memory for playback. More...
 
void mmLoadEffect (mm_word sample_ID)
 Loads a sound effect into memory for playback. More...
 
void mmLockChannels (mm_word bitmask)
 Lock audio channels to prevent Maxmod from using them. More...
 
void mmSelectMode (mm_mode_enum mode)
 Switches the audio mode for Maxmod DS. More...
 
void mmSetCustomSoundBankHandler (mm_callback p_loader)
 Install a custom routine to interface with the soundbank data. More...
 
void mmSetEventHandler (mm_callback handler)
 Install handler to receive song events. More...
 
void mmSoundBankInFiles (char *filename)
 Setup the standard interface for a soundbank that is loaded in the file system. More...
 
void mmSoundBankInMemory (mm_addr address)
 Enable the standard interface for a soundbank that is loaded into memory. More...
 
void mmUnload (mm_word module_ID)
 Unloads and frees memory space occupied by a module. More...
 
void mmUnloadEffect (mm_word sample_ID)
 Unloads a sound effect and frees the memory if the reference count becomes zero. More...
 
void mmUnlockChannels (mm_word bitmask)
 Unlocks audio channels to allow Maxmod to use them. More...
 

Detailed Description

Function Documentation

◆ mmInit()

void mmInit ( mm_ds_system system)

Initializes Maxmod with the settings specified.

Initialize system. Call once at startup.

For DS projects, you must also setup a soundbank interface with one of the mmSoundBank* functions.

Parameters
systemMaxmod setup configuration.

Example:

void maxmodInit( void )
{
// Number of modules in your soundbank (defined in output header)
sys.mod_count = MSL_NSONGS;
// Number of samples in your soundbank (defined in output header)
sys.samp_count= MSL_NSAMPS;
// Memory bank, allocate BANKSIZE (or NSONGS+NSAMPS) words
sys.mem_bank = malloc( MSL_BANKSIZE * 4 );
// Select FIFO channel
sys.fifo_channel = FIFO_MAXMOD;
// Initialize maxmod
mmInit( &sys );
mmSoundBankInMemory( (mm_addr)my_soundbank );
// or
//
//mmSoundBankInFiles( "my_soundbank.msl" );
}
void mmInit(mm_gba_system *setup)
Initializes Maxmod with the settings specified.
void * mm_addr
Memory address (pointer)
Definition: mm_types.h:44
void mmSoundBankInMemory(mm_addr address)
Enable the standard interface for a soundbank that is loaded into memory.
DS setup information.
Definition: mm_types.h:317
mm_word fifo_channel
FIFO channel to use for communicating with ARM7. Usually FIFO_MAXMOD.
Definition: mm_types.h:331
mm_word mod_count
Number of modules in the soundbank file. Write MSL_NSONGS here.
Definition: mm_types.h:319
mm_word samp_count
Number of samples in the soundbank file. Write MSL_NSAMPS here.
Definition: mm_types.h:322
mm_word * mem_bank
Pointer to a memory region to be used for managing modules/samples:
Definition: mm_types.h:328

◆ mmInitDefault()

void mmInitDefault ( char *  soundbank_file)

Initialize Maxmod with default settings.

For DS, this function also sets up the internal soundbank interface to use the file specified.

Parameters
soundbank_fileFilename of soundbank. A soundbank file can be created with the Maxmod Utility.

◆ mmInitDefaultMem()

void mmInitDefaultMem ( mm_addr  soundbank)

Initialize Maxmod with default settings.

This function also sets up the internal soundbank interface to use the file that is located somewhere in memory.

Use this when you have the entire soundbank loaded into memory.

Parameters
soundbankAddress of soundbank data.

◆ mmLoad()

void mmLoad ( mm_word  module_ID)

Loads a module into memory for playback.

Must be used before starting to play a module with mmStart().

Parameters
module_IDIndex of module to be loaded. Values are defined in the soundbank header output. (prefixed with "MOD_")

◆ mmLoadEffect()

void mmLoadEffect ( mm_word  sample_ID)

Loads a sound effect into memory for playback.

May be played with mmEffect()/mmEffectEx() afterwards.

Parameters
sample_IDIndex of sample to be loaded. Values are defined in the soundbank header output (prefixed with "SFX_)

◆ mmLockChannels()

void mmLockChannels ( mm_word  bitmask)

Lock audio channels to prevent Maxmod from using them.

This is for when you need to operate on the DS hardware channels directly. Note that if you use this function while music or sound effects are playing, any active notes that are using the channels to be locked will be cut.

Parameters
bitmaskSelection of channels to lock. Bit0 = Channel0, Bit1 = Channel1 ... Bit15 = Channel15

◆ mmSelectMode()

void mmSelectMode ( mm_mode_enum  mode)

Switches the audio mode for Maxmod DS.

Hardware mixing offers 16-channel audio with minimal CPU load.

Interpolated mixing extends the capability of the hardware channels by adding linear interpolation in software.

Extended mixing increases the channel count to 30 with software mixing.

Parameters
modeNew audio mode. Pass MM_MODE_A for complete hardware mixing, MM_MODE_B for interpolated mixing, or MM_MODE_C for extended mixing.

◆ mmSetCustomSoundBankHandler()

void mmSetCustomSoundBankHandler ( mm_callback  p_loader)

Install a custom routine to interface with the soundbank data.

The routine will be responsible for handling requests from Maxmod to access data in the soundbank.

Parameters
p_loaderFunction pointer to soundbank request handler.

◆ mmSetEventHandler()

void mmSetEventHandler ( mm_callback  handler)

Install handler to receive song events.

Use this function to receive song events. Song events occur in two situations. One is by special pattern data in a module (which is triggered by SFx/EFx commands). The other occurs when a module finishes playback (in MM_PLAY_ONCE mode).

Parameters
handlerFunction pointer to event handler.

◆ mmSoundBankInFiles()

void mmSoundBankInFiles ( char *  filename)

Setup the standard interface for a soundbank that is loaded in the file system.

This function should be called after mmInit and before any Load or Unload operations. This function is called by mmInitDefault.

Parameters
filenameFilename of your soundbank binary.

◆ mmSoundBankInMemory()

void mmSoundBankInMemory ( mm_addr  address)

Enable the standard interface for a soundbank that is loaded into memory.

This function should be called after mmInit and before any Load or Unload functions. This function is called by mmInitDefaultMem.

Parameters
addressMemory address of soundbank file.

◆ mmUnload()

void mmUnload ( mm_word  module_ID)

Unloads and frees memory space occupied by a module.

Caution: Ensure that the module to be unloaded isn't playing!

Parameters
module_IDIndex of module to be unloaded from memory.

◆ mmUnloadEffect()

void mmUnloadEffect ( mm_word  sample_ID)

Unloads a sound effect and frees the memory if the reference count becomes zero.

Parameters
sample_IDIndex of sample to be unloaded.

◆ mmUnlockChannels()

void mmUnlockChannels ( mm_word  bitmask)

Unlocks audio channels to allow Maxmod to use them.

This function can be used to restore channel usage to Maxmod when you are finished using certain channels.

Note that in the "Interpolated Audio" mode, channels can not be unlocked. To unlock channels in the interpolated mode you must reset the audio system. To reset the audio system, use mmSelectMode.

Parameters
bitmaskSelection of channels to unlock. Bit0 = Channel0, Bit1 = Channel1, Bit2 = Channel2 ... Bit15 = Channel15