PSXSDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Enumerations | Functions
modplay.h File Reference
#include <psx.h>

Go to the source code of this file.

Data Structures

struct  ModSample
 
struct  ModInstrument
 Instrument. More...
 
struct  ModMusic
 Music. More...
 

Enumerations

enum  modplay_formats { MOD_FMT_MOD }
 Format identification IDs. More...
 
enum  modload_flags { MODLOAD_NOSAMPLES = 1 }
 Flags for MODLoad. More...
 

Functions

ModMusicMODLoadEx (void *d, unsigned int flags)
 Allocate a ModMusic structure and copy data to it from data in memory containing a music module file.
 
ModMusicMODLoad (void *d)
 Just like MODLoadEx() but with the flags parameters set to zero, i.e.
 
void MODPlay (ModMusic *m, int *t)
 Play a tick of a music.
 
void MODStop (ModMusic *m)
 Stop a music.
 
void MODRewind (ModMusic *m)
 Rewind music, that is, make it restart from the beginning.
 
int MODUploadSamples (ModMusic *m, int base_addr)
 Upload the samples of the module music to Sound RAM.
 
void MODSetBaseVoice (int base_voice)
 Sets the SPU voice to use as the first channel when playing music.
 
void MODSetTranspose (ModMusic *m, short transpose)
 Sets transpose for music.
 
int MOD4PSX_Upload (void *d, int base_addr)
 Upload preconverted ADPCM samples, as generated by the mod4psx tool.
 
void MODUnload (ModMusic *m)
 Free memory allocated for music module.
 
void MODSetMaxVolume (unsigned short max_volume)
 Set maximum volume for MODPlay.
 
void MODSetMono (int value)
 Set mono mode.
 

Enumeration Type Documentation

Flags for MODLoad.

Enumerator:
MODLOAD_NOSAMPLES 

Do not load the samples in memory.

Format identification IDs.

Enumerator:
MOD_FMT_MOD 

Function Documentation

int MOD4PSX_Upload ( void *  d,
int  base_addr 
)

Upload preconverted ADPCM samples, as generated by the mod4psx tool.

Parameters
dPointer to buffer containing the ADPCM samples archive
base_addrBase address at which the samples will start to be uploaded.
Returns
The sound address after all the uploaded samples
ModMusic* MODLoad ( void *  d)

Just like MODLoadEx() but with the flags parameters set to zero, i.e.

default behaviour.

Parameters
dPointer to a buffer containing a music module file
Returns
Pointer to newly allocated ModMusic structure.
ModMusic* MODLoadEx ( void *  d,
unsigned int  flags 
)

Allocate a ModMusic structure and copy data to it from data in memory containing a music module file.

Almost all data from the music module file is copied into another location in memory for the ModMusic structure.

This means your free memory should be roughly the double of the size of the MOD you're loading.

You can avoid loading the samples in the module file's native format, thus saving useful memory, by passing the MODLOAD_NOSAMPLES flag. This is especially the case when you use MOD4PSX_Upload().

Parameters
dPointer to a buffer containing a music module file
flagsFlag bitmask.
Returns
Pointer to newly allocated ModMusic structure.
void MODPlay ( ModMusic m,
int *  t 
)

Play a tick of a music.

This has to be called 60 / 50 times per second.

MODPlay decreases the value referenced by t every time the music finishes.

Set the variable pointed by t when you want to set the number of times again!

Parameters
mPointer to ModMusic structure
tPointer to an int which contains how many times the music module has to be played. i.e. if *t == 1, play once, if *t == 2, play twice, ..., if *t == -1, loop endlessly
void MODRewind ( ModMusic m)

Rewind music, that is, make it restart from the beginning.

Parameters
mPointer to ModMusic structure for the music.
void MODSetBaseVoice ( int  base_voice)

Sets the SPU voice to use as the first channel when playing music.

The voice for the second channel will then be this (value+1), and so on...

Usually the base voice is 0; a MOD file can have up to eight channels, so take care of that.

A 669 file can always have 8 channels.

Parameters
base_voiceDesired base voice (0-23)
void MODSetMaxVolume ( unsigned short  max_volume)

Set maximum volume for MODPlay.

Parameters
max_volumeMaximum volume desired (0-0x3FFF)
void MODSetMono ( int  value)

Set mono mode.

Parameters
valueIf 0 set stereo mode, if 1 set mono mode
void MODSetTranspose ( ModMusic m,
short  transpose 
)

Sets transpose for music.

Changing the transpose value for a music shifts the frequency its samples are played at, but the music's tempo is unchanged.

Parameters
mPointer to ModMusic structure
transposeTranspose value
void MODStop ( ModMusic m)

Stop a music.

Parameters
mPointer to ModMusic structure for the music.
void MODUnload ( ModMusic m)

Free memory allocated for music module.

Parameters
mPointer to ModMusic structure
int MODUploadSamples ( ModMusic m,
int  base_addr 
)

Upload the samples of the module music to Sound RAM.

Parameters
mPointer to ModMusic structure for the music.
base_addrSound RAM address to start from when uploading to Sound RAM If -1 it is interpreted to be the same as the start of the section for sound data in Sound RAM (SPU_DATA_BASE_ADDR). base_addr must be a multiply of 8.
Returns
The sound address after all the uploaded samples