b154304515750aa091af3bae851198d41d943205
[ardour.git] / libs / fluidsynth / fluidsynth / event.h
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 Library General Public License
7  * as published by the Free Software Foundation; either version 2 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  * Library General Public License for more details.
14  *  
15  * You should have received a copy of the GNU Library 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 #ifndef _FLUIDSYNTH_EVENT_H
22 #define _FLUIDSYNTH_EVENT_H
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /**
29  * @file event.h
30  * @brief Sequencer event functions and defines.
31  *
32  * Functions and constants for creating/processing sequencer events.
33  */
34
35 /**
36  * Sequencer event type enumeration.
37  */
38 enum fluid_seq_event_type {
39   FLUID_SEQ_NOTE = 0,           /**< Note event with duration */
40   FLUID_SEQ_NOTEON,             /**< Note on event */
41   FLUID_SEQ_NOTEOFF,            /**< Note off event */
42   FLUID_SEQ_ALLSOUNDSOFF,       /**< All sounds off event */
43   FLUID_SEQ_ALLNOTESOFF,        /**< All notes off event */
44   FLUID_SEQ_BANKSELECT,         /**< Bank select message */
45   FLUID_SEQ_PROGRAMCHANGE,      /**< Program change message */
46   FLUID_SEQ_PROGRAMSELECT,      /**< Program select message (DOCME) */
47   FLUID_SEQ_PITCHBEND,          /**< Pitch bend message */
48   FLUID_SEQ_PITCHWHEELSENS,     /**< Pitch wheel sensitivity set message @since 1.1.0 was mispelled previously */
49   FLUID_SEQ_MODULATION,         /**< Modulation controller event */
50   FLUID_SEQ_SUSTAIN,            /**< Sustain controller event */
51   FLUID_SEQ_CONTROLCHANGE,      /**< MIDI control change event */
52   FLUID_SEQ_PAN,                /**< Stereo pan set event */
53   FLUID_SEQ_VOLUME,             /**< Volume set event */
54   FLUID_SEQ_REVERBSEND,         /**< Reverb send set event */
55   FLUID_SEQ_CHORUSSEND,         /**< Chorus send set event */
56   FLUID_SEQ_TIMER,              /**< Timer event (DOCME) */
57   FLUID_SEQ_ANYCONTROLCHANGE,   /**< DOCME (used for remove_events only) */
58   FLUID_SEQ_CHANNELPRESSURE,    /**< Channel aftertouch event @since 1.1.0 */
59   FLUID_SEQ_SYSTEMRESET,        /**< System reset event @since 1.1.0 */
60   FLUID_SEQ_UNREGISTERING,      /**< Called when a sequencer client is being unregistered. @since 1.1.0 */
61   FLUID_SEQ_LASTEVENT           /**< Defines the count of event enums */
62 };
63
64 #define FLUID_SEQ_PITCHWHHELSENS        FLUID_SEQ_PITCHWHEELSENS        /**< Old deprecated misspelling of #FLUID_SEQ_PITCHWHEELSENS */
65
66 /* Event alloc/free */
67 FLUIDSYNTH_API fluid_event_t* new_fluid_event(void);
68 FLUIDSYNTH_API void delete_fluid_event(fluid_event_t* evt);
69
70 /* Initializing events */
71 FLUIDSYNTH_API void fluid_event_set_source(fluid_event_t* evt, short src);
72 FLUIDSYNTH_API void fluid_event_set_dest(fluid_event_t* evt, short dest);
73
74 /* Timer events */
75 FLUIDSYNTH_API void fluid_event_timer(fluid_event_t* evt, void* data);
76
77 /* Note events */
78 FLUIDSYNTH_API void fluid_event_note(fluid_event_t* evt, int channel, 
79                                    short key, short vel, 
80                                    unsigned int duration);
81
82 FLUIDSYNTH_API void fluid_event_noteon(fluid_event_t* evt, int channel, short key, short vel);
83 FLUIDSYNTH_API void fluid_event_noteoff(fluid_event_t* evt, int channel, short key);
84 FLUIDSYNTH_API void fluid_event_all_sounds_off(fluid_event_t* evt, int channel);
85 FLUIDSYNTH_API void fluid_event_all_notes_off(fluid_event_t* evt, int channel);
86
87 /* Instrument selection */
88 FLUIDSYNTH_API void fluid_event_bank_select(fluid_event_t* evt, int channel, short bank_num);
89 FLUIDSYNTH_API void fluid_event_program_change(fluid_event_t* evt, int channel, short preset_num);
90 FLUIDSYNTH_API void fluid_event_program_select(fluid_event_t* evt, int channel, unsigned int sfont_id, short bank_num, short preset_num);
91
92 /* Real-time generic instrument controllers */
93 FLUIDSYNTH_API 
94 void fluid_event_control_change(fluid_event_t* evt, int channel, short control, short val);
95
96 /* Real-time instrument controllers shortcuts */
97 FLUIDSYNTH_API void fluid_event_pitch_bend(fluid_event_t* evt, int channel, int val);
98 FLUIDSYNTH_API void fluid_event_pitch_wheelsens(fluid_event_t* evt, int channel, short val);
99 FLUIDSYNTH_API void fluid_event_modulation(fluid_event_t* evt, int channel, short val);
100 FLUIDSYNTH_API void fluid_event_sustain(fluid_event_t* evt, int channel, short val);
101 FLUIDSYNTH_API void fluid_event_pan(fluid_event_t* evt, int channel, short val);
102 FLUIDSYNTH_API void fluid_event_volume(fluid_event_t* evt, int channel, short val);
103 FLUIDSYNTH_API void fluid_event_reverb_send(fluid_event_t* evt, int channel, short val);
104 FLUIDSYNTH_API void fluid_event_chorus_send(fluid_event_t* evt, int channel, short val);
105
106 FLUIDSYNTH_API void fluid_event_channel_pressure(fluid_event_t* evt, int channel, short val);
107 FLUIDSYNTH_API void fluid_event_system_reset(fluid_event_t* evt);
108
109
110 /* Only for removing events */
111 FLUIDSYNTH_API void fluid_event_any_control_change(fluid_event_t* evt, int channel);
112
113 /* Only when unregistering clients */
114 FLUIDSYNTH_API void fluid_event_unregistering(fluid_event_t* evt);
115
116 /* Accessing event data */
117 FLUIDSYNTH_API int fluid_event_get_type(fluid_event_t* evt);
118 FLUIDSYNTH_API short fluid_event_get_source(fluid_event_t* evt);
119 FLUIDSYNTH_API short fluid_event_get_dest(fluid_event_t* evt);
120 FLUIDSYNTH_API int fluid_event_get_channel(fluid_event_t* evt);
121 FLUIDSYNTH_API short fluid_event_get_key(fluid_event_t* evt);
122 FLUIDSYNTH_API short fluid_event_get_velocity(fluid_event_t* evt);
123 FLUIDSYNTH_API short fluid_event_get_control(fluid_event_t* evt);
124 FLUIDSYNTH_API short fluid_event_get_value(fluid_event_t* evt);
125 FLUIDSYNTH_API short fluid_event_get_program(fluid_event_t* evt);
126 FLUIDSYNTH_API void* fluid_event_get_data(fluid_event_t* evt);
127 FLUIDSYNTH_API unsigned int fluid_event_get_duration(fluid_event_t* evt);
128 FLUIDSYNTH_API short fluid_event_get_bank(fluid_event_t* evt);
129 FLUIDSYNTH_API int fluid_event_get_pitch(fluid_event_t* evt);
130 FLUIDSYNTH_API unsigned int fluid_event_get_sfont_id(fluid_event_t* evt);
131
132 #ifdef __cplusplus
133 }
134 #endif
135 #endif /* _FLUIDSYNTH_EVENT_H */