typedef struct t_mmgbasystem { mm_mixmode mixing_mode;mm_word mod_channel_count;mm_word mix_channel_count;mm_addr module_channels;mm_addr active_channels;mm_addr mixing_channels;mm_addr mixing_memory;mm_addr wave_memory;mm_addr soundbank; } mm_gba_system;
Software mixing rate. May be 8, 10, 13, 16, 18, or 21 KHz (select value from enum). Higher values offer better quality at expense of a larger CPU and memory load.
This is the amount of module channels there will be. It must be greater or equal to the largest channel number used by your modules (notice: NOT virtual channel number).
Number of mixing channels. Higher numbers offer better polyphony at expense of larger memory footprint and CPU load.
Pointer to module channel buffer, this can be placed in EWRAM. Size of buffer must be MM_SIZEOF_MODCH * mod_channel_count bytes.
Pointer to active channel buffer, this can be placed in EWRAM. Size of buffer must be MM_SIZEOF_ACTCH * mix_channel_count bytes.
Pointer to mixing channel buffer, this can be placed in EWRAM. Size of buffer must be MM_SIZEOF_MIXCH * mix_channel_count bytes.
Pointer to mixing buffer, should be placed in IWRAM. Placing this buffer in EWRAM will cause a much higher CPU load. See description for size specification.
Pointer to wave output buffer, this can be placed in EWRAM. see description for size specification.
Pointer to your soundbank file. (Most likely somewhere in the cartridge space)
GBA setup information, passed to mmInit.
About mixing_memory: The mixing memory is a heavily used area of memory and should most definitely be located in the fast IWRAM. By default, devkitARM will place any global variables in IWRAM. The size of this buffer depeds on the mixing rate selected. Here are the five definitions from maxmod.h:
|
These definitions contain the size of the mixing buffer in bytes. If you're using 16KHz mixing rate, your mixing buffer should be defined like this (as a global array):
u8 my_mixing_buffer[ MM_MIXEN_16KHZ ] __attribute((aligned(4))); |
Notice also that the mixing buffer should be aligned by 4 bytes.
About the wave buffer: The wave buffer is a not-so-heavily used area of memory and can be placed in EWRAM. The wave buffer contains the final waveform data that is DMA copied to the sound FIFO. The size of the waveform buffer must be equal to the size of the mixing buffer. By default (devkitARM), the malloc function can be used to allocate the wave buffer in EWRAM. The wave buffer must be aligned by 4 bytes too.