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 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.
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  * Library General Public License for more details.
14  *
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  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18  * 02111-1307, USA
19  */
20 
21 #ifndef _FLUIDSYNTH_SYNTH_H
22 #define _FLUIDSYNTH_SYNTH_H
23 
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30   /**   Embedded synthesizer
31    *
32    *    You create a new synthesizer with new_fluid_synth() and you destroy
33    *    if with delete_fluid_synth(). Use the settings structure to specify
34    *    the synthesizer characteristics.
35    *
36    *    You have to load a SoundFont in order to hear any sound. For that
37    *    you use the fluid_synth_sfload() function.
38    *
39    *    You can use the audio driver functions described below to open
40    *    the audio device and create a background audio thread.
41    *
42    *    The API for sending MIDI events is probably what you expect:
43    *    fluid_synth_noteon(), fluid_synth_noteoff(), ...
44    *
45    */
46 
47 
48   /** Creates a new synthesizer object.
49    *
50    *  Creates a new synthesizer object. As soon as the synthesizer is
51    *  created, it will start playing.
52    *
53    * \param settings a pointer to a settings structure
54    * \return a newly allocated synthesizer or NULL in case of error
55    */
56 FLUIDSYNTH_API fluid_synth_t* new_fluid_synth(fluid_settings_t* settings);
57 
58 FLUIDSYNTH_API void fluid_synth_set_sample_rate(fluid_synth_t* synth, float sample_rate);
59 
60 
61   /**
62    * Deletes the synthesizer previously created with new_fluid_synth.
63    *
64    * \param synth the synthesizer object
65    * \return 0 if no error occured, -1 otherwise
66    */
67 FLUIDSYNTH_API int delete_fluid_synth(fluid_synth_t* synth);
68 
69 
70   /** Get a reference to the settings of the synthesizer.
71    *
72    * \param synth the synthesizer object
73    * \return pointer to the settings
74    */
75 FLUIDSYNTH_API fluid_settings_t* fluid_synth_get_settings(fluid_synth_t* synth);
76 
77 
78   /*
79    *
80    * MIDI channel messages
81    *
82    */
83 
84   /** Send a noteon message. Returns 0 if no error occurred, -1 otherwise. */
85 FLUIDSYNTH_API int fluid_synth_noteon(fluid_synth_t* synth, int chan, int key, int vel);
86 
87   /** Send a noteoff message. Returns 0 if no error occurred, -1 otherwise.  */
88 FLUIDSYNTH_API int fluid_synth_noteoff(fluid_synth_t* synth, int chan, int key);
89 
90   /** Send a control change message. Returns 0 if no error occurred, -1 otherwise.  */
91 FLUIDSYNTH_API int fluid_synth_cc(fluid_synth_t* synth, int chan, int ctrl, int val);
92 
93   /** Get a control value. Returns 0 if no error occurred, -1 otherwise.  */
94 FLUIDSYNTH_API int fluid_synth_get_cc(fluid_synth_t* synth, int chan, int ctrl, int* pval);
95 
96   /** Send a pitch bend message. Returns 0 if no error occurred, -1 otherwise.  */
97 FLUIDSYNTH_API int fluid_synth_pitch_bend(fluid_synth_t* synth, int chan, int val);
98 
99   /** Get the pitch bend value. Returns 0 if no error occurred, -1 otherwise. */
100 FLUIDSYNTH_API
101 int fluid_synth_get_pitch_bend(fluid_synth_t* synth, int chan, int* ppitch_bend);
102 
103   /** Set the pitch wheel sensitivity. Returns 0 if no error occurred, -1 otherwise. */
104 FLUIDSYNTH_API int fluid_synth_pitch_wheel_sens(fluid_synth_t* synth, int chan, int val);
105 
106   /** Get the pitch wheel sensitivity. Returns 0 if no error occurred, -1 otherwise. */
107 FLUIDSYNTH_API int fluid_synth_get_pitch_wheel_sens(fluid_synth_t* synth, int chan, int* pval);
108 
109   /** Send a program change message. Returns 0 if no error occurred, -1 otherwise. */
110 FLUIDSYNTH_API int fluid_synth_program_change(fluid_synth_t* synth, int chan, int program);
111 
112 FLUIDSYNTH_API int fluid_synth_channel_pressure(fluid_synth_t* synth, int chan, int val);
113 FLUIDSYNTH_API int fluid_synth_sysex(fluid_synth_t *synth, const char *data, int len,
114                                      char *response, int *response_len, int *handled, int dryrun);
115 
116   /** Select a bank. Returns 0 if no error occurred, -1 otherwise. */
117 FLUIDSYNTH_API
118 int fluid_synth_bank_select(fluid_synth_t* synth, int chan, unsigned int bank);
119 
120   /** Select a sfont. Returns 0 if no error occurred, -1 otherwise. */
121 FLUIDSYNTH_API
122 int fluid_synth_sfont_select(fluid_synth_t* synth, int chan, unsigned int sfont_id);
123 
124   /** Select a preset for a channel. The preset is specified by the
125       SoundFont ID, the bank number, and the preset number. This
126       allows any preset to be selected and circumvents preset masking
127       due to previously loaded SoundFonts on the SoundFont stack.
128 
129       \param synth The synthesizer
130       \param chan The channel on which to set the preset
131       \param sfont_id The ID of the SoundFont
132       \param bank_num The bank number
133       \param preset_num The preset number
134       \return 0 if no errors occured, -1 otherwise
135   */
136 FLUIDSYNTH_API
137 int fluid_synth_program_select(fluid_synth_t* synth, int chan,
138 			      unsigned int sfont_id,
139 			      unsigned int bank_num,
140 			      unsigned int preset_num);
141 
142   /** Returns the program, bank, and SoundFont number of the preset on
143       a given channel. Returns 0 if no error occurred, -1 otherwise. */
144 FLUIDSYNTH_API
145 int fluid_synth_get_program(fluid_synth_t* synth, int chan,
146 			   unsigned int* sfont_id,
147 			   unsigned int* bank_num,
148 			   unsigned int* preset_num);
149 
150   /** Send a bank select and a program change to every channel to
151    *  reinitialize the preset of the channel. This function is useful
152    *  mainly after a SoundFont has been loaded, unloaded or
153    *  reloaded. . Returns 0 if no error occurred, -1 otherwise. */
154 FLUIDSYNTH_API int fluid_synth_program_reset(fluid_synth_t* synth);
155 
156   /** Send a reset. A reset turns all the notes off and resets the
157       controller values. */
158 FLUIDSYNTH_API int fluid_synth_system_reset(fluid_synth_t* synth);
159 
160 
161   /*
162    *
163    * Low level access
164    *
165    */
166 
167   /** Create and start voices using a preset. The id passed as
168    * argument will be used as the voice group id.  */
169 FLUIDSYNTH_API int fluid_synth_start(fluid_synth_t* synth, unsigned int id,
170 				     fluid_preset_t* preset, int audio_chan,
171 				     int midi_chan, int key, int vel);
172 
173   /** Stop the voices in the voice group defined by id. */
174 FLUIDSYNTH_API int fluid_synth_stop(fluid_synth_t* synth, unsigned int id);
175 
176   /** Change the value of a generator of the voices in the voice group
177    * defined by id. */
178 /* FLUIDSYNTH_API int fluid_synth_ctrl(fluid_synth_t* synth, int id,  */
179 /* 				    int gen, float value,  */
180 /* 				    int absolute, int normalized); */
181 
182 
183   /*
184    *
185    * SoundFont management
186    *
187    */
188 
189   /** Loads a SoundFont file and creates a new SoundFont. The newly
190       loaded SoundFont will be put on top of the SoundFont
191       stack. Presets are searched starting from the SoundFont on the
192       top of the stack, working the way down the stack until a preset
193       is found.
194 
195       \param synth The synthesizer object
196       \param filename The file name
197       \param reset_presets If non-zero, the presets on the channels will be reset
198       \returns The ID of the loaded SoundFont, or -1 in case of error
199   */
200 FLUIDSYNTH_API
201 int fluid_synth_sfload(fluid_synth_t* synth, const char* filename, int reset_presets);
202 
203   /** Reload a SoundFont. The reloaded SoundFont retains its ID and
204       index on the stack.
205 
206       \param synth The synthesizer object
207       \param id The id of the SoundFont
208       \returns The ID of the loaded SoundFont, or -1 in case of error
209   */
210 FLUIDSYNTH_API int fluid_synth_sfreload(fluid_synth_t* synth, unsigned int id);
211 
212   /** Removes a SoundFont from the stack and deallocates it.
213 
214       \param synth The synthesizer object
215       \param id The id of the SoundFont
216       \param reset_presets If TRUE then presets will be reset for all channels
217       \returns 0 if no error, -1 otherwise
218   */
219 FLUIDSYNTH_API int fluid_synth_sfunload(fluid_synth_t* synth, unsigned int id, int reset_presets);
220 
221   /** Add a SoundFont. The SoundFont will be put on top of
222       the SoundFont stack.
223 
224       \param synth The synthesizer object
225       \param sfont The SoundFont
226       \returns The ID of the loaded SoundFont, or -1 in case of error
227   */
228 FLUIDSYNTH_API int fluid_synth_add_sfont(fluid_synth_t* synth, fluid_sfont_t* sfont);
229 
230   /** Remove a SoundFont that was previously added using
231    *  fluid_synth_add_sfont(). The synthesizer does not delete the
232    *  SoundFont; this is responsability of the caller.
233 
234       \param synth The synthesizer object
235       \param sfont The SoundFont
236   */
237 FLUIDSYNTH_API void fluid_synth_remove_sfont(fluid_synth_t* synth, fluid_sfont_t* sfont);
238 
239   /** Count the number of loaded SoundFonts.
240 
241       \param synth The synthesizer object
242       \returns The number of loaded SoundFonts
243   */
244 FLUIDSYNTH_API int fluid_synth_sfcount(fluid_synth_t* synth);
245 
246   /** Get a SoundFont. The SoundFont is specified by its index on the
247       stack. The top of the stack has index zero.
248 
249       \param synth The synthesizer object
250       \param num The number of the SoundFont (0 <= num < sfcount)
251       \returns A pointer to the SoundFont
252   */
253 FLUIDSYNTH_API fluid_sfont_t* fluid_synth_get_sfont(fluid_synth_t* synth, unsigned int num);
254 
255   /** Get a SoundFont. The SoundFont is specified by its ID.
256 
257       \param synth The synthesizer object
258       \param id The id of the sfont
259       \returns A pointer to the SoundFont
260   */
261 FLUIDSYNTH_API fluid_sfont_t* fluid_synth_get_sfont_by_id(fluid_synth_t* synth, unsigned int id);
262 
263 
264   /** Get the preset of a channel */
265 FLUIDSYNTH_API fluid_preset_t* fluid_synth_get_channel_preset(fluid_synth_t* synth, int chan);
266 
267   /** Offset the bank numbers in a SoundFont. Returns -1 if an error
268    * occured (out of memory or negative offset) */
269 FLUIDSYNTH_API int fluid_synth_set_bank_offset(fluid_synth_t* synth, int sfont_id, int offset);
270 
271   /** Get the offset of the bank numbers in a SoundFont. */
272 FLUIDSYNTH_API int fluid_synth_get_bank_offset(fluid_synth_t* synth, int sfont_id);
273 
274 
275 
276   /*
277    *
278    * Reverb
279    *
280    */
281 
282   /** Set the parameters for the built-in reverb unit */
283 FLUIDSYNTH_API void fluid_synth_set_reverb(fluid_synth_t* synth, double roomsize,
284 					 double damping, double width, double level);
285 
286   /** Turn on (1) / off (0) the built-in reverb unit */
287 FLUIDSYNTH_API void fluid_synth_set_reverb_on(fluid_synth_t* synth, int on);
288 
289 
290   /** Query the current state of the reverb. */
291 FLUIDSYNTH_API double fluid_synth_get_reverb_roomsize(fluid_synth_t* synth);
292 FLUIDSYNTH_API double fluid_synth_get_reverb_damp(fluid_synth_t* synth);
293 FLUIDSYNTH_API double fluid_synth_get_reverb_level(fluid_synth_t* synth);
294 FLUIDSYNTH_API double fluid_synth_get_reverb_width(fluid_synth_t* synth);
295 
296   /* Those are the default settings for the reverb */
297 #define FLUID_REVERB_DEFAULT_ROOMSIZE 0.2f
298 #define FLUID_REVERB_DEFAULT_DAMP 0.0f
299 #define FLUID_REVERB_DEFAULT_WIDTH 0.5f
300 #define FLUID_REVERB_DEFAULT_LEVEL 0.9f
301 
302 
303 
304   /*
305    *
306    * Chorus
307    *
308    */
309 
310 enum fluid_chorus_mod {
311   FLUID_CHORUS_MOD_SINE = 0,
312   FLUID_CHORUS_MOD_TRIANGLE = 1
313 };
314 
315   /** Set up the chorus. It should be turned on with fluid_synth_set_chorus_on.
316    * If faulty parameters are given, all new settings are discarded.
317    * Keep in mind, that the needed CPU time is proportional to 'nr'.
318    */
319 FLUIDSYNTH_API void fluid_synth_set_chorus(fluid_synth_t* synth, int nr, double level,
320 					 double speed, double depth_ms, int type);
321 
322   /** Turn on (1) / off (0) the built-in chorus unit */
323 FLUIDSYNTH_API void fluid_synth_set_chorus_on(fluid_synth_t* synth, int on);
324 
325   /** Query the current state of the chorus. */
326 FLUIDSYNTH_API int fluid_synth_get_chorus_nr(fluid_synth_t* synth);
327 FLUIDSYNTH_API double fluid_synth_get_chorus_level(fluid_synth_t* synth);
328 FLUIDSYNTH_API double fluid_synth_get_chorus_speed_Hz(fluid_synth_t* synth);
329 FLUIDSYNTH_API double fluid_synth_get_chorus_depth_ms(fluid_synth_t* synth);
330 FLUIDSYNTH_API int fluid_synth_get_chorus_type(fluid_synth_t* synth); /* see fluid_chorus_mod */
331 
332   /* Those are the default settings for the chorus. */
333 #define FLUID_CHORUS_DEFAULT_N 3
334 #define FLUID_CHORUS_DEFAULT_LEVEL 2.0f
335 #define FLUID_CHORUS_DEFAULT_SPEED 0.3f
336 #define FLUID_CHORUS_DEFAULT_DEPTH 8.0f
337 #define FLUID_CHORUS_DEFAULT_TYPE FLUID_CHORUS_MOD_SINE
338 
339 
340 
341   /*
342    *
343    * Audio and MIDI channels
344    *
345    */
346 
347   /** Returns the number of MIDI channels that the synthesizer uses
348       internally */
349 FLUIDSYNTH_API int fluid_synth_count_midi_channels(fluid_synth_t* synth);
350 
351   /** Returns the number of audio channels that the synthesizer uses
352       internally */
353 FLUIDSYNTH_API int fluid_synth_count_audio_channels(fluid_synth_t* synth);
354 
355   /** Returns the number of audio groups that the synthesizer uses
356       internally. This is usually identical to audio_channels. */
357 FLUIDSYNTH_API int fluid_synth_count_audio_groups(fluid_synth_t* synth);
358 
359   /** Returns the number of effects channels that the synthesizer uses
360       internally */
361 FLUIDSYNTH_API int fluid_synth_count_effects_channels(fluid_synth_t* synth);
362 
363 
364 
365   /*
366    *
367    * Synthesis parameters
368    *
369    */
370 
371   /** Set the master gain */
372 FLUIDSYNTH_API void fluid_synth_set_gain(fluid_synth_t* synth, float gain);
373 
374   /** Get the master gain */
375 FLUIDSYNTH_API float fluid_synth_get_gain(fluid_synth_t* synth);
376 
377   /** Set the polyphony limit (FluidSynth >= 1.0.6) */
378 FLUIDSYNTH_API int fluid_synth_set_polyphony(fluid_synth_t* synth, int polyphony);
379 
380   /** Get the polyphony limit (FluidSynth >= 1.0.6) */
381 FLUIDSYNTH_API int fluid_synth_get_polyphony(fluid_synth_t* synth);
382 
383   /** Get the internal buffer size. The internal buffer size if not the
384       same thing as the buffer size specified in the
385       settings. Internally, the synth *always* uses a specific buffer
386       size independent of the buffer size used by the audio driver. The
387       internal buffer size is normally 64 samples. The reason why it
388       uses an internal buffer size is to allow audio drivers to call the
389       synthesizer with a variable buffer length. The internal buffer
390       size is useful for client who want to optimize their buffer sizes.
391   */
392 FLUIDSYNTH_API int fluid_synth_get_internal_bufsize(fluid_synth_t* synth);
393 
394   /** Set the interpolation method for one channel or all channels (chan = -1) */
395 FLUIDSYNTH_API
396 int fluid_synth_set_interp_method(fluid_synth_t* synth, int chan, int interp_method);
397 
398   /* Flags to choose the interpolation method */
399 enum fluid_interp {
400   /* no interpolation: Fastest, but questionable audio quality */
401   FLUID_INTERP_NONE = 0,
402   /* Straight-line interpolation: A bit slower, reasonable audio quality */
403   FLUID_INTERP_LINEAR = 1,
404   /* Fourth-order interpolation: Requires 50 % of the whole DSP processing time, good quality
405    * Default. */
406   FLUID_INTERP_DEFAULT = 4,
407   FLUID_INTERP_4THORDER = 4,
408   FLUID_INTERP_7THORDER = 7,
409   FLUID_INTERP_HIGHEST=7
410 };
411 
412 
413 
414 
415   /*
416    *
417    * Generator interface
418    *
419    */
420 
421   /** Change the value of a generator. This function allows to control
422       all synthesis parameters in real-time. The changes are additive,
423       i.e. they add up to the existing parameter value. This function is
424       similar to sending an NRPN message to the synthesizer. The
425       function accepts a float as the value of the parameter. The
426       parameter numbers and ranges are described in the SoundFont 2.01
427       specification, paragraph 8.1.3, page 48. See also 'fluid_gen_type'.
428 
429       \param synth The synthesizer object.
430       \param chan The MIDI channel number.
431       \param param The parameter number.
432       \param value The parameter value.
433       \returns Your favorite dish.
434   */
435 FLUIDSYNTH_API
436 int fluid_synth_set_gen(fluid_synth_t* synth, int chan, int param, float value);
437 
438 
439   /** Retreive the value of a generator. This function returns the value
440       set by a previous call 'fluid_synth_set_gen' or by an NRPN message.
441 
442       \param synth The synthesizer object.
443       \param chan The MIDI channel number.
444       \param param The generator number.
445       \returns The value of the generator.
446   */
447 FLUIDSYNTH_API float fluid_synth_get_gen(fluid_synth_t* synth, int chan, int param);
448 
449 
450 
451 
452   /*
453    *
454    * Tuning
455    *
456    */
457 
458   /** Create a new key-based tuning with given name, number, and
459       pitches. The array 'pitches' should have length 128 and contains
460       the pitch in cents of every key in cents. However, if 'pitches' is
461       NULL, a new tuning is created with the well-tempered scale.
462 
463       \param synth The synthesizer object
464       \param tuning_bank The tuning bank number [0-127]
465       \param tuning_prog The tuning program number [0-127]
466       \param name The name of the tuning
467       \param pitch The array of pitch values. The array length has to be 128.
468   */
469 FLUIDSYNTH_API
470 int fluid_synth_create_key_tuning(fluid_synth_t* synth, int tuning_bank, int tuning_prog,
471                                  const char* name, double* pitch);
472 
473   /** Create a new octave-based tuning with given name, number, and
474       pitches.  The array 'pitches' should have length 12 and contains
475       derivation in cents from the well-tempered scale. For example, if
476       pitches[0] equals -33, then the C-keys will be tuned 33 cents
477       below the well-tempered C.
478 
479       \param synth The synthesizer object
480       \param tuning_bank The tuning bank number [0-127]
481       \param tuning_prog The tuning program number [0-127]
482       \param name The name of the tuning
483       \param pitch The array of pitch derivations. The array length has to be 12.
484   */
485 FLUIDSYNTH_API
486 int fluid_synth_create_octave_tuning(fluid_synth_t* synth, int tuning_bank, int tuning_prog,
487                                     const char* name, const double* pitch);
488 
489 FLUIDSYNTH_API
490 int fluid_synth_activate_octave_tuning(fluid_synth_t* synth, int bank, int prog,
491                                        const char* name, const double* pitch, int apply);
492 
493   /** Request a note tuning changes. Both they 'keys' and 'pitches'
494       arrays should be of length 'num_pitches'. If 'apply' is non-zero,
495       the changes should be applied in real-time, i.e. sounding notes
496       will have their pitch updated. 'APPLY' IS CURRENTLY IGNORED. The
497       changes will be available for newly triggered notes only.
498 
499       \param synth The synthesizer object
500       \param tuning_bank The tuning bank number [0-127]
501       \param tuning_prog The tuning program number [0-127]
502       \param len The length of the keys and pitch arrays
503       \param keys The array of keys values.
504       \param pitch The array of pitch values.
505       \param apply Flag to indicate whether to changes should be applied in real-time.
506   */
507 FLUIDSYNTH_API
508 int fluid_synth_tune_notes(fluid_synth_t* synth, int tuning_bank, int tuning_prog,
509 			  int len, int *keys, double* pitch, int apply);
510 
511   /** Select a tuning for a channel.
512 
513   \param synth The synthesizer object
514   \param chan The channel number [0-max channels]
515   \param tuning_bank The tuning bank number [0-127]
516   \param tuning_prog The tuning program number [0-127]
517   */
518 FLUIDSYNTH_API
519 int fluid_synth_select_tuning(fluid_synth_t* synth, int chan, int tuning_bank, int tuning_prog);
520 
521 int fluid_synth_activate_tuning(fluid_synth_t* synth, int chan, int bank, int prog, int apply);
522 
523   /** Set the tuning to the default well-tempered tuning on a channel.
524 
525   \param synth The synthesizer object
526   \param chan The channel number [0-max channels]
527   */
528 FLUIDSYNTH_API int fluid_synth_reset_tuning(fluid_synth_t* synth, int chan);
529 
530   /** Start the iteration throught the list of available tunings.
531 
532   \param synth The synthesizer object
533   */
534 FLUIDSYNTH_API void fluid_synth_tuning_iteration_start(fluid_synth_t* synth);
535 
536 
537   /** Get the next tuning in the iteration. This functions stores the
538       bank and program number of the next tuning in the pointers given as
539       arguments.
540 
541       \param synth The synthesizer object
542       \param bank Pointer to an int to store the bank number
543       \param prog Pointer to an int to store the program number
544       \returns 1 if there is a next tuning, 0 otherwise
545   */
546 FLUIDSYNTH_API
547 int fluid_synth_tuning_iteration_next(fluid_synth_t* synth, int* bank, int* prog);
548 
549 
550   /** Dump the data of a tuning. This functions stores the name and
551       pitch values of a tuning in the pointers given as arguments. Both
552       name and pitch can be NULL is the data is not needed.
553 
554       \param synth The synthesizer object
555       \param bank The tuning bank number [0-127]
556       \param prog The tuning program number [0-127]
557       \param name Pointer to a buffer to store the name
558       \param len The length of the name buffer
559       \param pitch Pointer to buffer to store the pitch values
560   */
561 FLUIDSYNTH_API int fluid_synth_tuning_dump(fluid_synth_t* synth, int bank, int prog,
562 					 char* name, int len, double* pitch);
563 
564 
565 
566 
567   /*
568    *
569    * Misc
570    *
571    */
572 
573   /** Get a textual representation of the last error */
574 FLUIDSYNTH_API char* fluid_synth_error(fluid_synth_t* synth);
575 
576 
577   /*
578    *
579    *    Synthesizer plugin
580    *
581    *
582    *    To create a synthesizer plugin, create the synthesizer as
583    *    explained above. Once the synthesizer is created you can call
584    *    any of the functions below to get the audio.
585    *
586    */
587 
588   /** Generate a number of samples. This function expects two signed
589    *  16bits buffers (left and right channel) that will be filled with
590    *  samples.
591    *
592    *  \param synth The synthesizer
593    *  \param len The number of samples to generate
594    *  \param lout The sample buffer for the left channel
595    *  \param loff The offset, in samples, in the left buffer where the writing pointer starts
596    *  \param lincr The increment, in samples, of the writing pointer in the left buffer
597    *  \param rout The sample buffer for the right channel
598    *  \param roff The offset, in samples, in the right buffer where the writing pointer starts
599    *  \param rincr The increment, in samples, of the writing pointer in the right buffer
600    *  \returns 0 if no error occured, non-zero otherwise
601    */
602 
603 FLUIDSYNTH_API int fluid_synth_write_s16(fluid_synth_t* synth, int len,
604 				       void* lout, int loff, int lincr,
605 				       void* rout, int roff, int rincr);
606 
607 
608   /** Generate a number of samples. This function expects two floating
609    *  point buffers (left and right channel) that will be filled with
610    *  samples.
611    *
612    *  \param synth The synthesizer
613    *  \param len The number of samples to generate
614    *  \param lout The sample buffer for the left channel
615    *  \param loff The offset, in samples, in the left buffer where the writing pointer starts
616    *  \param lincr The increment, in samples, of the writing pointer in the left buffer
617    *  \param rout The sample buffer for the right channel
618    *  \param roff The offset, in samples, in the right buffer where the writing pointer starts
619    *  \param rincr The increment, in samples, of the writing pointer in the right buffer
620    *  \returns 0 if no error occured, non-zero otherwise
621    */
622 
623 FLUIDSYNTH_API int fluid_synth_write_float(fluid_synth_t* synth, int len,
624 					 void* lout, int loff, int lincr,
625 					 void* rout, int roff, int rincr);
626 
627 FLUIDSYNTH_API int fluid_synth_nwrite_float(fluid_synth_t* synth, int len,
628 					  float** left, float** right,
629 					  float** fx_left, float** fx_right);
630 
631   /** Generate a number of samples. This function implements the
632    *  default interface defined in fluidsynth/audio.h. This function
633    *  ignores the input buffers and expects at least two output
634    *  buffer.
635    *
636    *  \param synth The synthesizer
637    *  \param len The number of samples to generate
638    *  \param nin The number of input buffers
639    *  \param in The array of input buffers
640    *  \param nout The number of output buffers
641    *  \param out The array of output buffers
642    *  \returns 0 if no error occured, non-zero otherwise
643    */
644 
645 FLUIDSYNTH_API int fluid_synth_process(fluid_synth_t* synth, int len,
646 				     int nin, float** in,
647 				     int nout, float** out);
648 
649 
650 
651   /* Type definition of the synthesizer's audio callback function. */
652 typedef int (*fluid_audio_callback_t)(fluid_synth_t* synth, int len,
653 				     void* out1, int loff, int lincr,
654 				     void* out2, int roff, int rincr);
655 
656 
657 
658 
659 
660   /*
661    *  Synthesizer's interface to handle SoundFont loaders
662    */
663 
664 
665   /** Add a SoundFont loader to the synthesizer. Note that SoundFont
666       loader don't necessarily load SoundFonts. They can load any type
667       of wavetable data but export a SoundFont interface. */
668 FLUIDSYNTH_API void fluid_synth_add_sfloader(fluid_synth_t* synth, fluid_sfloader_t* loader);
669 
670   /** Allocate a synthesis voice. This function is called by a
671       soundfont's preset in response to a noteon event.
672       The returned voice comes with default modulators installed (velocity-to-attenuation,
673       velocity to filter, ...)
674       Note: A single noteon event may create any number of voices, when the preset is layered.
675       Typically 1 (mono) or 2 (stereo).*/
676 FLUIDSYNTH_API fluid_voice_t* fluid_synth_alloc_voice(fluid_synth_t* synth, fluid_sample_t* sample,
677 						   int channum, int key, int vel);
678 
679   /** Start a synthesis voice. This function is called by a
680       soundfont's preset in response to a noteon event after the voice
681       has been allocated with fluid_synth_alloc_voice() and
682       initialized.
683       Exclusive classes are processed here.*/
684 FLUIDSYNTH_API void fluid_synth_start_voice(fluid_synth_t* synth, fluid_voice_t* voice);
685 
686 
687   /** Write a list of all voices matching ID into buf, but not more than bufsize voices.
688    * If ID <0, return all voices. */
689 FLUIDSYNTH_API void fluid_synth_get_voicelist(fluid_synth_t* synth,
690 					    fluid_voice_t* buf[], int bufsize, int ID);
691 
692 
693 //midi router disabled
694 //  /** This is a hack to get command handlers working */
695 //FLUIDSYNTH_API void fluid_synth_set_midi_router(fluid_synth_t* synth,
696 //					      fluid_midi_router_t* router);
697 
698 #ifdef __cplusplus
699 }
700 #endif
701 
702 #endif /* _FLUIDSYNTH_SYNTH_H */
703