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 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.
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.
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
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 int 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);
56 * MIDI router rule type.
61 FLUID_MIDI_ROUTER_RULE_NOTE, /**< MIDI note rule */
62 FLUID_MIDI_ROUTER_RULE_CC, /**< MIDI controller rule */
63 FLUID_MIDI_ROUTER_RULE_PROG_CHANGE, /**< MIDI program change rule */
64 FLUID_MIDI_ROUTER_RULE_PITCH_BEND, /**< MIDI pitch bend rule */
65 FLUID_MIDI_ROUTER_RULE_CHANNEL_PRESSURE, /**< MIDI channel pressure rule */
66 FLUID_MIDI_ROUTER_RULE_KEY_PRESSURE, /**< MIDI key pressure rule */
67 FLUID_MIDI_ROUTER_RULE_COUNT /**< Total count of rule types */
68 } fluid_midi_router_rule_type;
71 * Generic callback function for MIDI events.
72 * @param data User defined data pointer
73 * @param event The MIDI event
74 * @return Should return #FLUID_OK on success, #FLUID_FAILED otherwise
76 * Will be used between
77 * - MIDI driver and MIDI router
78 * - MIDI router and synth
79 * to communicate events.
80 * In the not-so-far future...
82 typedef int (*handle_midi_event_func_t)(void* data, fluid_midi_event_t* event);
84 FLUIDSYNTH_API fluid_midi_router_t* new_fluid_midi_router(fluid_settings_t* settings,
85 handle_midi_event_func_t handler,
86 void* event_handler_data);
87 FLUIDSYNTH_API int delete_fluid_midi_router(fluid_midi_router_t* handler);
88 FLUIDSYNTH_API int fluid_midi_router_set_default_rules (fluid_midi_router_t *router);
89 FLUIDSYNTH_API int fluid_midi_router_clear_rules (fluid_midi_router_t *router);
90 FLUIDSYNTH_API int fluid_midi_router_add_rule (fluid_midi_router_t *router,
91 fluid_midi_router_rule_t *rule, int type);
92 FLUIDSYNTH_API fluid_midi_router_rule_t *new_fluid_midi_router_rule (void);
93 FLUIDSYNTH_API void delete_fluid_midi_router_rule (fluid_midi_router_rule_t *rule);
94 FLUIDSYNTH_API void fluid_midi_router_rule_set_chan (fluid_midi_router_rule_t *rule,
95 int min, int max, float mul, int add);
96 FLUIDSYNTH_API void fluid_midi_router_rule_set_param1 (fluid_midi_router_rule_t *rule,
97 int min, int max, float mul, int add);
98 FLUIDSYNTH_API void fluid_midi_router_rule_set_param2 (fluid_midi_router_rule_t *rule,
99 int min, int max, float mul, int add);
100 FLUIDSYNTH_API int fluid_midi_router_handle_midi_event(void* data, fluid_midi_event_t* event);
101 FLUIDSYNTH_API int fluid_midi_dump_prerouter(void* data, fluid_midi_event_t* event);
102 FLUIDSYNTH_API int fluid_midi_dump_postrouter(void* data, fluid_midi_event_t* event);
106 fluid_midi_driver_t* new_fluid_midi_driver(fluid_settings_t* settings,
107 handle_midi_event_func_t handler,
108 void* event_handler_data);
110 FLUIDSYNTH_API void delete_fluid_midi_driver(fluid_midi_driver_t* driver);
114 * MIDI player status enum.
117 enum fluid_player_status
119 FLUID_PLAYER_READY, /**< Player is ready */
120 FLUID_PLAYER_PLAYING, /**< Player is currently playing */
121 FLUID_PLAYER_DONE /**< Player is finished playing */
124 FLUIDSYNTH_API fluid_player_t* new_fluid_player(fluid_synth_t* synth);
125 FLUIDSYNTH_API int delete_fluid_player(fluid_player_t* player);
126 FLUIDSYNTH_API int fluid_player_add(fluid_player_t* player, const char *midifile);
127 FLUIDSYNTH_API int fluid_player_add_mem(fluid_player_t* player, const void *buffer, size_t len);
128 FLUIDSYNTH_API int fluid_player_play(fluid_player_t* player);
129 FLUIDSYNTH_API int fluid_player_stop(fluid_player_t* player);
130 FLUIDSYNTH_API int fluid_player_join(fluid_player_t* player);
131 FLUIDSYNTH_API int fluid_player_set_loop(fluid_player_t* player, int loop);
132 FLUIDSYNTH_API int fluid_player_set_midi_tempo(fluid_player_t* player, int tempo);
133 FLUIDSYNTH_API int fluid_player_set_bpm(fluid_player_t* player, int bpm);
134 FLUIDSYNTH_API int fluid_player_get_status(fluid_player_t* player);
135 FLUIDSYNTH_API int fluid_player_set_playback_callback(fluid_player_t* player, handle_midi_event_func_t handler, void* handler_data);
141 #endif /* _FLUIDSYNTH_MIDI_H */