townengine/include/twn_audio.h

47 lines
1.3 KiB
C

#ifndef TWN_AUDIO_H
#define TWN_AUDIO_H
#include "twn_engine_api.h"
#include "twn_option.h"
#include <stdbool.h>
/* 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 */
typedef enum {
AUDIO_PARAM_REPEAT,
AUDIO_PARAM_VOLUME,
AUDIO_PARAM_PANNING,
} AudioParam;
TWN_API void audio_set(const char *channel, AudioParam param, float value);
/* TODO */
// TWN_API bool audio_ended(const char *channel);
#ifndef TWN_NOT_C
typedef struct PlayAudioArgs {
char *path;
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
#endif