DS GBA
mmInit

Back to Index

Prototype

void mmInit( mm_ds_system* system );
void mmInit( mm_gba_system* system );

Parameters

system

Maxmod setup configuration.

Description

Initializes Maxmod with the settings specified.

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

For GBA projects, irqInit() should be called before this function.

DS Example

void maxmodInit( void )
{
    mm_ds_system sys;
    
    // 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" );
}

GBA Example

// Mixing buffer (globals should go in IWRAM)
// Mixing buffer SHOULD be in IWRAM, otherwise the CPU load
// will _drastially_ increase
u8 myMixingBuffer[ MM_MIXLEN_16KHZ ] __attribute((aligned(4)));

void maxmodInit( void )
{
    irqSet( IRQ_VBLANK, mmVBlank );

    u8* myData;
    mm_gba_system mySystem;
 
    // allocate data for channel buffers & wave buffer (malloc'd data goes to EWRAM)
    // Use the SIZEOF definitions to calculate how many bytes to reserve
    myData = (u8*)malloc( 8 * (MM_SIZEOF_MODCH
                               +MM_SIZEOF_ACTCH
                               +MM_SIZEOF_MIXCH)
                               +MM_MIXLEN_16KHZ );
    
    // setup system info
    // 16KHz software mixing rate, select from mm_mixmode
    mySystem.mixing_mode       = MM_MIX_16KHZ;

    // number of module/mixing channels
    // higher numbers offer better polyphony at the expense
    // of more memory and/or CPU usage.
    mySystem.mod_channel_count = 8;
    mySystem.mix_channel_count = 8;
    
    // Assign memory blocks to pointers
    mySystem.module_channels   = (mm_addr)(myData+0);
    mySystem.active_channels   = (mm_addr)(myData+(8*MM_SIZEOF_MODCH));
    mySystem.mixing_channels   = (mm_addr)(myData+(8*(MM_SIZEOF_MODCH
	                                             +MM_SIZEOF_ACTCH)));
    mySystem.mixing_memory     = (mm_addr)myMixingBuffer;
    mySystem.wave_memory       = (mm_addr)(myData+(8*(MM_SIZEOF_MODCH
                                                     +MM_SIZEOF_ACTCH
                                                     +MM_SIZEOF_MIXCH)));
    // Pass soundbank address
    mySystem.soundbank         = (mm_addr)soundbank;

    // Initialize Maxmod
    mmInit( &mySystem );
}

See Also

mmInitDefault, mmInitDefaultMem, mmInstall, mm_ds_system, mm_gba_system