Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/fluidsynth/src/rvoice/fluid_rvoice_event.h
4396 views
1
/* FluidSynth - A Software Synthesizer
2
*
3
* Copyright (C) 2003 Peter Hanappe and others.
4
*
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public License
7
* as published by the Free Software Foundation; either version 2.1 of
8
* the License, or (at your option) any later version.
9
*
10
* This library is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
14
*
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free
17
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
* 02110-1301, USA
19
*/
20
21
22
#ifndef _FLUID_RVOICE_EVENT_H
23
#define _FLUID_RVOICE_EVENT_H
24
25
#include "fluidsynth_priv.h"
26
#include "fluid_rvoice_mixer.h"
27
#include "fluid_ringbuffer.h"
28
29
typedef struct _fluid_rvoice_event_t fluid_rvoice_event_t;
30
31
struct _fluid_rvoice_event_t
32
{
33
fluid_rvoice_function_t method;
34
void *object;
35
fluid_rvoice_param_t param[MAX_EVENT_PARAMS];
36
};
37
38
/*
39
* Bridge between the renderer thread and the midi state thread.
40
* fluid_rvoice_eventhandler_fetch_all() can be called in parallel
41
* with fluid_rvoice_eventhandler_push/flush()
42
*/
43
struct _fluid_rvoice_eventhandler_t
44
{
45
fluid_ringbuffer_t *queue; /**< List of fluid_rvoice_event_t */
46
fluid_atomic_int_t queue_stored; /**< Extras pushed but not flushed */
47
fluid_ringbuffer_t *finished_voices; /**< return queue from handler, list of fluid_rvoice_t* */
48
fluid_rvoice_mixer_t *mixer;
49
};
50
51
fluid_rvoice_eventhandler_t *new_fluid_rvoice_eventhandler(
52
int queuesize, int finished_voices_size, int bufs,
53
int fx_bufs, int fx_units, fluid_real_t sample_rate_max, fluid_real_t sample_rate, int, int);
54
55
void delete_fluid_rvoice_eventhandler(fluid_rvoice_eventhandler_t *);
56
57
int fluid_rvoice_eventhandler_dispatch_all(fluid_rvoice_eventhandler_t *);
58
int fluid_rvoice_eventhandler_dispatch_count(fluid_rvoice_eventhandler_t *);
59
void fluid_rvoice_eventhandler_finished_voice_callback(fluid_rvoice_eventhandler_t *eventhandler,
60
fluid_rvoice_t *rvoice);
61
62
static FLUID_INLINE void
63
fluid_rvoice_eventhandler_flush(fluid_rvoice_eventhandler_t *handler)
64
{
65
int queue_stored = fluid_atomic_int_get(&handler->queue_stored);
66
67
if(queue_stored > 0)
68
{
69
fluid_atomic_int_set(&handler->queue_stored, 0);
70
fluid_ringbuffer_next_inptr(handler->queue, queue_stored);
71
}
72
}
73
74
/**
75
* @return next finished voice, or NULL if nothing in queue
76
*/
77
static FLUID_INLINE fluid_rvoice_t *
78
fluid_rvoice_eventhandler_get_finished_voice(fluid_rvoice_eventhandler_t *handler)
79
{
80
void *result = fluid_ringbuffer_get_outptr(handler->finished_voices);
81
82
if(result == NULL)
83
{
84
return NULL;
85
}
86
87
result = * (fluid_rvoice_t **) result;
88
fluid_ringbuffer_next_outptr(handler->finished_voices);
89
return result;
90
}
91
92
93
int fluid_rvoice_eventhandler_push_int_real(fluid_rvoice_eventhandler_t *handler,
94
fluid_rvoice_function_t method, void *object, int intparam,
95
fluid_real_t realparam);
96
97
int fluid_rvoice_eventhandler_push_ptr(fluid_rvoice_eventhandler_t *handler,
98
fluid_rvoice_function_t method, void *object, void *ptr);
99
100
int fluid_rvoice_eventhandler_push(fluid_rvoice_eventhandler_t *handler,
101
fluid_rvoice_function_t method, void *object,
102
fluid_rvoice_param_t param[MAX_EVENT_PARAMS]);
103
104
static FLUID_INLINE void
105
fluid_rvoice_eventhandler_add_rvoice(fluid_rvoice_eventhandler_t *handler,
106
fluid_rvoice_t *rvoice)
107
{
108
fluid_rvoice_eventhandler_push_ptr(handler, fluid_rvoice_mixer_add_voice,
109
handler->mixer, rvoice);
110
}
111
112
113
114
#endif
115
116