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-10-07 12:21:44 +00:00
|
|
|
#include "twn_option.h"
|
2024-08-26 21:33:37 +00:00
|
|
|
|
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 */
|
2025-01-15 01:15:08 +00:00
|
|
|
TWN_API void audio_play(const char *audio,
|
2024-10-07 12:21:44 +00:00
|
|
|
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-22 10:52:24 +00:00
|
|
|
/* possible parameter options: "volume", "panning", "repeat" */
|
2024-10-29 09:25:24 +00:00
|
|
|
TWN_API void audio_parameter(const char *channel, const char *parameter, 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
|