sparrowSound

SparrowSound is for sound output.  Most calls and types are just renames of libSDL_mixer functions with error handling.  For more details (especially about what is not wrapped here) have a look at http://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_frame.html

Summary
sparrowSoundSparrowSound is for sound output.
SP_VOLUME_MAXThe maximal volume of a channel or chunk/spSound.
spSoundThis type ist just Mix_Chunk from SDL Mixer renamed for better usage (I don’t like the SDL name).
spSoundInitThis inits spSound.
spSoundSetChannelsSets the maximum count of channels.
spSoundQuitThis has to be called at the end of the program.
spSoundPauseAllPauses or resumes all music and sounds.
Background music functionsThese functions are for the background music.
spSoundSetMusicSets the background music file.
spSoundPlayMusicPlays the loaded music from spSoundSetMusic with optional fade in and repeating.
spSoundStopMusicStops playing the loaded music with optional fade out.
spSoundPauseMusicPauses or resumes the music.
spSoundSetMusicVolumeSets the volume of the background music.
spSoundGetMusicVolumeReturns the volume of the background music.
Sound sample functionsThese functions are for the sound samples.
spSoundLoadLoads a spSound from a file.
spSoundPlayPlays a spSound sound.
spSoundStopStops a channel.
spSoundPausePauses or resumes a channel.
spSoundDeleteDeletes a sound.
spSoundSetVolumeSets the volume of all sound.
spSoundGetVolumeReturns the volume of all sounds.

SP_VOLUME_MAX

The maximal volume of a channel or chunk/spSound.  Same as MIX_MAX_VOLUME from SDL Mixer.

spSound

This type ist just Mix_Chunk from SDL Mixer renamed for better usage (I don’t like the SDL name).  Of course you can use the SDL-type-name or use this types with SDL-mixer functions

spSoundInit

PREFIX int spSoundInit(void)

This inits spSound.  Without no sound will be possible!  It returns 1 at success and 0 at failure.  If it failure, every spSound function will still be callable without crash - there will just be no sound.

Returns

int1 at success, 0 at failure

spSoundSetChannels

PREFIX void spSoundSetChannels(int channels)

Sets the maximum count of channels.  More channels need more space and time to get handled.  The default is 8 on most systems.

Parameters

channelsthe new count of channels

spSoundQuit

PREFIX void spSoundQuit(void)

This has to be called at the end of the program.

spSoundPauseAll

PREFIX void spSoundPauseAll(int pause)

Pauses or resumes all music and sounds.  Every new started sound will be pause, too.

Parameters

pause1 if you want to pause, 0 if you want to resume

See Also

spSoundPause, spSoundPauseMusic

Background music functions

These functions are for the background music.

spSoundSetMusic

PREFIX int spSoundSetMusic(char *filename)

Sets the background music file.  Every function for background music uses this function.  It’s like spBindTexture for music.  ^^’ To start the music use spSoundPlayMusic afterwards.

Parameters

filenamethe music file to be used.  Many formats are supported depending on the system. ogg, mp3, flac, wav should always be fine, but I already had system without mpe-support.  In doubt use ogg or flac.

Returns

int1 at success, 0 at failure

See Also

spSoundLoad

spSoundPlayMusic

PREFIX int spSoundPlayMusic(int fadeIn,
int loops)

Plays the loaded music from spSoundSetMusic with optional fade in and repeating.

Parameters

fadeInif greater 0, the duration of the fade in
loopsthe amount of times the background music will be played.  -1 means “infinite” times and 0 means just once (0 repeats ;))

Returns

int1 at success, 0 at failure

spSoundStopMusic

PREFIX int spSoundStopMusic(int fadeOut)

Stops playing the loaded music with optional fade out.

Parameters

fadeOutif greater 0, the duration of the fade out

Returns

int1 at success, 0 at failure

spSoundPauseMusic

PREFIX void spSoundPauseMusic(int pause)

Pauses or resumes the music.

Parameters

pause1 pauses and 0 resumes

See Also

spSoundPauseAll, spSoundPauseMusic

spSoundSetMusicVolume

PREFIX void spSoundSetMusicVolume(int volume)

Sets the volume of the background music.

Parameters

volumethe new volume of the music.  Music and (all) sounds have different volumes!

See Also

spSoundGetMusicVolume, spSoundSetVolume

spSoundGetMusicVolume

PREFIX int spSoundGetMusicVolume(void)

Returns the volume of the background music.

Returns int - the set volume of the music.  Music and (all) sounds have different volumes!

See Also

spSoundSetMusicVolume, spSoundGetVolume

Sound sample functions

These functions are for the sound samples.

spSoundLoad

PREFIX spSound* spSoundLoad(char *filename)

Loads a spSound from a file.  The loaded file is not played automaticly, use spSoundPlay for this.

Parameters

filenamethe file to be loaded.  Many formats are possible like wav, ogg, mp3 or flac.  But some systems don’t support everything so it is a good idea to stay with ogg and flac.

See Also

spSoundSetMusic

spSoundPlay

PREFIX int spSoundPlay(spSound *sound,
int channel,
int loops,
int fadeIn,
int maxTime)

Plays a spSound sound.

Parameters

soundthe sound to be played
channelif you want to play on a specific channel, use this parameter, if you don’t care (what you will most of the time) use -1
loopsthe amount of times the sound will be played.  -1 means “infinite” times and 0 means just once (0 repeats ;))
fadeInif greater 0, the duration of the fade in
maxTimethe maximal time of playing the sound even with “infinite” loops.  -1 means no maximal duration

Returns

intthe channel, in which the sound is played

spSoundStop

PREFIX void spSoundStop(int soundChannel,
int fadeOut)

Stops a channel.  You have to stop channels instead of spSounds, because one sound can be played multiple times on multiple channels.

Parameters

soundChannelthe channel to be stopped.  -1 stops every channel
fadeOutif greater 0 this is the duration of a fade out

spSoundPause

PREFIX void spSoundPause(int pause,
int channel)

Pauses or resumes a channel.

Parameters

pauseuse 1 for pause and 0 for resume
channelthe channel to be paused or resumed.  -1 means every channel is pause or resumed.  To pause or resume every channel and the background music use spSoundPauseAll

See Also

spSoundPauseAll, spSoundPauseMusic

spSoundDelete

PREFIX void spSoundDelete(spSound *sound)

Deletes a sound.

Parameters

soundthe sound to be deleted

spSoundSetVolume

PREFIX void spSoundSetVolume(int volume)

Sets the volume of all sound.

Parameters

volumethe new volume of all sounds.  Music and (all) sounds have different volumes!

See Also

spSoundGetVolume, spSoundSetMusicVolume

spSoundGetVolume

PREFIX int spSoundGetVolume(void)

Returns the volume of all sounds.

Returns int - the set volume of all sounds.  Music and (all) sounds have different volumes!

See Also

spSoundSetVolume, spSoundGetMusicVolume

PREFIX int spSoundInit(void)
This inits spSound.
PREFIX void spSoundSetChannels(int channels)
Sets the maximum count of channels.
PREFIX void spSoundQuit(void)
This has to be called at the end of the program.
PREFIX void spSoundPauseAll(int pause)
Pauses or resumes all music and sounds.
PREFIX int spSoundSetMusic(char *filename)
Sets the background music file.
PREFIX int spSoundPlayMusic(int fadeIn,
int loops)
Plays the loaded music from spSoundSetMusic with optional fade in and repeating.
PREFIX int spSoundStopMusic(int fadeOut)
Stops playing the loaded music with optional fade out.
PREFIX void spSoundPauseMusic(int pause)
Pauses or resumes the music.
PREFIX void spSoundSetMusicVolume(int volume)
Sets the volume of the background music.
PREFIX int spSoundGetMusicVolume(void)
Returns the volume of the background music.
PREFIX spSound* spSoundLoad(char *filename)
Loads a spSound from a file.
This type ist just Mix_Chunk from SDL Mixer renamed for better usage (I don’t like the SDL name).
PREFIX int spSoundPlay(spSound *sound,
int channel,
int loops,
int fadeIn,
int maxTime)
Plays a spSound sound.
PREFIX void spSoundStop(int soundChannel,
int fadeOut)
Stops a channel.
PREFIX void spSoundPause(int pause,
int channel)
Pauses or resumes a channel.
PREFIX void spSoundDelete(spSound *sound)
Deletes a sound.
PREFIX void spSoundSetVolume(int volume)
Sets the volume of all sound.
PREFIX int spSoundGetVolume(void)
Returns the volume of all sounds.
PREFIX void spBindTexture(SDL_Surface *texture)
This texture will be used for all following draw operations with textures
Close