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 #ifndef _FLUIDSYNTH_EVENT_H
22 #define _FLUIDSYNTH_EVENT_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /**
29  * @defgroup sequencer_events Sequencer Events
30  * @ingroup sequencer
31  *
32  * Create, modify, query and destroy sequencer events.
33  *
34  * @{
35  */
36 
37 /**
38  * Sequencer event type enumeration.
39  */
40 enum fluid_seq_event_type
41 {
42     FLUID_SEQ_NOTE = 0,		/**< Note event with duration */
43     FLUID_SEQ_NOTEON,		/**< Note on event */
44     FLUID_SEQ_NOTEOFF,		/**< Note off event */
45     FLUID_SEQ_ALLSOUNDSOFF,	/**< All sounds off event */
46     FLUID_SEQ_ALLNOTESOFF,	/**< All notes off event */
47     FLUID_SEQ_BANKSELECT,		/**< Bank select message */
48     FLUID_SEQ_PROGRAMCHANGE,	/**< Program change message */
49     FLUID_SEQ_PROGRAMSELECT,	/**< Program select message */
50     FLUID_SEQ_PITCHBEND,		/**< Pitch bend message */
51     FLUID_SEQ_PITCHWHEELSENS,	/**< Pitch wheel sensitivity set message @since 1.1.0 was misspelled previously */
52     FLUID_SEQ_MODULATION,		/**< Modulation controller event */
53     FLUID_SEQ_SUSTAIN,		/**< Sustain controller event */
54     FLUID_SEQ_CONTROLCHANGE,	/**< MIDI control change event */
55     FLUID_SEQ_PAN,		/**< Stereo pan set event */
56     FLUID_SEQ_VOLUME,		/**< Volume set event */
57     FLUID_SEQ_REVERBSEND,		/**< Reverb send set event */
58     FLUID_SEQ_CHORUSSEND,		/**< Chorus send set event */
59     FLUID_SEQ_TIMER,		/**< Timer event (useful for giving a callback at a certain time) */
60     FLUID_SEQ_CHANNELPRESSURE,    /**< Channel aftertouch event @since 1.1.0 */
61     FLUID_SEQ_KEYPRESSURE,        /**< Polyphonic aftertouch event @since 2.0.0 */
62     FLUID_SEQ_SYSTEMRESET,        /**< System reset event @since 1.1.0 */
63     FLUID_SEQ_UNREGISTERING,      /**< Called when a sequencer client is being unregistered. @since 1.1.0 */
64     FLUID_SEQ_SCALE,              /**< Sets a new time scale for the sequencer @since 2.2.0 */
65     FLUID_SEQ_LASTEVENT		/**< @internal Defines the count of events enums @warning This symbol
66                               is not part of the public API and ABI stability guarantee and
67                               may change at any time! */
68 };
69 
70 /* Event alloc/free */
71 /** @startlifecycle{Sequencer Event} */
72 FLUIDSYNTH_API fluid_event_t *new_fluid_event(void);
73 FLUIDSYNTH_API void delete_fluid_event(fluid_event_t *evt);
74 /** @endlifecycle */
75 
76 /* Initializing events */
77 FLUIDSYNTH_API void fluid_event_set_source(fluid_event_t *evt, fluid_seq_id_t src);
78 FLUIDSYNTH_API void fluid_event_set_dest(fluid_event_t *evt, fluid_seq_id_t dest);
79 
80 /* Timer events */
81 FLUIDSYNTH_API void fluid_event_timer(fluid_event_t *evt, void *data);
82 
83 /* Note events */
84 FLUIDSYNTH_API void fluid_event_note(fluid_event_t *evt, int channel,
85                                      short key, short vel,
86                                      unsigned int duration);
87 
88 FLUIDSYNTH_API void fluid_event_noteon(fluid_event_t *evt, int channel, short key, short vel);
89 FLUIDSYNTH_API void fluid_event_noteoff(fluid_event_t *evt, int channel, short key);
90 FLUIDSYNTH_API void fluid_event_all_sounds_off(fluid_event_t *evt, int channel);
91 FLUIDSYNTH_API void fluid_event_all_notes_off(fluid_event_t *evt, int channel);
92 
93 /* Instrument selection */
94 FLUIDSYNTH_API void fluid_event_bank_select(fluid_event_t *evt, int channel, short bank_num);
95 FLUIDSYNTH_API void fluid_event_program_change(fluid_event_t *evt, int channel, int preset_num);
96 FLUIDSYNTH_API void fluid_event_program_select(fluid_event_t *evt, int channel, unsigned int sfont_id, short bank_num, short preset_num);
97 
98 /* Real-time generic instrument controllers */
99 FLUIDSYNTH_API
100 void fluid_event_control_change(fluid_event_t *evt, int channel, short control, int val);
101 
102 /* Real-time instrument controllers shortcuts */
103 FLUIDSYNTH_API void fluid_event_pitch_bend(fluid_event_t *evt, int channel, int val);
104 FLUIDSYNTH_API void fluid_event_pitch_wheelsens(fluid_event_t *evt, int channel, int val);
105 FLUIDSYNTH_API void fluid_event_modulation(fluid_event_t *evt, int channel, int val);
106 FLUIDSYNTH_API void fluid_event_sustain(fluid_event_t *evt, int channel, int val);
107 FLUIDSYNTH_API void fluid_event_pan(fluid_event_t *evt, int channel, int val);
108 FLUIDSYNTH_API void fluid_event_volume(fluid_event_t *evt, int channel, int val);
109 FLUIDSYNTH_API void fluid_event_reverb_send(fluid_event_t *evt, int channel, int val);
110 FLUIDSYNTH_API void fluid_event_chorus_send(fluid_event_t *evt, int channel, int val);
111 
112 FLUIDSYNTH_API void fluid_event_key_pressure(fluid_event_t *evt, int channel, short key, int val);
113 FLUIDSYNTH_API void fluid_event_channel_pressure(fluid_event_t *evt, int channel, int val);
114 FLUIDSYNTH_API void fluid_event_system_reset(fluid_event_t *evt);
115 
116 /* Only when unregistering clients */
117 FLUIDSYNTH_API void fluid_event_unregistering(fluid_event_t *evt);
118 
119 FLUIDSYNTH_API void fluid_event_scale(fluid_event_t *evt, double new_scale);
120 
121 /* Accessing event data */
122 FLUIDSYNTH_API int fluid_event_get_type(fluid_event_t *evt);
123 FLUIDSYNTH_API fluid_seq_id_t fluid_event_get_source(fluid_event_t *evt);
124 FLUIDSYNTH_API fluid_seq_id_t fluid_event_get_dest(fluid_event_t *evt);
125 FLUIDSYNTH_API int fluid_event_get_channel(fluid_event_t *evt);
126 FLUIDSYNTH_API short fluid_event_get_key(fluid_event_t *evt);
127 FLUIDSYNTH_API short fluid_event_get_velocity(fluid_event_t *evt);
128 FLUIDSYNTH_API short fluid_event_get_control(fluid_event_t *evt);
129 FLUIDSYNTH_API int fluid_event_get_value(fluid_event_t *evt);
130 FLUIDSYNTH_API int fluid_event_get_program(fluid_event_t *evt);
131 FLUIDSYNTH_API void *fluid_event_get_data(fluid_event_t *evt);
132 FLUIDSYNTH_API unsigned int fluid_event_get_duration(fluid_event_t *evt);
133 FLUIDSYNTH_API short fluid_event_get_bank(fluid_event_t *evt);
134 FLUIDSYNTH_API int fluid_event_get_pitch(fluid_event_t *evt);
135 FLUIDSYNTH_API double fluid_event_get_scale(fluid_event_t *evt);
136 FLUIDSYNTH_API unsigned int fluid_event_get_sfont_id(fluid_event_t *evt);
137 /* @} */
138 
139 #ifdef __cplusplus
140 }
141 #endif
142 #endif /* _FLUIDSYNTH_EVENT_H */
143