2024-09-16 06:07:01 +00:00
|
|
|
#ifndef TWN_AUDIO_H
|
|
|
|
#define TWN_AUDIO_H
|
2024-07-08 06:46:12 +00:00
|
|
|
|
2024-08-26 21:33:37 +00:00
|
|
|
#include "twn_engine_api.h"
|
|
|
|
|
2024-07-08 06:46:12 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
|
2024-09-23 17:43:16 +00:00
|
|
|
typedef struct PlayAudioArgs {
|
2024-07-08 06:46:12 +00:00
|
|
|
/* default: false */
|
|
|
|
bool repeat;
|
|
|
|
/* crossfade between already playing audio on a given channel, if any */
|
|
|
|
/* default: false */
|
|
|
|
bool crossfade;
|
|
|
|
/* range: 0.0f to 1.0f */
|
2024-07-29 22:31:05 +00:00
|
|
|
/* default: 1.0f */
|
2024-07-08 06:46:12 +00:00
|
|
|
float volume;
|
|
|
|
/* range: -1.0 to 1.0f */
|
|
|
|
/* default: 0.0f */
|
|
|
|
float panning;
|
2024-09-23 17:43:16 +00:00
|
|
|
} PlayAudioArgs;
|
2024-07-08 06:46:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* plays audio file at specified channel or anywhere if NULL is passed */
|
|
|
|
/* path must contain valid file extension to infer which file format it is */
|
|
|
|
/* supported formats: .ogg, .xm */
|
|
|
|
/* preserves args that are already specified on the channel */
|
2024-09-23 17:43:16 +00:00
|
|
|
TWN_API void audio_play(const char *path, const char *channel);
|
2024-07-08 06:46:12 +00:00
|
|
|
|
2024-09-23 17:43:16 +00:00
|
|
|
TWN_API void audio_play_ex(const char *path, const char *channel, PlayAudioArgs args);
|
2024-07-08 06:46:12 +00:00
|
|
|
|
2024-07-08 15:13:33 +00:00
|
|
|
/* could be used for modifying args */
|
|
|
|
/* warn: is only valid if no other calls to audio are made */
|
2024-09-23 17:43:16 +00:00
|
|
|
TWN_API PlayAudioArgs *audio_get_args(const char *channel);
|
2024-07-08 06:46:12 +00:00
|
|
|
|
2024-09-23 17:43:16 +00:00
|
|
|
TWN_API PlayAudioArgs audio_get_default_args(void);
|
2024-07-08 06:46:12 +00:00
|
|
|
|
|
|
|
#endif
|