Maxmod
Loading...
Searching...
No Matches
Enumerations | Functions
Headless: Initialization/Main Functions

Enumerations

enum  mm_headless_output_format {
  MM_OUTFMT_STEREO_U8 = 0 ,
  MM_OUTFMT_STEREO_S8 = 1
}
 Output formats supported by Maxmod. More...
 

Functions

bool mmEnd (void)
 Deinitializes Maxmod.
 
mm_callback mmGetEventHandler (void)
 Returns the event handler previously installed by the user.
 
mm_word mmGetModuleCount (void)
 Returns the number of modules available in the soundbank.
 
mm_word mmGetSampleCount (void)
 Returns the number of samples available in the soundbank.
 
bool mmInitDefault (const char *soundbank_path, mm_word number_of_channels, mm_word sample_rate, mm_headless_output_format output_format)
 Initialize Maxmod with default settings with a soundbank stored in the filesystem.
 
bool mmInitDefaultMem (mm_addr soundbank, mm_word number_of_channels, mm_word sample_rate, mm_headless_output_format output_format)
 Initialize Maxmod with default settings with a soundbank stored in RAM.
 
void mmMix (mm_addr buffer, mm_word total_samples)
 This is the main routine-function that processes music and updates the sound output.
 
void mmSetEventHandler (mm_callback handler)
 Install handler to receive song events.
 

Detailed Description

Enumeration Type Documentation

◆ mm_headless_output_format

Output formats supported by Maxmod.

Enumerator
MM_OUTFMT_STEREO_U8 

Unsigned 8-bit stereo output.

MM_OUTFMT_STEREO_S8 

Signed 8-bit stereo output.

Function Documentation

◆ mmEnd()

bool mmEnd ( void  )

Deinitializes Maxmod.

If Maxmod was initialized with mmInitDefault(), it also frees the memory allocated by it.

If Maxmod was initialized with mmInit(), the user is responsible for freeing the memory passed to it when Maxmod was initialized.

Returns
It returns true on success, false on error.

◆ mmGetEventHandler()

mm_callback mmGetEventHandler ( void  )

Returns the event handler previously installed by the user.

Returns
Function pointer to the event handler currently installed.

◆ mmGetModuleCount()

mm_word mmGetModuleCount ( void  )

Returns the number of modules available in the soundbank.

Returns
The number of modules.

◆ mmGetSampleCount()

mm_word mmGetSampleCount ( void  )

Returns the number of samples available in the soundbank.

Note
This number includes the samples used by all the songs in the soundbank, not just the sound effects in WAV format.
Returns
The number of samples.

◆ mmInitDefault()

bool mmInitDefault ( const char *  soundbank_path,
mm_word  number_of_channels,
mm_word  sample_rate,
mm_headless_output_format  output_format 
)

Initialize Maxmod with default settings with a soundbank stored in the filesystem.

Parameters
soundbank_pathPath to the soundbank file. A soundbank file can be created with the Maxmod Utility.
number_of_channelsNumber of module/mixing channels to allocate. Must be greater or equal to the channel count in your modules. The maximum value allowed is 256.
sample_rateThe sample rate to be used by Maxmod. Any value is allowed.
output_modeFormat of the output of Maxmod.
Returns
It returns true on success, false on error.

◆ mmInitDefaultMem()

bool mmInitDefaultMem ( mm_addr  soundbank,
mm_word  number_of_channels,
mm_word  sample_rate,
mm_headless_output_format  output_format 
)

Initialize Maxmod with default settings with a soundbank stored in RAM.

Parameters
soundbankMemory address of soundbank (in ROM). A soundbank file can be created with the Maxmod Utility.
number_of_channelsNumber of module/mixing channels to allocate. Must be greater or equal to the channel count in your modules. The maximum value allowed is 256.
sample_rateThe sample rate to be used by Maxmod. Any value is allowed.
output_modeFormat of the output of Maxmod.
Returns
It returns true on success, false on error.

◆ mmMix()

void mmMix ( mm_addr  buffer,
mm_word  total_samples 
)

This is the main routine-function that processes music and updates the sound output.

This function must be called whenever the user wants Maxmod to generate new samples and write them to a buffer.

The output format is currently hardcoded to 8-bit signed samples. The output is stereo, and left and right channels are interleaved (L, R, L, R ...).

Parameters
bufferDestination buffer. The size must be total_samples * 2.
total_samplesThe number of samples to save to the buffer. In total, it saves total_samples * 2 because the output is 8-bit stereo.

◆ 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).

During the song event, Maxmod is in the middle of module processing. Avoid using any Maxmod related functions during your song event handler since they may cause problems in this situation.

Check the song events tutorial in the documentation for more information.

Parameters
handlerFunction pointer to event handler.