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_get_text(fluid_midi_event_t
*evt
,
57 void **data
, int *size
);
58 FLUIDSYNTH_API
int fluid_midi_event_set_lyrics(fluid_midi_event_t
*evt
,
59 void *data
, int size
, int dynamic
);
60 FLUIDSYNTH_API
int fluid_midi_event_get_lyrics(fluid_midi_event_t
*evt
,
61 void **data
, int *size
);
64 * MIDI router rule type.
69 FLUID_MIDI_ROUTER_RULE_NOTE
, /**< MIDI note rule */
70 FLUID_MIDI_ROUTER_RULE_CC
, /**< MIDI controller rule */
71 FLUID_MIDI_ROUTER_RULE_PROG_CHANGE
, /**< MIDI program change rule */
72 FLUID_MIDI_ROUTER_RULE_PITCH_BEND
, /**< MIDI pitch bend rule */
73 FLUID_MIDI_ROUTER_RULE_CHANNEL_PRESSURE
, /**< MIDI channel pressure rule */
74 FLUID_MIDI_ROUTER_RULE_KEY_PRESSURE
, /**< MIDI key pressure rule */
76 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!*/
78 } fluid_midi_router_rule_type
;
81 * Generic callback function for MIDI events.
82 * @param data User defined data pointer
83 * @param event The MIDI event
84 * @return Should return #FLUID_OK on success, #FLUID_FAILED otherwise
86 * Will be used between
87 * - MIDI driver and MIDI router
88 * - MIDI router and synth
89 * to communicate events.
90 * In the not-so-far future...
92 typedef int (*handle_midi_event_func_t
)(void *data
, fluid_midi_event_t
*event
);
94 FLUIDSYNTH_API fluid_midi_router_t
*new_fluid_midi_router(fluid_settings_t
*settings
,
95 handle_midi_event_func_t handler
,
96 void *event_handler_data
);
97 FLUIDSYNTH_API
void delete_fluid_midi_router(fluid_midi_router_t
*handler
);
98 FLUIDSYNTH_API
int fluid_midi_router_set_default_rules(fluid_midi_router_t
*router
);
99 FLUIDSYNTH_API
int fluid_midi_router_clear_rules(fluid_midi_router_t
*router
);
100 FLUIDSYNTH_API
int fluid_midi_router_add_rule(fluid_midi_router_t
*router
,
101 fluid_midi_router_rule_t
*rule
, int type
);
102 FLUIDSYNTH_API fluid_midi_router_rule_t
*new_fluid_midi_router_rule(void);
103 FLUIDSYNTH_API
void delete_fluid_midi_router_rule(fluid_midi_router_rule_t
*rule
);
104 FLUIDSYNTH_API
void fluid_midi_router_rule_set_chan(fluid_midi_router_rule_t
*rule
,
105 int min
, int max
, float mul
, int add
);
106 FLUIDSYNTH_API
void fluid_midi_router_rule_set_param1(fluid_midi_router_rule_t
*rule
,
107 int min
, int max
, float mul
, int add
);
108 FLUIDSYNTH_API
void fluid_midi_router_rule_set_param2(fluid_midi_router_rule_t
*rule
,
109 int min
, int max
, float mul
, int add
);
110 FLUIDSYNTH_API
int fluid_midi_router_handle_midi_event(void *data
, fluid_midi_event_t
*event
);
111 FLUIDSYNTH_API
int fluid_midi_dump_prerouter(void *data
, fluid_midi_event_t
*event
);
112 FLUIDSYNTH_API
int fluid_midi_dump_postrouter(void *data
, fluid_midi_event_t
*event
);
116 fluid_midi_driver_t
*new_fluid_midi_driver(fluid_settings_t
*settings
,
117 handle_midi_event_func_t handler
,
118 void *event_handler_data
);
120 FLUIDSYNTH_API
void delete_fluid_midi_driver(fluid_midi_driver_t
*driver
);
124 * MIDI player status enum.
127 enum fluid_player_status
129 FLUID_PLAYER_READY
, /**< Player is ready */
130 FLUID_PLAYER_PLAYING
, /**< Player is currently playing */
131 FLUID_PLAYER_DONE
/**< Player is finished playing */
134 FLUIDSYNTH_API fluid_player_t
*new_fluid_player(fluid_synth_t
*synth
);
135 FLUIDSYNTH_API
void delete_fluid_player(fluid_player_t
*player
);
136 FLUIDSYNTH_API
int fluid_player_add(fluid_player_t
*player
, const char *midifile
);
137 FLUIDSYNTH_API
int fluid_player_add_mem(fluid_player_t
*player
, const void *buffer
, size_t len
);
138 FLUIDSYNTH_API
int fluid_player_play(fluid_player_t
*player
);
139 FLUIDSYNTH_API
int fluid_player_stop(fluid_player_t
*player
);
140 FLUIDSYNTH_API
int fluid_player_join(fluid_player_t
*player
);
141 FLUIDSYNTH_API
int fluid_player_set_loop(fluid_player_t
*player
, int loop
);
142 FLUIDSYNTH_API
int fluid_player_set_midi_tempo(fluid_player_t
*player
, int tempo
);
143 FLUIDSYNTH_API
int fluid_player_set_bpm(fluid_player_t
*player
, int bpm
);
144 FLUIDSYNTH_API
int fluid_player_set_playback_callback(fluid_player_t
*player
, handle_midi_event_func_t handler
, void *handler_data
);
146 FLUIDSYNTH_API
int fluid_player_get_status(fluid_player_t
*player
);
147 FLUIDSYNTH_API
int fluid_player_get_current_tick(fluid_player_t
*player
);
148 FLUIDSYNTH_API
int fluid_player_get_total_ticks(fluid_player_t
*player
);
149 FLUIDSYNTH_API
int fluid_player_get_bpm(fluid_player_t
*player
);
150 FLUIDSYNTH_API
int fluid_player_get_midi_tempo(fluid_player_t
*player
);
151 FLUIDSYNTH_API
int fluid_player_seek(fluid_player_t
*player
, int ticks
);
159 #endif /* _FLUIDSYNTH_MIDI_H */