Cavestory Mod API
Macros | Typedefs | Functions
Sound

In-house math functions. More...

Macros

#define SOUND_MODE_STOP   0
 Stop sound. More...
 
#define SOUND_MODE_STOP_THEN_PLAY   1
 Stop and then play a sound. More...
 
#define SOUND_MODE_PLAY   2
 Play a sound. More...
 

Typedefs

typedef int CSM_CustomPixToneId
 A custom sound ID.
 
typedef int CSM_CustomSoundId
 

Functions

CAVESTORY_MOD_API CSM_CustomPixToneId CSM_LoadPixTone (const char *pPath)
 Load a custom pixtone file. More...
 
CAVESTORY_MOD_API CSM_CustomSoundId CSM_LoadCustomSound (const char *pPath)
 Load a custom sound file. More...
 
CAVESTORY_MOD_API void CSM_SetCustomSoundPan (CSM_CustomSoundId iSoundId, unsigned char iPanAmount=50)
 Set the pan amount of a custom sound. More...
 
CAVESTORY_MOD_API void CSM_SetCustomSoundVolume (CSM_CustomSoundId iSoundId, unsigned char iVolume)
 Set the volume of a custom sound. More...
 
CAVESTORY_MOD_API BOOL CSM_UnloadPixTone (CSM_CustomPixToneId iSoundId)
 Unload a custom sound file. More...
 
CAVESTORY_MOD_API BOOL CSM_UnloadCustomSound (CSM_CustomSoundId iSoundId)
 Unload a custom sound file. More...
 
CAVESTORY_MOD_API void CSM_Sound_Process2D ()
 Process the 2D soundscape.
 
CAVESTORY_MOD_API void PlaySoundObject2D (int iSubpixelX, int iSubpixelY, int iRadius, bool bAlwaysOnScreen, int iSoundIndex, int iPlayMode=SOUND_MODE_STOP_THEN_PLAY, unsigned int iPlayVolume=0x100, unsigned int iFalloffRadius=0x7FFFFFFE)
 Play a sound by index at a specific place in the game. More...
 
CAVESTORY_MOD_API void CSM_Sound_SetPitch (int iSoundIndex, unsigned short iPitch)
 Set the pitch of a sound. More...
 
CAVESTORY_MOD_API void CSM_Sound_SetPan (int iSoundIndex, char iPan)
 Set the panning of a sound. More...
 
CAVESTORY_MOD_API void CSM_Sound_SetVolume (int iSoundIndex, unsigned char iVolume)
 Set the volume of a sound. More...
 
CAVESTORY_MOD_API void PlaySoundObject (int iSoundIndex, int iPlayMode=SOUND_MODE_STOP_THEN_PLAY, unsigned int iPlayVolume=0x100)
 Play a sound by index. More...
 
CAVESTORY_MOD_API BOOL IsSoundPlaying (int iSoundId)
 Check if a sound is playing. More...
 
CAVESTORY_MOD_API void ChangeMusic (int iMusicIndex)
 Set the current music track. More...
 
CAVESTORY_MOD_API void PlayCustomMusic (const char *pFileName)
 Play custom music. More...
 
CAVESTORY_MOD_API void CSM_Music_SetVolume (unsigned char iVolume)
 Set the volume of music. More...
 
CAVESTORY_MOD_API void ReCallMusic ()
 Recall the last played music. More...
 

Detailed Description

In-house math functions.

Several helpful in-house math functions.

Macro Definition Documentation

◆ SOUND_MODE_PLAY

#define SOUND_MODE_PLAY   2

Play a sound.

See also
PlaySoundObject

Tells PlaySoundObject to immediately play a sound.

◆ SOUND_MODE_STOP

#define SOUND_MODE_STOP   0

Stop sound.

See also
PlaySoundObject

Tells PlaySoundObject to stop the sound.

◆ SOUND_MODE_STOP_THEN_PLAY

#define SOUND_MODE_STOP_THEN_PLAY   1

Stop and then play a sound.

See also
PlaySoundObject

Tells PlaySoundObject to stop the sound, and then plays it afterwards.

Function Documentation

◆ ChangeMusic()

CAVESTORY_MOD_API void ChangeMusic ( int  iMusicIndex)

Set the current music track.

Parameters
iMusicIndexThe index of the music to play.

◆ CSM_LoadCustomSound()

CAVESTORY_MOD_API CSM_CustomSoundId CSM_LoadCustomSound ( const char *  pPath)

Load a custom sound file.

Parameters
pPathThe file path of the sound file.
Returns
Returns a non-zero ID of the new sound on success, -1 on failure.

◆ CSM_LoadPixTone()

CAVESTORY_MOD_API CSM_CustomPixToneId CSM_LoadPixTone ( const char *  pPath)

Load a custom pixtone file.

Parameters
pPathThe file path of the sound file.
Returns
Returns a non-zero ID of the new sound on success, -1 on failure.

◆ CSM_Music_SetVolume()

CAVESTORY_MOD_API void CSM_Music_SetVolume ( unsigned char  iVolume)

Set the volume of music.

Parameters
iVolumeThe new volume of the music. Must be 0 - 255, with 255 being the loudest and 0 being inaudible.

◆ CSM_SetCustomSoundPan()

CAVESTORY_MOD_API void CSM_SetCustomSoundPan ( CSM_CustomSoundId  iSoundId,
unsigned char  iPanAmount = 50 
)

Set the pan amount of a custom sound.

Parameters
iSoundIdThe ID of the sound to manipulate.
iPanAmountThe amount of pan (0 - 100). Center = 50.

◆ CSM_SetCustomSoundVolume()

CAVESTORY_MOD_API void CSM_SetCustomSoundVolume ( CSM_CustomSoundId  iSoundId,
unsigned char  iVolume 
)

Set the volume of a custom sound.

Parameters
iSoundIdThe ID of the sound to manipulate.
iVolumeThe volume (0 - 100).

◆ CSM_Sound_SetPan()

CAVESTORY_MOD_API void CSM_Sound_SetPan ( int  iSoundIndex,
char  iPan 
)

Set the panning of a sound.

Parameters
iSoundIndexThe index of the sound.
iPanThe new pan of the sound. Must be between -127 and 127, with 0 being normal pan.

◆ CSM_Sound_SetPitch()

CAVESTORY_MOD_API void CSM_Sound_SetPitch ( int  iSoundIndex,
unsigned short  iPitch 
)

Set the pitch of a sound.

Parameters
iSoundIndexThe index of the sound.
iPitchThe new pitch of the sound. Must be between 0 and 1000, with 500 being normal pitch.

◆ CSM_Sound_SetVolume()

CAVESTORY_MOD_API void CSM_Sound_SetVolume ( int  iSoundIndex,
unsigned char  iVolume 
)

Set the volume of a sound.

Parameters
iSoundIndexThe index of the sound.
iVolumeThe new volume of the sound. Must be between 0 and 255, with 255 being loudest.

◆ CSM_UnloadCustomSound()

CAVESTORY_MOD_API BOOL CSM_UnloadCustomSound ( CSM_CustomSoundId  iSoundId)

Unload a custom sound file.

Parameters
iSoundIdThe ID of the sound file to unload.
Returns
Returns TRUE on success, FALSE otherwise.

◆ CSM_UnloadPixTone()

CAVESTORY_MOD_API BOOL CSM_UnloadPixTone ( CSM_CustomPixToneId  iSoundId)

Unload a custom sound file.

Parameters
iSoundIdThe ID of the sound file to unload.
Returns
Returns TRUE on success, FALSE otherwise.

◆ IsSoundPlaying()

CAVESTORY_MOD_API BOOL IsSoundPlaying ( int  iSoundId)

Check if a sound is playing.

Parameters
iSoundIdThe sound to test for.
Returns
Returns TRUE if the sound is still playing, FALSE otherwise.

◆ PlayCustomMusic()

CAVESTORY_MOD_API void PlayCustomMusic ( const char *  pFileName)

Play custom music.

Parameters
pFileNameThe filename of the music file to play.

◆ PlaySoundObject()

CAVESTORY_MOD_API void PlaySoundObject ( int  iSoundIndex,
int  iPlayMode = SOUND_MODE_STOP_THEN_PLAY,
unsigned int  iPlayVolume = 0x100 
)

Play a sound by index.

Parameters
iSoundIndexThe index of the sound.
iPlayModeHow to play the sound. Default is #CSM_SOUND_MODE_STOP_THEN_PLAY.
iPlayVolumeThe volume of the sound, from 0 to 0x100.

◆ PlaySoundObject2D()

CAVESTORY_MOD_API void PlaySoundObject2D ( int  iSubpixelX,
int  iSubpixelY,
int  iRadius,
bool  bAlwaysOnScreen,
int  iSoundIndex,
int  iPlayMode = SOUND_MODE_STOP_THEN_PLAY,
unsigned int  iPlayVolume = 0x100,
unsigned int  iFalloffRadius = 0x7FFFFFFE 
)

Play a sound by index at a specific place in the game.

Plays a sound at a subpixel coordinate with a given distance.

Parameters
iSubpixelXThe X subpixel coordinate to play the sound at.
iSubpixelYThe Y subpixel coordinate to play the sound at.
iRadiusThe distance that this will be hearable at, in subpixels.
bAlwaysOnScreenIf this is set to 'TRUE', then iRadius is used as the distance from the edge of the screen that the sound needs to be in order to be heard.
iSoundIndexThe index of the sound.
iPlayModeHow to play the sound. Default is #CSM_SOUND_MODE_STOP_THEN_PLAY.
iPlayVolumeThe volume of the sound, from 0 to 0x100.
iFalloffRadiusThe sound falloff radius. Will be clamped to iRadus.

◆ ReCallMusic()

CAVESTORY_MOD_API void ReCallMusic ( )

Recall the last played music.

Parameters
iMusicIndexThe index of the music to play