CRM32Pro SDK  v5.22
List of all members | Public Member Functions

ISoundFX. More...

Detailed Description

ISoundFX.

Sound,music and FX effects interface.

Public Member Functions

int AllocateChannels (int nch)
 Dynamically change the number of channels managed by the mixer. More...
 
int ChannelFadeIn (int ch, int hndSound, int loops, int ms)
 Channel fade in. More...
 
int ChannelFadeOut (int ch, int ms)
 Channel fade out. More...
 
int ChannelGetVolume (int ch)
 Channel get volume. More...
 
int ChannelIsPaused (int ch)
 Check a mixing channel pause status. More...
 
void ChannelPause (int ch)
 Channel pause. More...
 
void ChannelResume (int ch)
 Channel resume. More...
 
void ChannelStop (int ch)
 Channel stop. More...
 
void ChannelVolume (int ch, int vol)
 Channel volume control. More...
 
unsigned char Export (char *fileDPF, char *namesnd, char m, char *s=NULL)
 Export audio from a DPF(using a filename) to a filename. More...
 
unsigned char Export (int idDPF, char *namesnd, char m, char *s=NULL)
 Export audio from a DPF(using an idDPF) to a filename. More...
 
unsigned char Init (int frequency, unsigned short format, int channels, int chunksize)
 Initialize sound system. More...
 
unsigned char Init ()
 Try to initialize sound system according to CRM32Pro.Config. More...
 
int Initialized ()
 Was sound system activated? More...
 
int IsPlaying (void)
 Check if music is playing. More...
 
int IsPlaying (int ch)
 Check if a mixing channel is playing. More...
 
int MusicFadeIn (int hndMusic, int loops, int ms)
 Music fade in. More...
 
int MusicFadeOut (int ms)
 Music fade out. More...
 
void MusicFree (int hndMusic)
 Free a music. More...
 
int MusicGetVolume ()
 Music get volume. More...
 
int MusicImport (char *fileDPF, char *namemus, char *filemus)
 Import a XM,IT,MOD,S3M or OGG music in to a DPF file(using filename) More...
 
int MusicImport (int idDPF, char *namemus, char *filemus)
 Import a XM,IT,MOD,S3M or OGG music in to a DPF file(using idDPF) More...
 
unsigned char MusicInfo (char *fileDPF, char *namemus, sAudioType *mustype)
 Get information about given music track stored on DPF(using an idDPF) or file. Only supports OGG,XM,MOD,IT and S3M. More...
 
unsigned char MusicInfo (int idDPF, char *namemus, sAudioType *mustype)
 Get information about given music track stored on DPF(using an idDPF) or file. Only supports OGG,XM,MOD,IT and S3M. More...
 
int MusicIsPaused (void)
 Check the music pause status. More...
 
int MusicLoad (const char *f)
 Load a XM,IT,S3M,MOD and OGG music from an external file. More...
 
int MusicLoad (char *fileDPF, char *musname)
 Load a XM,IT,S3M,MOD and OGG music from a DPF file(using a filename) More...
 
int MusicLoad (int idDPF, char *musname)
 Load a XM,IT,S3M,MOD and OGG music from a DPF file(using an idDPF) More...
 
void MusicPause (void)
 Pause music.
 
int MusicPlay (int hndMusic, int loops)
 Play a music track (XM,S3M,MOD,IT or OGG) More...
 
void MusicResume (void)
 Resume music from a paused or stopped status.
 
void MusicRewind (void)
 Rewind the music to the start.
 
void MusicStop (void)
 Music stop.
 
void MusicVolume (int vol)
 Music volume control. More...
 
void NoInit ()
 Turn off sound output.
 
void QuerySpec (int *freq, unsigned short *format, int *ch)
 Query sound system features. More...
 
void Quit (void)
 Close sound system.
 
void SoundFree (int hndSound)
 Free a sound. More...
 
int SoundGetVolume (int hndSound)
 Sound get volume. More...
 
int SoundImport (char *fileDPF, char *namesnd, char *filesnd)
 Import a WAV,VOC,AIFF and OGG sound in to DPF(using a filename) More...
 
int SoundImport (int idDPF, char *namesnd, char *filesnd)
 Import a WAV,VOC,AIFF and OGG sound in to DPF(using an idDPF) More...
 
unsigned char SoundInfo (char *fileDPF, char *namesnd, sAudioType *sndtype)
 Get information about given sound stored on DPF or file. Only supports WAV,VOC,AIFF and OGG. More...
 
unsigned char SoundInfo (int idDPF, char *namesnd, sAudioType *sndtype)
 Get information about given sound stored on DPF(an idDPF) or file. Only supports WAV,VOC,AIFF and OGG. More...
 
int SoundLoad (const char *f)
 Load a WAV,VOC,AIFF and OGG sound from a filename. More...
 
int SoundLoad (char *fileDPF, char *namesnd)
 Load a WAV,VOC,AIFF and OGG sound from a DPF(using a filename) More...
 
int SoundLoad (int idDPF, char *namesnd)
 Load a WAV,VOC,AIFF and OGG sound from a DPF(using an idDPF) More...
 
void SoundPlay (int ch, int hndSound, int loops)
 Play a sound. More...
 
void SoundVolume (int hndSound, int vol)
 Sound volume control. More...
 

Member Function Documentation

int CRM32Pro_ISoundFX::AllocateChannels ( int  nch)

Dynamically change the number of channels managed by the mixer.

The default mixer has 8 simultaneous mixing channels. If decreasing the number of channels, the upper channels are stopped. This has nothing to do with audio output channels (mono,stereo, etc.)

Parameters
nchNumber of mixing channels. A negative number will not do anything, it will tell you how many channels are currently allocated.
Returns
the new number of allocated channels.
int CRM32Pro_ISoundFX::ChannelFadeIn ( int  ch,
int  hndSound,
int  loops,
int  ms 
)

Channel fade in.

The effect is performed on the background (this method does not delay the execution)

Parameters
chmixing channel to play on, or -1 for the first free unreserved mixing channel
hndSoundsound handle to play
loopsnumber of loops, -1 is infinite loops. Passing one here plays the sample twice (1 loop)
mstime in milliseconds
Returns
-1 Failed
Otherwise the mixing channel the sample is played on.
int CRM32Pro_ISoundFX::ChannelFadeOut ( int  ch,
int  ms 
)

Channel fade out.

The effect is performed on the background (this method does not delay the execution)

Parameters
chmixing channel to fade out or -1 to fade all mixing channels out
mstime in milliseconds
Returns
-1 failed
Otherwise, the number of mixing channels set to fade out
int CRM32Pro_ISoundFX::ChannelGetVolume ( int  ch)

Channel get volume.

Parameters
chmixing channel. With -1, it will get the volume for all allocated mixing channels.
Returns
current volume
int CRM32Pro_ISoundFX::ChannelIsPaused ( int  ch)

Check a mixing channel pause status.

Parameters
chmixing channel to test whether it is paused or not. With -1 it just return the number of paused mixing channels.
Returns
0 mixing channel is not paused
Otherwise if you passed in -1, the number of paused mixing channels is returned. If you passed in a specific mixing channel, then 1 is returned if it is paused.
void CRM32Pro_ISoundFX::ChannelPause ( int  ch)

Channel pause.

Parameters
chmixing channel to pause playing, or -1 for all allocated mixing channels
void CRM32Pro_ISoundFX::ChannelResume ( int  ch)

Channel resume.

Parameters
chmixing channel to resume playing, or -1 for all allocated mixing channels
void CRM32Pro_ISoundFX::ChannelStop ( int  ch)

Channel stop.

Parameters
chmixing channel to stop playing, or -1 for all allocated mixing channels.
void CRM32Pro_ISoundFX::ChannelVolume ( int  ch,
int  vol 
)

Channel volume control.

Parameters
chmixing channel. With -1, it will set the volume for all allocated mixing channels.
volvolume range 0 to 128.
unsigned char CRM32Pro_ISoundFX::Export ( char *  fileDPF,
char *  namesnd,
char  m,
char *  s = NULL 
)

Export audio from a DPF(using a filename) to a filename.

Parameters
fileDPFDPF file that contains the audio(sound or music)
namesndname of the sound or music. If it has '/' or '\', it will create the path.
m0 if it is a sound and 1 if it is a music.
sby default, is NULL. Use it if you want to change the file name (an optional path) of output file.
Returns
0 Failed
1 Ok
unsigned char CRM32Pro_ISoundFX::Export ( int  idDPF,
char *  namesnd,
char  m,
char *  s = NULL 
)

Export audio from a DPF(using an idDPF) to a filename.

Parameters
idDPFID of the opened DPF
namesndname of the sound or music. If it has '/' or '\', it will create the path.
m0 if it is a sound and 1 if it is a music.
sby default, is NULL. Use it if you want to change the file name (an optional path) of output file.
Returns
0 Failed
1 Ok
unsigned char CRM32Pro_ISoundFX::Init ( int  frequency,
unsigned short  format,
int  nchannels,
int  chunksize 
)

Initialize sound system.

Parameters
frequencyfrequency in Hz (11025,22050,44200)
formatAUDIO_S8 to 8bits or AUDIO_S16 to 16bits sound resolution
nchannelsnumber of audio output channels: 1 for mono, 2 for stereo, 4 for surround and 6 for surround with center and lfe. This has nothing to do with mixing channels.
chunksizebuffer size, use 4096 for normal operation
Returns
0 Failed
1 Ok
Examples:
Example01_BasicCode.cpp, and SpacePong.cpp.
unsigned char CRM32Pro_ISoundFX::Init ( )

Try to initialize sound system according to CRM32Pro.Config.

Returns
-1 Failed
0 Audio is not enabled (CRM32Pro.Config.AudioEnable = 0)
1 Ok
int CRM32Pro_ISoundFX::Initialized ( )

Was sound system activated?

Returns
0 Is not active
1 Is active
int CRM32Pro_ISoundFX::IsPlaying ( void  )

Check if music is playing.

Returns
0 music is not playing
1 music is playing
Examples:
SpacePong.cpp.
int CRM32Pro_ISoundFX::IsPlaying ( int  ch)

Check if a mixing channel is playing.

Parameters
chmixing channel to check. -1 will return how many mixing channels are playing
Returns
0 mixing channel is not playing
otherwise if you passed in -1, the number of mixing channels playing is returned. If you passed in a specific mixing channel, then 1 is returned if it is playing
int CRM32Pro_ISoundFX::MusicFadeIn ( int  hndMusic,
int  loops,
int  ms 
)

Music fade in.

The effect is performed on the background (this method does not delay the execution)

Parameters
hndMusicmusic handle to play
loopsnumber of times to play through the music. 0 plays the music zero times and -1 plays it forever
mstime in milliseconds
Returns
0 Ok
-1 Error
int CRM32Pro_ISoundFX::MusicFadeOut ( int  ms)

Music fade out.

The effect is performed on the background (this method does not delay the execution)

Parameters
mstime in milliseconds
Returns
0 Failed
1 Ok
Examples:
SpacePong.cpp.
void CRM32Pro_ISoundFX::MusicFree ( int  hndMusic)

Free a music.

Parameters
hndMusicmusic handle to be deleted
Examples:
SpacePong.cpp.
int CRM32Pro_ISoundFX::MusicGetVolume ( )

Music get volume.

Returns
current volume
int CRM32Pro_ISoundFX::MusicImport ( char *  fileDPF,
char *  namemus,
char *  filemus 
)

Import a XM,IT,MOD,S3M or OGG music in to a DPF file(using filename)

Parameters
fileDPFDPF filename to store the music
namemus(to be stored with this name inside the DPF)
filemusmusic filename
Returns
-1 Music already exists.
0 Failed.
any other positive value, Ok and packed size of the added music
int CRM32Pro_ISoundFX::MusicImport ( int  idDPF,
char *  namemus,
char *  filemus 
)

Import a XM,IT,MOD,S3M or OGG music in to a DPF file(using idDPF)

Parameters
idDPFID of the opened DPF
namemusmusic name (to be stored with this name inside the DPF)
filemusmusic filename
Returns
-1 Music already exists.
0 Failed.
any other positive value, Ok and packed size of the added music
unsigned char CRM32Pro_ISoundFX::MusicInfo ( char *  fileDPF,
char *  namemus,
sAudioType mustype 
)

Get information about given music track stored on DPF(using an idDPF) or file. Only supports OGG,XM,MOD,IT and S3M.

Parameters
fileDPFDPF file to look for the music
namemusif "fileDPF" is NULL, this is the name of external file. Otherwise, this is music name
mustypepointer to sAudioType
Returns
0 Failed
1 Ok
unsigned char CRM32Pro_ISoundFX::MusicInfo ( int  idDPF,
char *  namemus,
sAudioType mustype 
)

Get information about given music track stored on DPF(using an idDPF) or file. Only supports OGG,XM,MOD,IT and S3M.

Parameters
idDPFID of the opened DPF
namemusif idDPF is 0, this is the name of external file. Otherwise, this is music name
mustypepointer to sAudioType
Returns
0 Failed
1 Ok
int CRM32Pro_ISoundFX::MusicIsPaused ( void  )

Check the music pause status.

Returns
0 music is not paused
1 music is paused
int CRM32Pro_ISoundFX::MusicLoad ( const char *  fname)

Load a XM,IT,S3M,MOD and OGG music from an external file.

Parameters
fnamefilename that contains the music
Returns
-1 Failed
any other value, the music handle
Examples:
SpacePong.cpp.
int CRM32Pro_ISoundFX::MusicLoad ( char *  fileDPF,
char *  namemus 
)

Load a XM,IT,S3M,MOD and OGG music from a DPF file(using a filename)

Parameters
fileDPFDPF filename that contains the music
namemusmusic name
Returns
-1 Failed
any other value, the music handle
int CRM32Pro_ISoundFX::MusicLoad ( int  idDPF,
char *  namemus 
)

Load a XM,IT,S3M,MOD and OGG music from a DPF file(using an idDPF)

Parameters
idDPFID of the opened DPF
namemusmusic name
Returns
-1 Failed
any other value, the music handle
int CRM32Pro_ISoundFX::MusicPlay ( int  hnd,
int  loops 
)

Play a music track (XM,S3M,MOD,IT or OGG)

Parameters
hndmusic handle to play
loopsnumber of times to play through the music. 0 plays the music zero times and -1 plays it forever
Returns
-1 error
0 Ok
Examples:
SpacePong.cpp.
void CRM32Pro_ISoundFX::MusicVolume ( int  vol)

Music volume control.

Parameters
volvolume range 0 to 128.
void CRM32Pro_ISoundFX::QuerySpec ( int *  freq,
unsigned short *  format,
int *  ch 
)

Query sound system features.

Parameters
freqpointer to integer to get the frequency in Hz (11025,22050,44200)
formatpointer to Uint16 to get the sound resolution (8bits or 16bits)
chpointer to an int where the number of audio output channels will be stored. Its value is 1 for mono, 2 for stereo, 4 for surround and 6 for surround with center and lfe
void CRM32Pro_ISoundFX::SoundFree ( int  hndSound)

Free a sound.

Parameters
hndSoundsound handle to be deleted
Examples:
Example01_BasicCode.cpp, and SpacePong.cpp.
int CRM32Pro_ISoundFX::SoundGetVolume ( int  hndSound)

Sound get volume.

Parameters
hndSoundsound handle to get the volume
Returns
current volume
int CRM32Pro_ISoundFX::SoundImport ( char *  fileDPF,
char *  namesnd,
char *  filesnd 
)

Import a WAV,VOC,AIFF and OGG sound in to DPF(using a filename)

Parameters
fileDPFDPF filename
namesndsound name (to be stored with this name inside the DPF)
filesndfilename with the sound
Returns
-1 Sound already exists.
0 Failed.
any other positive value, Ok and packed size of the added sound
int CRM32Pro_ISoundFX::SoundImport ( int  idDPF,
char *  namesnd,
char *  filesnd 
)

Import a WAV,VOC,AIFF and OGG sound in to DPF(using an idDPF)

Parameters
idDPFID of the opened DPF
namesndsound name (to be stored with this name inside the DPF)
filesndfilename with the sound
Returns
-1 Sound already exists.
0 Failed.
any other positive value, Ok and packed size of the added sound
unsigned char CRM32Pro_ISoundFX::SoundInfo ( char *  fileDPF,
char *  namesnd,
sAudioType sndtype 
)

Get information about given sound stored on DPF or file. Only supports WAV,VOC,AIFF and OGG.

Parameters
fileDPFDPF file to look for the sound
namesndif "fileDPF" is NULL, this is the name of external file. Otherwise, this is sound name
sndtypepointer to sAudioType
Returns
0 Failed
1 Ok
unsigned char CRM32Pro_ISoundFX::SoundInfo ( int  idDPF,
char *  namesnd,
sAudioType sndtype 
)

Get information about given sound stored on DPF(an idDPF) or file. Only supports WAV,VOC,AIFF and OGG.

Parameters
idDPFID of the opened DPF
namesndif idDPF is 0, this is the name of an external file. Otherwise, this is sound name
sndtypepointer to sAudioType
Returns
0 Failed
1 Ok
int CRM32Pro_ISoundFX::SoundLoad ( const char *  f)

Load a WAV,VOC,AIFF and OGG sound from a filename.

Parameters
ffile that contains the sound
Returns
-1 Failed
any other value, the sound handle
Examples:
Example01_BasicCode.cpp, and SpacePong.cpp.
int CRM32Pro_ISoundFX::SoundLoad ( char *  fileDPF,
char *  namesnd 
)

Load a WAV,VOC,AIFF and OGG sound from a DPF(using a filename)

Parameters
fileDPFDPF file that contains the sound
namesndsound name
Returns
-1 Failed
any other value, the sound handle
int CRM32Pro_ISoundFX::SoundLoad ( int  idDPF,
char *  namesnd 
)

Load a WAV,VOC,AIFF and OGG sound from a DPF(using an idDPF)

Parameters
idDPFID of the opened DPF
namesndsound name
Returns
-1 Failed
any other value, the sound handle
void CRM32Pro_ISoundFX::SoundPlay ( int  ch,
int  hndSound,
int  loops 
)

Play a sound.

Parameters
chmixing channel to play on, or -1 for the first free unreserved mixing channel
hndSoundsound handle to play
loopsnumber of loops, -1 is infinite loops. Passing one here plays the sample twice (1 loop)
Examples:
Example01_BasicCode.cpp, and SpacePong.cpp.
void CRM32Pro_ISoundFX::SoundVolume ( int  hndSound,
int  vol 
)

Sound volume control.

Parameters
hndSoundsound handle to adjust the volume
volvolume range 0 to 128.

The documentation for this class was generated from the following files: