1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#ifndef MOSSROSE_CHANNEL_H
#define MOSSROSE_CHANNEL_H
#include <stddef.h>
#include <stdbool.h>
#include <plibsys.h>
#include <mossrose.h>
typedef void (*channel_callback_t)(int channel, void *userdata);
struct channel_shared_t {
volatile pint active; /* boolean */
volatile pint paused; /* boolean */
volatile pint volume; /* 0-255 */
volatile pint pan_left; /* -255-255 */
volatile pint pan_right; /* -255-255 */
volatile pint loops;
volatile pint trigger_callback;
};
struct channel_t {
struct channel_shared_t shared;
bool skip;
float gain_ll, gain_lr;
float gain_rl, gain_rr;
PMutex *sound_mutex;
struct mossrose_sound_t sound;
size_t pos;
channel_callback_t callback;
void *userdata;
};
void channel_init(struct channel_t *chan);
void channel_reset(struct channel_t *chan);
void channel_pause(struct channel_t *chan);
void channel_resume(struct channel_t *chan);
void channel_set_volume(struct channel_t *chan, float volume);
void channel_set_pan(struct channel_t *chan, float pan_left, float pan_right);
void channel_set_callback(struct channel_t *chan, channel_callback_t callback, void *userdata);
void channel_poll_callbacks(struct channel_t *chan, int index);
int channel_sound_load(struct channel_t *chan, struct mossrose_sound_t *sound, bool force, int loops);
void channel_update_shared(struct channel_t *chan);
void channel_get_next_sample(float *left, float *right, struct channel_t *chan);
#endif
|