-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8894e94
commit a0624b3
Showing
19 changed files
with
172 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,93 @@ | ||
#ifndef AUDIO_H | ||
#define AUDIO_H | ||
|
||
#include "audio/music.h" | ||
#include "audio/sink.h" | ||
#include "audio/sound.h" | ||
#include "audio/source.h" | ||
#include "audio/sources/dumb_source.h" | ||
#include "audio/sources/vorbis_source.h" | ||
#include "audio/stream.h" | ||
|
||
int audio_is_sink_available(const char *sink_name); | ||
const char *audio_get_first_sink_name(); | ||
int audio_init(const char *sink_name); | ||
void audio_render(); | ||
#include <stdbool.h> | ||
|
||
#include "resources/ids.h" | ||
|
||
#define VOLUME_DEFAULT 1.0f | ||
#define PANNING_DEFAULT 0.0f | ||
#define PITCH_DEFAULT 1.0f | ||
|
||
#define VOLUME_MAX 1.0f | ||
#define PANNING_MAX 1.0f | ||
#define PITCH_MAX 2.0f | ||
|
||
#define VOLUME_MIN 0.0f | ||
#define PANNING_MIN -1.0f | ||
#define PITCH_MIN 0.5f | ||
|
||
typedef struct audio_mod_resampler { | ||
int internal_id; | ||
int is_default; | ||
const char *name; | ||
} audio_mod_resampler; | ||
|
||
typedef struct audio_freq { | ||
int freq; | ||
int is_default; | ||
const char *name; | ||
} audio_freq; | ||
|
||
/** | ||
* Initializes the audio subsystem | ||
* | ||
* @param freq Wanted output frequency (48000 should be fine) | ||
* @param mono True if 1 channel, False for 2. | ||
* @param resampler Music module resampler interpolation | ||
* @param music_volume Initial music volume | ||
* @param sound_volume Initial audio volume | ||
* @return True if initialized, false if not. | ||
*/ | ||
bool audio_init(int freq, bool mono, int resampler, float music_volume, float sound_volume); | ||
|
||
/** | ||
* Closes the audio subsystem. | ||
*/ | ||
void audio_close(); | ||
|
||
audio_sink *audio_get_sink(); | ||
/** | ||
* Plays sound with given parameters. | ||
* | ||
* @param id Sound resource identifier | ||
* @param volume Volume 0.0f ... 1.0f | ||
* @param panning Sound panning -1.0f ... 1.0f | ||
* @param pitch Sound pitch 0.0f ... n | ||
*/ | ||
void audio_play_sound(int id, float volume, float panning, float pitch); | ||
|
||
/** | ||
* Starts background music playback. If there is something already playing, | ||
* switches to new track. | ||
* @param id Music file resource identifier. | ||
*/ | ||
void audio_play_music(resource_id id); | ||
|
||
/** | ||
* Stops music playback. | ||
*/ | ||
void audio_stop_music(); | ||
|
||
/** | ||
* Set music volume | ||
* @param volume 0.0f ... 1.0f | ||
*/ | ||
void audio_set_music_volume(float volume); | ||
|
||
/** | ||
* Set sound volume 0.0f ... 1.0f | ||
* @param volume | ||
*/ | ||
void audio_set_sound_volume(float volume); | ||
|
||
/** | ||
* Get supported audio frequencies list | ||
*/ | ||
const audio_freq *audio_get_freqs(); | ||
|
||
/** | ||
* Get supported music resamplers list | ||
*/ | ||
const audio_mod_resampler *audio_get_resamplers(); | ||
|
||
#endif // AUDIO_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.