1 /* FluidSynth - A Software Synthesizer
3 * Copyright (C) 2003 Peter Hanappe and others.
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.
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.
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
21 #ifndef _FLUIDSYNTH_MIDI_H
22 #define _FLUIDSYNTH_MIDI_H
30 * @brief Functions for MIDI events, drivers and MIDI file playback.
33 FLUIDSYNTH_API fluid_midi_event_t *new_fluid_midi_event(void);
34 FLUIDSYNTH_API void delete_fluid_midi_event(fluid_midi_event_t *event);
36 FLUIDSYNTH_API int fluid_midi_event_set_type(fluid_midi_event_t *evt, int type);
37 FLUIDSYNTH_API int fluid_midi_event_get_type(fluid_midi_event_t *evt);
38 FLUIDSYNTH_API int fluid_midi_event_set_channel(fluid_midi_event_t *evt, int chan);
39 FLUIDSYNTH_API int fluid_midi_event_get_channel(fluid_midi_event_t *evt);
40 FLUIDSYNTH_API int fluid_midi_event_get_key(fluid_midi_event_t *evt);
41 FLUIDSYNTH_API int fluid_midi_event_set_key(fluid_midi_event_t *evt, int key);
42 FLUIDSYNTH_API int fluid_midi_event_get_velocity(fluid_midi_event_t *evt);
43 FLUIDSYNTH_API int fluid_midi_event_set_velocity(fluid_midi_event_t *evt, int vel);
44 FLUIDSYNTH_API int fluid_midi_event_get_control(fluid_midi_event_t *evt);
45 FLUIDSYNTH_API int fluid_midi_event_set_control(fluid_midi_event_t *evt, int ctrl);
46 FLUIDSYNTH_API int fluid_midi_event_get_value(fluid_midi_event_t *evt);
47 FLUIDSYNTH_API int fluid_midi_event_set_value(fluid_midi_event_t *evt, int val);
48 FLUIDSYNTH_API int fluid_midi_event_get_program(fluid_midi_event_t *evt);
49 FLUIDSYNTH_API int fluid_midi_event_set_program(fluid_midi_event_t *evt, int val);
50 FLUIDSYNTH_API int fluid_midi_event_get_pitch(fluid_midi_event_t *evt);
51 FLUIDSYNTH_API int fluid_midi_event_set_pitch(fluid_midi_event_t *evt, int val);
52 FLUIDSYNTH_API int fluid_midi_event_set_sysex(fluid_midi_event_t *evt, void *data,
53 int size, int dynamic);
54 FLUIDSYNTH_API int fluid_midi_event_set_text(fluid_midi_event_t *evt,
55 void *data, int size, int dynamic);
56 FLUIDSYNTH_API int fluid_midi_event_set_lyrics(fluid_midi_event_t *evt,
57 void *data, int size, int dynamic);
60 * MIDI router rule type.
65 FLUID_MIDI_ROUTER_RULE_NOTE, /**< MIDI note rule */
66 FLUID_MIDI_ROUTER_RULE_CC, /**< MIDI controller rule */
67 FLUID_MIDI_ROUTER_RULE_PROG_CHANGE, /**< MIDI program change rule */
68 FLUID_MIDI_ROUTER_RULE_PITCH_BEND, /**< MIDI pitch bend rule */
69 FLUID_MIDI_ROUTER_RULE_CHANNEL_PRESSURE, /**< MIDI channel pressure rule */
70 FLUID_MIDI_ROUTER_RULE_KEY_PRESSURE, /**< MIDI key pressure rule */
72 FLUID_MIDI_ROUTER_RULE_COUNT /**< @internal Total count of rule types @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time!*/
74 } fluid_midi_router_rule_type;
77 * Generic callback function for MIDI events.
78 * @param data User defined data pointer
79 * @param event The MIDI event
80 * @return Should return #FLUID_OK on success, #FLUID_FAILED otherwise
82 * Will be used between
83 * - MIDI driver and MIDI router
84 * - MIDI router and synth
85 * to communicate events.
86 * In the not-so-far future...
88 typedef int (*handle_midi_event_func_t)(void *data, fluid_midi_event_t *event);
90 FLUIDSYNTH_API fluid_midi_router_t *new_fluid_midi_router(fluid_settings_t *settings,
91 handle_midi_event_func_t handler,
92 void *event_handler_data);
93 FLUIDSYNTH_API void delete_fluid_midi_router(fluid_midi_router_t *handler);
94 FLUIDSYNTH_API int fluid_midi_router_set_default_rules(fluid_midi_router_t *router);
95 FLUIDSYNTH_API int fluid_midi_router_clear_rules(fluid_midi_router_t *router);
96 FLUIDSYNTH_API int fluid_midi_router_add_rule(fluid_midi_router_t *router,
97 fluid_midi_router_rule_t *rule, int type);
98 FLUIDSYNTH_API fluid_midi_router_rule_t *new_fluid_midi_router_rule(void);
99 FLUIDSYNTH_API void delete_fluid_midi_router_rule(fluid_midi_router_rule_t *rule);
100 FLUIDSYNTH_API void fluid_midi_router_rule_set_chan(fluid_midi_router_rule_t *rule,
101 int min, int max, float mul, int add);
102 FLUIDSYNTH_API void fluid_midi_router_rule_set_param1(fluid_midi_router_rule_t *rule,
103 int min, int max, float mul, int add);
104 FLUIDSYNTH_API void fluid_midi_router_rule_set_param2(fluid_midi_router_rule_t *rule,
105 int min, int max, float mul, int add);
106 FLUIDSYNTH_API int fluid_midi_router_handle_midi_event(void *data, fluid_midi_event_t *event);
107 FLUIDSYNTH_API int fluid_midi_dump_prerouter(void *data, fluid_midi_event_t *event);
108 FLUIDSYNTH_API int fluid_midi_dump_postrouter(void *data, fluid_midi_event_t *event);
112 fluid_midi_driver_t *new_fluid_midi_driver(fluid_settings_t *settings,
113 handle_midi_event_func_t handler,
114 void *event_handler_data);
116 FLUIDSYNTH_API void delete_fluid_midi_driver(fluid_midi_driver_t *driver);
120 * MIDI player status enum.
123 enum fluid_player_status
125 FLUID_PLAYER_READY, /**< Player is ready */
126 FLUID_PLAYER_PLAYING, /**< Player is currently playing */
127 FLUID_PLAYER_DONE /**< Player is finished playing */
130 FLUIDSYNTH_API fluid_player_t *new_fluid_player(fluid_synth_t *synth);
131 FLUIDSYNTH_API void delete_fluid_player(fluid_player_t *player);
132 FLUIDSYNTH_API int fluid_player_add(fluid_player_t *player, const char *midifile);
133 FLUIDSYNTH_API int fluid_player_add_mem(fluid_player_t *player, const void *buffer, size_t len);
134 FLUIDSYNTH_API int fluid_player_play(fluid_player_t *player);
135 FLUIDSYNTH_API int fluid_player_stop(fluid_player_t *player);
136 FLUIDSYNTH_API int fluid_player_join(fluid_player_t *player);
137 FLUIDSYNTH_API int fluid_player_set_loop(fluid_player_t *player, int loop);
138 FLUIDSYNTH_API int fluid_player_set_midi_tempo(fluid_player_t *player, int tempo);
139 FLUIDSYNTH_API int fluid_player_set_bpm(fluid_player_t *player, int bpm);
140 FLUIDSYNTH_API int fluid_player_set_playback_callback(fluid_player_t *player, handle_midi_event_func_t handler, void *handler_data);
142 FLUIDSYNTH_API int fluid_player_get_status(fluid_player_t *player);
143 FLUIDSYNTH_API int fluid_player_get_current_tick(fluid_player_t *player);
144 FLUIDSYNTH_API int fluid_player_get_total_ticks(fluid_player_t *player);
145 FLUIDSYNTH_API int fluid_player_get_bpm(fluid_player_t *player);
146 FLUIDSYNTH_API int fluid_player_get_midi_tempo(fluid_player_t *player);
147 FLUIDSYNTH_API int fluid_player_seek(fluid_player_t *player, int ticks);
155 #endif /* _FLUIDSYNTH_MIDI_H */