summaryrefslogtreecommitdiffstats
path: root/include/xas/seq.h
blob: 124af96abf2be7002fd166a76be6e73637e524d8 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#ifndef _XAS_SEQ_H
#define _XAS_SEQ_H

#include <sys/types.h>
#include <sys/time.h>

#include <xas/audio.h>
#include <xas/synth.h>
#include <xas/spatial.h>

enum xas_seq_event_type {
    XAS_SEQ_EVENT_SET_POSITION,
    XAS_SEQ_EVENT_SET_HEADING,
    XAS_SEQ_EVENT_SET_SPEED,
    XAS_SEQ_EVENT_SET_GAIN,
    XAS_SEQ_EVENT_SET_FREQUENCY,
    XAS_SEQ_EVENT_SET_TYPE,
    XAS_SEQ_EVENT_SET_ENTRY,
    XAS_SEQ_EVENT_SET_FLAGS,
    XAS_SEQ_EVENT_SPEECH,
    XAS_SEQ_EVENT_OFF,
    XAS_SEQ_EVENT_ON,
    XAS_SEQ_EVENT_STOP
};

typedef struct _xas_seq_event xas_seq_event;

struct _xas_seq_event {
    enum xas_seq_event_type type;

    xas_object *object;

    struct timeval timestamp;
    size_t index;

    union {
        xas_spatial_coord point;
        xas_spatial_coord heading;
        float speed;
        float gain;
        int flags;
        int value;
        size_t entry;
        size_t frequency;
        const char *phrase;
    };

    xas_seq_event *next;
};

typedef struct _xas_seq {
    xas_spatial_scene *scene;

    xas_seq_event *first,
                    *last;

    size_t buffer_size;
} xas_seq;

xas_seq *xas_seq_new(xas_spatial_scene *scene, size_t buffer_size);

void xas_seq_destroy(xas_seq *seq);

int xas_seq_add_event_off(xas_seq *seq,
                            xas_object *object,
                            struct timeval timestamp,
                            size_t index);

int xas_seq_add_event_on(xas_seq *seq,
                           xas_object *object,
                           struct timeval timestamp,
                           size_t index);

int xas_seq_add_set_position(xas_seq *seq,
                               xas_object *object,
                               struct timeval timestamp,
                               xas_spatial_coord point);

int xas_seq_add_set_heading(xas_seq *seq,
                              xas_object *object,
                              struct timeval timestamp,
                              xas_spatial_coord heading);

int xas_seq_add_set_speed(xas_seq *seq,
                            xas_object *object,
                            struct timeval timestamp,
                            float speed);

int xas_seq_add_set_type(xas_seq *seq,
                           xas_object *object,
                           struct timeval timestamp,
                           size_t index,
                           int type);

int xas_seq_add_set_gain(xas_seq *seq,
                           xas_object *object,
                           struct timeval timestamp,
                           float gain);

int xas_seq_add_set_entry(xas_seq *seq,
                            xas_object *object,
                            struct timeval timestamp,
                            size_t index,
                            size_t entry);

int xas_seq_add_set_flags(xas_seq *seq,
                            xas_object *object,
                            struct timeval timestamp,
                            size_t index,
                            int flags);

int xas_seq_add_set_type(xas_seq *seq,
                           xas_object *object,
                           struct timeval timestamp,
                           size_t index,
                           int type);

int xas_seq_add_set_frequency(xas_seq *seq,
                                xas_object *object,
                                struct timeval timestamp,
                                size_t index,
                                size_t frequency);

int xas_seq_add_phrase(xas_seq *seq,
                         xas_object *object,
                         struct timeval timestamp,
                         const char *phrase);

int xas_seq_add_stop(xas_seq *seq,
                       struct timeval timestamp);

int xas_seq_play(xas_seq *seq, xas_audio_stream *sink);

#endif /* _XAS_SEQ_H */