Jo Engine  9
Jo Sega Saturn Engine
audio.h
Go to the documentation of this file.
1 /*
2 ** Jo Sega Saturn Engine
3 ** Copyright (c) 2012-2017, Johannes Fetz (johannesfetz@gmail.com)
4 ** All rights reserved.
5 **
6 ** Redistribution and use in source and binary forms, with or without
7 ** modification, are permitted provided that the following conditions are met:
8 ** * Redistributions of source code must retain the above copyright
9 ** notice, this list of conditions and the following disclaimer.
10 ** * Redistributions in binary form must reproduce the above copyright
11 ** notice, this list of conditions and the following disclaimer in the
12 ** documentation and/or other materials provided with the distribution.
13 ** * Neither the name of the Johannes Fetz nor the
14 ** names of its contributors may be used to endorse or promote products
15 ** derived from this software without specific prior written permission.
16 **
17 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 ** DISCLAIMED. IN NO EVENT SHALL Johannes Fetz BE LIABLE FOR ANY
21 ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
35 #ifndef __JO_AUDIO_H__
36 # define __JO_AUDIO_H__
37 
38 #ifdef JO_COMPILE_WITH_AUDIO_SUPPORT
39 
40 # define JO_SOUND_MAX_CHANNEL (6)
41 
42 typedef enum
43 {
44  JoSoundMono8Bit = (0x00 | 0x10),
45  JoSoundMono16Bit = (0x00 | 0x00),
46  JoSoundStereo8Bit = (0x80 | 0x10),
47  JoSoundStereo16Bit = (0x80 | 0x00)
49 
50 typedef struct
51 {
52  char *data;
53  unsigned int data_length;
55  unsigned char current_playing_channel;
56 } jo_sound;
57 
59 # define JO_DEFAULT_AUDIO_VOLUME (127)
60 
61 # define JO_MAX_AUDIO_VOLUME (127)
62 
63 # define JO_MIN_AUDIO_VOLUME (0)
64 
70 void jo_audio_play_cd_track(const int fromTrack, const int totrack, const int loop);
71 
75 void jo_audio_set_volume(const unsigned char vol);
76 
79 void jo_audio_stop_cd(void);
80 
85 void jo_audio_play_sound_on_channel(jo_sound * const sound, const unsigned char channel);
86 
90 void jo_audio_play_sound(jo_sound * const sound);
91 
95 void jo_audio_stop_sound(const jo_sound * const sound);
96 
106 bool jo_audio_load_pcm(const char * const filename, const jo_sound_mode mode, jo_sound *sound);
107 
111 void jo_audio_free_pcm(jo_sound *sound);
112 
117 int jo_audio_usage_percent(void);
118 
119 #endif /* !JO_COMPILE_WITH_AUDIO_SUPPORT */
120 
121 #endif /* !__JO_AUDIO_H__ */
122 
123 /*
124 ** END OF FILE
125 */
jo_sound_mode mode
Definition: audio.h:54
Definition: audio.h:44
Definition: audio.h:45
Definition: audio.h:46
void jo_audio_stop_cd(void)
Stop playing audio track.
void jo_audio_play_cd_track(const int fromTrack, const int totrack, const int loop)
Play a track from the CD.
jo_sound_mode
Definition: audio.h:42
void jo_audio_stop_sound(const jo_sound *const sound)
Stop a sound.
int jo_audio_usage_percent(void)
Get audio channel usage.
Definition: audio.h:47
unsigned int data_length
Definition: audio.h:53
unsigned char current_playing_channel
Definition: audio.h:55
Definition: audio.h:50
char * data
Definition: audio.h:52
bool jo_audio_load_pcm(const char *const filename, const jo_sound_mode mode, jo_sound *sound)
Load PCM file from CD.
void jo_audio_free_pcm(jo_sound *sound)
Free pcm sound loaded with jo_audio_load_pcm()
void jo_audio_play_sound_on_channel(jo_sound *const sound, const unsigned char channel)
Play a sound on a specific channel.
void jo_audio_play_sound(jo_sound *const sound)
Play a sound on first available channel.
void jo_audio_set_volume(const unsigned char vol)
Set the audio volume.