43 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| #ifndef TWN_AUDIO_H
 | |
| #define TWN_AUDIO_H
 | |
| 
 | |
| #include "twn_engine_api.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 *audio,
 | |
|                         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 */
 | |
| 
 | |
| /* possible parameter options: "volume", "panning", "repeat" */
 | |
| TWN_API void audio_parameter(const char *channel, const char *parameter, float value);
 | |
| 
 | |
| /* TODO */
 | |
| // TWN_API bool audio_ended(const char *channel);
 | |
| 
 | |
| #ifndef TWN_NOT_C
 | |
| 
 | |
| #include "src/twn_option_c.h"
 | |
| 
 | |
| 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
 |