Jo Engine  2024.04.28
Jo Sega Saturn Engine
Data Structures | Macros | Enumerations | Functions
audio.h File Reference

Jo Engine Function prototypes for audio. More...

Go to the source code of this file.

Data Structures

struct  jo_sound
 

Macros

#define JO_SOUND_MAX_CHANNEL
 
#define JO_DEFAULT_AUDIO_VOLUME
 Default audio volume. More...
 
#define JO_MAX_AUDIO_VOLUME
 Max audio volume available for jo_audio_set_volume()
More...
 
#define JO_MIN_AUDIO_VOLUME
 Min audio volume available for jo_audio_set_volume()
More...
 

Enumerations

enum  jo_sound_mode { JoSoundMono8Bit, JoSoundMono16Bit, JoSoundStereo8Bit, JoSoundStereo16Bit }
 

Functions

void jo_audio_play_cd_track (const int from_track, const int to_track, const bool repeat_infinitely)
 Play a track from the CD. More...
 
void jo_audio_set_volume (const unsigned char vol)
 Set the audio volume. More...
 
void jo_audio_stop_cd (void)
 Stop playing audio track. More...
 
void jo_audio_play_sound_on_channel (jo_sound *const sound, const unsigned char channel)
 Play a sound on a specific channel. More...
 
void jo_audio_play_sound (jo_sound *const sound)
 Play a sound on first available channel. More...
 
void jo_audio_stop_sound (const jo_sound *const sound)
 Stop a sound. More...
 
bool jo_audio_load_pcm (const char *const filename, const jo_sound_mode mode, jo_sound *sound)
 Load PCM file from CD. More...
 
bool jo_audio_load_pcm_async (const char *const filename, const jo_sound_mode mode, jo_sound *sound)
 Load PCM file from CD asynchronously. More...
 
void jo_audio_free_pcm (jo_sound *sound)
 Free pcm sound loaded with jo_audio_load_pcm() More...
 
int jo_audio_usage_percent (void)
 Get audio channel usage. More...
 

Detailed Description

Jo Engine Function prototypes for audio.

Author
Johannes Fetz
Bug:
No known bugs.

Data Structure Documentation

◆ jo_sound

struct jo_sound
Data Fields
unsigned char current_playing_channel
char * data
unsigned int data_length
jo_sound_mode mode
char pan
unsigned short sample_rate
unsigned char volume

Macro Definition Documentation

◆ JO_DEFAULT_AUDIO_VOLUME

#define JO_DEFAULT_AUDIO_VOLUME

Default audio volume.

◆ JO_MAX_AUDIO_VOLUME

#define JO_MAX_AUDIO_VOLUME

Max audio volume available for jo_audio_set_volume()

◆ JO_MIN_AUDIO_VOLUME

#define JO_MIN_AUDIO_VOLUME

Min audio volume available for jo_audio_set_volume()

◆ JO_SOUND_MAX_CHANNEL

#define JO_SOUND_MAX_CHANNEL

Enumeration Type Documentation

◆ jo_sound_mode

Enumerator
JoSoundMono8Bit 
JoSoundMono16Bit 
JoSoundStereo8Bit 
JoSoundStereo16Bit 

Function Documentation

◆ jo_audio_free_pcm()

void jo_audio_free_pcm ( jo_sound sound)

Free pcm sound loaded with jo_audio_load_pcm()

Parameters
soundSound definition

◆ jo_audio_load_pcm()

bool jo_audio_load_pcm ( const char *const  filename,
const jo_sound_mode  mode,
jo_sound sound 
)

Load PCM file from CD.

Parameters
filenamePcm filename (example: A.PCM)
modePCM audio mode (JoSoundMono16Bit, etc)
soundSound definition (output)
Remarks
To convert any audio file to PCM under Linux or Windows => http://ffmpeg.org
ffmpeg -i A.WAV -f s8 -ar 44100 A.PCM
ffmpeg -i A.MP3 -f s8 -ac 1 -ar 8000 A.PCM
Returns
true if succeed otherwise false

◆ jo_audio_load_pcm_async()

bool jo_audio_load_pcm_async ( const char *const  filename,
const jo_sound_mode  mode,
jo_sound sound 
)

Load PCM file from CD asynchronously.

Parameters
filenamePcm filename (example: A.PCM)
modePCM audio mode (JoSoundMono16Bit, etc)
soundSound definition (output)
Remarks
To convert any audio file to PCM under Linux or Windows => http://ffmpeg.org
ffmpeg -i A.WAV -f s8 -ar 44100 A.PCM
ffmpeg -i A.MP3 -f s8 -ac 1 -ar 8000 A.PCM
Returns
true if succeed otherwise false

◆ jo_audio_play_cd_track()

void jo_audio_play_cd_track ( const int  from_track,
const int  to_track,
const bool  repeat_infinitely 
)

Play a track from the CD.

Parameters
from_trackFirst track index to play
to_trackLast track index to play
repeat_infinitelyPlay tracks infinitely or not

◆ jo_audio_play_sound()

void jo_audio_play_sound ( jo_sound *const  sound)

Play a sound on first available channel.

Parameters
soundSound definition

◆ jo_audio_play_sound_on_channel()

void jo_audio_play_sound_on_channel ( jo_sound *const  sound,
const unsigned char  channel 
)

Play a sound on a specific channel.

Parameters
soundSound definition
channelChannel (0 to 6)

◆ jo_audio_set_volume()

void jo_audio_set_volume ( const unsigned char  vol)

Set the audio volume.

Parameters
volVolume level from 0 to 127

◆ jo_audio_stop_cd()

void jo_audio_stop_cd ( void  )

Stop playing audio track.

◆ jo_audio_stop_sound()

void jo_audio_stop_sound ( const jo_sound *const  sound)

Stop a sound.

Parameters
soundSound definition

◆ jo_audio_usage_percent()

int jo_audio_usage_percent ( void  )

Get audio channel usage.

Returns
Audio channel usage percent
Remarks
jo_printf(0, 0, "Audio channel usage: %d%% ", jo_audio_usage_percent());