townengine/include/twn_audio.h

47 lines
1.3 KiB
C
Raw Normal View History

#ifndef TWN_AUDIO_H
#define TWN_AUDIO_H
2024-07-08 06:46:12 +00:00
#include "twn_engine_api.h"
2024-10-07 12:21:44 +00:00
#include "twn_option.h"
2024-07-08 06:46:12 +00:00
#include <stdbool.h>
2024-10-07 12:21:44 +00:00
/* plays audio file at specified channel or at scratch channel if NULL is passed, without ability to refer to it later */
/* path path must contain valid file extension to infer which file format it is */
/* supported formats: .ogg, .xm */
TWN_API void audio_play(const char *path,
const char *channel, /* optional */
bool repeat, /* default: false */
float volume, /* default: 1.0f, range: 0.0f to 1.0f */
float panning); /* default: 0.0f, range: -1.0 to 1.0f */
2024-07-08 06:46:12 +00:00
2024-10-07 12:21:44 +00:00
typedef enum {
AUDIO_PARAM_REPEAT,
AUDIO_PARAM_VOLUME,
AUDIO_PARAM_PANNING,
} AudioParam;
2024-07-08 06:46:12 +00:00
2024-10-07 12:21:44 +00:00
TWN_API void audio_set(const char *channel, AudioParam param, float value);
2024-07-08 06:46:12 +00:00
2024-10-07 12:21:44 +00:00
/* TODO */
// TWN_API bool audio_ended(const char *channel);
2024-07-08 06:46:12 +00:00
2024-10-07 12:21:44 +00:00
#ifndef TWN_NOT_C
2024-07-08 06:46:12 +00:00
2024-10-07 12:21:44 +00:00
typedef struct PlayAudioArgs {
char *path;
2024-07-08 06:46:12 +00:00
2024-10-07 12:21:44 +00:00
m_option_list(
char *, channel,
bool, repeat,
float, volume,
float, panning )
} PlayAudioArgs;
TWN_API void audio_play_args(PlayAudioArgs args);
#define m_audio(...) (audio_play_args((PlayAudioArgs){__VA_ARGS__}))
#endif
2024-07-08 06:46:12 +00:00
#endif