MTek-GDL 0.100.4-muffintrap
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions
mgdl-sound.h File Reference

Sound module header. More...

#include "mgdl-types.h"
#include <mgdl/mgdl-openal.h>
#include <stdlib.h>
#include <sndfile.h>

Go to the source code of this file.

Data Structures

struct  Sound
 Sound handling struct. More...
 

Typedefs

typedef enum SoundStatus SoundStatus
 
typedef struct Sound Sound
 

Enumerations

enum  SoundStatus { Stopped , Playing , Paused , Initial }
 

Functions

SoundSound_Create (void)
 Allocates a new Sound with empty variables.
 
SoundSound_Load (const char *filename)
 Loads a sound file.
 
void Sound_DeleteData (Sound *sound)
 Deletes the sound data stored in the object.
 
void Sound_Play (Sound *sound)
 Plays a sound.
 
void Sound_PlayEx (Sound *sound, float pitchOffset, float volumePercent)
 Plays a sound with extended paramters.
 
void Sound_Stop (Sound *sound)
 Stops the playback of the sound.
 
void Sound_SetPaused (Sound *sound, bool pause)
 Pauses the playback of the sound.
 
void Sound_SetLooping (Sound *sound, bool looping)
 
bool Sound_GetLooping (Sound *sound)
 
float Sound_GetElapsedSeconds (Sound *sound)
 Get elapsed playback time in seconds.
 
void Sound_SetElapsedSeconds (Sound *sound, float elapsed)
 
SoundStatus Sound_GetStatus (Sound *sound)
 Get if the voice is playing or not.
 

Detailed Description

Sound module header.

Function Documentation

◆ Sound_Create()

Sound * Sound_Create ( void  )

Allocates a new Sound with empty variables.

Returns
New Sound

◆ Sound_DeleteData()

void Sound_DeleteData ( Sound sound)

Deletes the sound data stored in the object.

Deallocates the memory buffer containing the loaded sound data.

◆ Sound_GetElapsedSeconds()

float Sound_GetElapsedSeconds ( Sound sound)

Get elapsed playback time in seconds.

This function returns how long the sound has been playing in seconds

Returns
Elapsed playback time in seconds

◆ Sound_GetStatus()

SoundStatus Sound_GetStatus ( Sound sound)

Get if the voice is playing or not.

This function can be used to know if the voice is currently playing

Returns
True if voice is playing, false if not playing

◆ Sound_Load()

Sound * Sound_Load ( const char *  filename)

Loads a sound file.

This function loads a sound file which can then be played with Play() or Play2D().

Note
This port of the library only supports uncompressed Microsoft WAV sound files with a sample format of 8 or 16-bit and a sample frequency of up to 48KHz, Mono or Stereo.
Parameters
[in]*fileNameFile name of sound file to load.
Returns
Pointer if the sound file was successfully loaded, otherwise a null pointer

◆ Sound_Play()

void Sound_Play ( Sound sound)

Plays a sound.

Plays a sound

◆ Sound_PlayEx()

void Sound_PlayEx ( Sound sound,
float  pitchOffset,
float  volumePercent 
)

Plays a sound with extended paramters.

Plays a sound with pitch control and its own volume level.

Parameters
[in]pitchPitch of sound (1.0 is normal pitch).
[in]volumeVolume of sound (100 is full volume).

◆ Sound_SetPaused()

void Sound_SetPaused ( Sound sound,
bool  pause 
)

Pauses the playback of the sound.

This function pauses the sound if it is playing

◆ Sound_Stop()

void Sound_Stop ( Sound sound)

Stops the playback of the sound.

This function stops the sound if it is playing