/[svn]/liblscp/trunk/lscp/client.h
ViewVC logotype

Contents of /liblscp/trunk/lscp/client.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3664 - (show annotations) (download) (as text)
Sun Dec 22 12:53:26 2019 UTC (2 years, 6 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 12864 byte(s)
Improved connection error handling:

* Expose actual system error codes via client interface
  instead of just -1 whenever a syscall failed.

* Added new client interface function:
    lscp_client_connection_lost();
  for checking whether client lost connection to server.

1 // client.h
2 //
3 /****************************************************************************
4 liblscp - LinuxSampler Control Protocol API
5 Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved.
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21 *****************************************************************************/
22
23 #ifndef __LSCP_CLIENT_H
24 #define __LSCP_CLIENT_H
25
26 #include "lscp/socket.h"
27 #include "lscp/event.h"
28 #include <stdbool.h>
29
30 #if defined(__cplusplus)
31 extern "C" {
32 #endif
33
34 //-------------------------------------------------------------------------
35 // MIDI channel omni mode.
36
37 #define LSCP_MIDI_CHANNEL_ALL 16
38
39
40 //-------------------------------------------------------------------------
41 // Client data structures.
42
43 /** Server info cache struct. */
44 typedef struct _lscp_server_info_t
45 {
46 char * description;
47 char * version;
48 char * protocol_version;
49
50 } lscp_server_info_t;
51
52
53 /** Engine info cache struct. */
54 typedef struct _lscp_engine_info_t
55 {
56 char * description;
57 char * version;
58
59 } lscp_engine_info_t;
60
61
62 /** Channel info cache struct. */
63 typedef struct _lscp_channel_info_t
64 {
65 char * engine_name;
66 int audio_device;
67 int audio_channels;
68 int * audio_routing;
69 char * instrument_file;
70 int instrument_nr;
71 char * instrument_name;
72 int instrument_status;
73 int midi_device;
74 int midi_port;
75 int midi_channel;
76 int midi_map;
77 float volume;
78 int mute;
79 int solo;
80
81 } lscp_channel_info_t;
82
83
84 /** Buffer fill cache struct. */
85 typedef struct _lscp_buffer_fill_t
86 {
87 unsigned int stream_id;
88 unsigned long stream_usage;
89
90 } lscp_buffer_fill_t;
91
92
93 /** Buffer fill stream usage types. */
94 typedef enum _lscp_usage_t
95 {
96 LSCP_USAGE_BYTES = 0,
97 LSCP_USAGE_PERCENTAGE
98
99 } lscp_usage_t;
100
101
102 /** Effect send info cache struct. */
103 typedef struct _lscp_fxsend_info_t
104 {
105 char * name;
106 int midi_controller;
107 int * audio_routing;
108 float level;
109
110 } lscp_fxsend_info_t;
111
112
113 /** MIDI instrument parameter struct. */
114 typedef struct _lscp_midi_instrument_t
115 {
116 int map;
117 int bank;
118 int prog;
119
120 } lscp_midi_instrument_t;
121
122
123 /** MIDI instrument load mode. */
124 typedef enum _lscp_load_mode_t
125 {
126 LSCP_LOAD_DEFAULT = 0,
127 LSCP_LOAD_ON_DEMAND,
128 LSCP_LOAD_ON_DEMAND_HOLD,
129 LSCP_LOAD_PERSISTENT
130
131 } lscp_load_mode_t;
132
133
134 /** MIDI instrument info cache struct. */
135 typedef struct _lscp_midi_instrument_info_t
136 {
137 char * name;
138 char * engine_name;
139 char * instrument_file;
140 int instrument_nr;
141 char * instrument_name;
142 lscp_load_mode_t load_mode;
143 float volume;
144
145 } lscp_midi_instrument_info_t;
146
147
148 /** MIDI instrument map mode. */
149 typedef enum _lscp_midi_map_mode_t
150 {
151 LSCP_MIDI_MAP_NONE = -1,
152 LSCP_MIDI_MAP_DEFAULT = -2,
153 LSCP_MIDI_MAP_ALL = -3
154
155 } lscp_midi_map_mode_t;
156
157
158 //-------------------------------------------------------------------------
159 // Client socket main structure.
160
161 /** Client opaque descriptor struct. */
162 typedef struct _lscp_client_t lscp_client_t;
163
164 /** Client event callback procedure prototype. */
165 typedef lscp_status_t (*lscp_client_proc_t)
166 (
167 struct _lscp_client_t *pClient,
168 lscp_event_t event,
169 const char *pchData,
170 int cchData,
171 void *pvData
172 );
173
174 //-------------------------------------------------------------------------
175 // Client versioning teller function.
176
177 const char * lscp_client_package (void);
178 const char * lscp_client_version (void);
179 const char * lscp_client_build (void);
180
181 //-------------------------------------------------------------------------
182 // Client socket functions.
183
184 lscp_client_t * lscp_client_create (const char *pszHost, int iPort, lscp_client_proc_t pfnCallback, void *pvData);
185 lscp_status_t lscp_client_join (lscp_client_t *pClient);
186 lscp_status_t lscp_client_destroy (lscp_client_t *pClient);
187
188 lscp_status_t lscp_client_set_timeout (lscp_client_t *pClient, int iTimeout);
189 int lscp_client_get_timeout (lscp_client_t *pClient);
190 bool lscp_client_connection_lost (lscp_client_t *pClient);
191
192 //-------------------------------------------------------------------------
193 // Client common protocol functions.
194
195 lscp_status_t lscp_client_query (lscp_client_t *pClient, const char *pszQuery);
196 const char * lscp_client_get_result (lscp_client_t *pClient );
197 int lscp_client_get_errno (lscp_client_t *pClient );
198
199 //-------------------------------------------------------------------------
200 // Client registration protocol functions.
201
202 lscp_status_t lscp_client_subscribe (lscp_client_t *pClient, lscp_event_t events);
203 lscp_status_t lscp_client_unsubscribe (lscp_client_t *pClient, lscp_event_t events);
204
205 lscp_event_t lscp_client_get_events (lscp_client_t *pClient);
206
207 //-------------------------------------------------------------------------
208 // Client command protocol functions.
209
210 lscp_status_t lscp_load_instrument (lscp_client_t *pClient, const char *pszFileName, int iInstrIndex, int iSamplerChannel);
211 lscp_status_t lscp_load_instrument_non_modal (lscp_client_t *pClient, const char *pszFileName, int iInstrIndex, int iSamplerChannel);
212 lscp_status_t lscp_load_engine (lscp_client_t *pClient, const char *pszEngineName, int iSamplerChannel);
213 int lscp_get_channels (lscp_client_t *pClient);
214 int * lscp_list_channels (lscp_client_t *pClient);
215 int lscp_add_channel (lscp_client_t *pClient);
216 lscp_status_t lscp_remove_channel (lscp_client_t *pClient, int iSamplerChannel);
217
218 int lscp_get_available_engines (lscp_client_t *pClient);
219 const char ** lscp_list_available_engines (lscp_client_t *pClient);
220
221 lscp_engine_info_t * lscp_get_engine_info (lscp_client_t *pClient, const char *pszEngineName);
222 lscp_channel_info_t * lscp_get_channel_info (lscp_client_t *pClient, int iSamplerChannel);
223
224 int lscp_get_channel_voice_count (lscp_client_t *pClient, int iSamplerChannel);
225 int lscp_get_channel_stream_count (lscp_client_t *pClient, int iSamplerChannel);
226 int lscp_get_channel_stream_usage (lscp_client_t *pClient, int iSamplerChannel);
227
228 lscp_buffer_fill_t * lscp_get_channel_buffer_fill (lscp_client_t *pClient, lscp_usage_t iUsageType, int iSamplerChannel);
229
230 lscp_status_t lscp_set_channel_audio_type (lscp_client_t *pClient, int iSamplerChannel, const char *pszAudioType);
231 lscp_status_t lscp_set_channel_audio_device (lscp_client_t *pClient, int iSamplerChannel, int iAudioDevice);
232 lscp_status_t lscp_set_channel_audio_channel (lscp_client_t *pClient, int iSamplerChannel, int iAudioOut, int iAudioIn);
233
234 lscp_status_t lscp_set_channel_midi_type (lscp_client_t *pClient, int iSamplerChannel, const char *pszMidiType);
235 lscp_status_t lscp_set_channel_midi_device (lscp_client_t *pClient, int iSamplerChannel, int iMidiDevice);
236 lscp_status_t lscp_set_channel_midi_port (lscp_client_t *pClient, int iSamplerChannel, int iMidiPort);
237 lscp_status_t lscp_set_channel_midi_channel (lscp_client_t *pClient, int iSamplerChannel, int iMidiChannel);
238 lscp_status_t lscp_set_channel_midi_map (lscp_client_t *pClient, int iSamplerChannel, int iMidiMap);
239
240 lscp_status_t lscp_set_channel_volume (lscp_client_t *pClient, int iSamplerChannel, float fVolume);
241
242 lscp_status_t lscp_set_channel_mute (lscp_client_t *pClient, int iSamplerChannel, int iMute);
243 lscp_status_t lscp_set_channel_solo (lscp_client_t *pClient, int iSamplerChannel, int iSolo);
244
245 lscp_status_t lscp_reset_channel (lscp_client_t *pClient, int iSamplerChannel);
246
247 lscp_status_t lscp_reset_sampler (lscp_client_t *pClient);
248
249 lscp_server_info_t * lscp_get_server_info (lscp_client_t *pClient);
250
251 int lscp_get_total_voice_count (lscp_client_t *pClient);
252 int lscp_get_total_voice_count_max (lscp_client_t *pClient);
253
254 float lscp_get_volume (lscp_client_t *pClient);
255 lscp_status_t lscp_set_volume (lscp_client_t *pClient, float fVolume);
256
257 int lscp_get_voices (lscp_client_t *pClient);
258 lscp_status_t lscp_set_voices (lscp_client_t *pClient, int iMaxVoices);
259
260 int lscp_get_streams (lscp_client_t *pClient);
261 lscp_status_t lscp_set_streams (lscp_client_t *pClient, int iMaxStreams);
262
263 //-------------------------------------------------------------------------
264 // Effect sends control functions.
265
266 int lscp_create_fxsend (lscp_client_t *pClient, int iSamplerChannel, int iMidiController, const char *pszFxName);
267 lscp_status_t lscp_destroy_fxsend (lscp_client_t *pClient, int iSamplerChannel, int iFxSend);
268
269 int lscp_get_fxsends (lscp_client_t *pClient, int iSamplerChannel);
270 int * lscp_list_fxsends (lscp_client_t *pClient, int iSamplerChannel);
271
272 lscp_fxsend_info_t * lscp_get_fxsend_info (lscp_client_t *pClient, int iSamplerChannel, int iFxSend);
273
274 lscp_status_t lscp_set_fxsend_name (lscp_client_t *pClient, int iSamplerChannel, int iFxSend, const char *pszFxName);
275 lscp_status_t lscp_set_fxsend_audio_channel (lscp_client_t *pClient, int iSamplerChannel, int iFxSend, int iAudioSrc, int iAudioDst);
276 lscp_status_t lscp_set_fxsend_midi_controller (lscp_client_t *pClient, int iSamplerChannel, int iFxSend, int iMidiController);
277 lscp_status_t lscp_set_fxsend_level (lscp_client_t *pClient, int iSamplerChannel, int iFxSend, float fLevel);
278
279 //-------------------------------------------------------------------------
280 // MIDI instrument mapping control functions.
281
282 int lscp_add_midi_instrument_map (lscp_client_t *pClient, const char *pszMapName);
283 lscp_status_t lscp_remove_midi_instrument_map (lscp_client_t *pClient, int iMidiMap);
284
285 int lscp_get_midi_instrument_maps (lscp_client_t *pClient);
286 int * lscp_list_midi_instrument_maps (lscp_client_t *pClient);
287
288 const char * lscp_get_midi_instrument_map_name (lscp_client_t *pClient, int iMidiMap);
289 lscp_status_t lscp_set_midi_instrument_map_name (lscp_client_t *pClient, int iMidiMap, const char *pszMapName);
290
291 lscp_status_t lscp_map_midi_instrument (lscp_client_t *pClient, lscp_midi_instrument_t *pMidiInstr, const char *pszEngineName, const char *pszFileName, int iInstrIndex, float fVolume, lscp_load_mode_t load_mode, const char *pszName);
292 lscp_status_t lscp_unmap_midi_instrument (lscp_client_t *pClient, lscp_midi_instrument_t *pMidiInstr);
293
294 int lscp_get_midi_instruments (lscp_client_t *pClient, int iMidiMap);
295 lscp_midi_instrument_t *lscp_list_midi_instruments (lscp_client_t *pClient, int iMidiMap);
296
297 lscp_midi_instrument_info_t *lscp_get_midi_instrument_info(lscp_client_t *pClient, lscp_midi_instrument_t *pMidiInstr);
298
299 lscp_status_t lscp_clear_midi_instruments (lscp_client_t *pClient, int iMidiMap);
300
301 //-------------------------------------------------------------------------
302 // Instrument editor functions.
303
304 lscp_status_t lscp_edit_channel_instrument (lscp_client_t *pClient, int iSamplerChannel);
305
306 #if defined(__cplusplus)
307 }
308 #endif
309
310 #endif // __LSCP_CLIENT_H
311
312 // end of client.h

  ViewVC Help
Powered by ViewVC