Main Page | Data Structures | File List | Data Fields | Globals

synth.h

Go to the documentation of this file.
00001 /* FluidSynth - A Software Synthesizer
00002  *
00003  * Copyright (C) 2003  Peter Hanappe and others.
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public License
00007  * as published by the Free Software Foundation; either version 2 of
00008  * the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *  
00015  * You should have received a copy of the GNU Library General Public
00016  * License along with this library; if not, write to the Free
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018  * 02111-1307, USA
00019  */
00020 
00021 #ifndef _FLUIDSYNTH_SYNTH_H
00022 #define _FLUIDSYNTH_SYNTH_H
00023 
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 
00056 FLUIDSYNTH_API fluid_synth_t* new_fluid_synth(fluid_settings_t* settings);
00057 
00058 
00065 FLUIDSYNTH_API int delete_fluid_synth(fluid_synth_t* synth);
00066 
00067 
00073 FLUIDSYNTH_API fluid_settings_t* fluid_synth_get_settings(fluid_synth_t* synth);
00074 
00075 
00076   /*
00077    * 
00078    * MIDI channel messages 
00079    *
00080    */
00081 
00083 FLUIDSYNTH_API int fluid_synth_noteon(fluid_synth_t* synth, int chan, int key, int vel);
00084 
00086 FLUIDSYNTH_API int fluid_synth_noteoff(fluid_synth_t* synth, int chan, int key);
00087 
00089 FLUIDSYNTH_API int fluid_synth_cc(fluid_synth_t* synth, int chan, int ctrl, int val);
00090 
00092 FLUIDSYNTH_API int fluid_synth_get_cc(fluid_synth_t* synth, int chan, int ctrl, int* pval);
00093 
00095 FLUIDSYNTH_API int fluid_synth_pitch_bend(fluid_synth_t* synth, int chan, int val);
00096 
00098 FLUIDSYNTH_API 
00099 int fluid_synth_get_pitch_bend(fluid_synth_t* synth, int chan, int* ppitch_bend);
00100 
00102 FLUIDSYNTH_API int fluid_synth_pitch_wheel_sens(fluid_synth_t* synth, int chan, int val);
00103 
00105 FLUIDSYNTH_API int fluid_synth_program_change(fluid_synth_t* synth, int chan, int program);
00106 
00108 FLUIDSYNTH_API 
00109 int fluid_synth_bank_select(fluid_synth_t* synth, int chan, unsigned int bank);
00110 
00112 FLUIDSYNTH_API 
00113 int fluid_synth_sfont_select(fluid_synth_t* synth, int chan, unsigned int sfont_id);
00114 
00127 FLUIDSYNTH_API 
00128 int fluid_synth_program_select(fluid_synth_t* synth, int chan, 
00129                               unsigned int sfont_id, 
00130                               unsigned int bank_num, 
00131                               unsigned int preset_num);
00132 
00135 FLUIDSYNTH_API 
00136 int fluid_synth_get_program(fluid_synth_t* synth, int chan, 
00137                            unsigned int* sfont_id, 
00138                            unsigned int* bank_num, 
00139                            unsigned int* preset_num);
00140 
00145 FLUIDSYNTH_API int fluid_synth_program_reset(fluid_synth_t* synth);
00146 
00149 FLUIDSYNTH_API int fluid_synth_system_reset(fluid_synth_t* synth);
00150 
00151 
00152   /*
00153    * 
00154    * Low level access 
00155    *
00156    */
00157 
00160 FLUIDSYNTH_API int fluid_synth_start(fluid_synth_t* synth, unsigned int id, 
00161                                      fluid_preset_t* preset, int audio_chan, 
00162                                      int midi_chan, int key, int vel);
00163 
00165 FLUIDSYNTH_API int fluid_synth_stop(fluid_synth_t* synth, unsigned int id);
00166 
00169 /* FLUIDSYNTH_API int fluid_synth_ctrl(fluid_synth_t* synth, int id,  */
00170 /*                                  int gen, float value,  */
00171 /*                                  int absolute, int normalized); */
00172 
00173 
00174   /*
00175    * 
00176    * SoundFont management 
00177    *
00178    */
00179 
00191 FLUIDSYNTH_API 
00192 int fluid_synth_sfload(fluid_synth_t* synth, const char* filename, int reset_presets);
00193 
00201 FLUIDSYNTH_API int fluid_synth_sfreload(fluid_synth_t* synth, unsigned int id);
00202 
00210 FLUIDSYNTH_API int fluid_synth_sfunload(fluid_synth_t* synth, unsigned int id, int reset_presets);
00211 
00219 FLUIDSYNTH_API int fluid_synth_add_sfont(fluid_synth_t* synth, fluid_sfont_t* sfont);
00220 
00226 FLUIDSYNTH_API int fluid_synth_sfcount(fluid_synth_t* synth);
00227 
00235 FLUIDSYNTH_API fluid_sfont_t* fluid_synth_get_sfont(fluid_synth_t* synth, unsigned int num);
00236 
00243 FLUIDSYNTH_API fluid_sfont_t* fluid_synth_get_sfont_by_id(fluid_synth_t* synth, unsigned int id);
00244 
00245 
00247 FLUIDSYNTH_API fluid_preset_t* fluid_synth_get_channel_preset(fluid_synth_t* synth, int chan);
00248 
00249 
00250 
00251 
00252   /*
00253    * 
00254    * Reverb 
00255    *
00256    */
00257 
00259 FLUIDSYNTH_API void fluid_synth_set_reverb(fluid_synth_t* synth, double roomsize, 
00260                                          double damping, double width, double level);
00261 
00263 FLUIDSYNTH_API void fluid_synth_set_reverb_on(fluid_synth_t* synth, int on);
00264 
00265 
00267 FLUIDSYNTH_API double fluid_synth_get_reverb_roomsize(fluid_synth_t* synth);
00268 FLUIDSYNTH_API double fluid_synth_get_reverb_damp(fluid_synth_t* synth);
00269 FLUIDSYNTH_API double fluid_synth_get_reverb_level(fluid_synth_t* synth);
00270 FLUIDSYNTH_API double fluid_synth_get_reverb_width(fluid_synth_t* synth);
00271 
00272   /* Those are the default settings for the reverb */
00273 #define FLUID_REVERB_DEFAULT_ROOMSIZE 0.2f
00274 #define FLUID_REVERB_DEFAULT_DAMP 0.0f
00275 #define FLUID_REVERB_DEFAULT_WIDTH 0.5f
00276 #define FLUID_REVERB_DEFAULT_LEVEL 0.9f
00277 
00278 
00279 
00280   /*
00281    * 
00282    * Chorus 
00283    *
00284    */
00285 
00286 enum fluid_chorus_mod {
00287   FLUID_CHORUS_MOD_SINE = 0,
00288   FLUID_CHORUS_MOD_TRIANGLE = 1
00289 };
00290 
00295 FLUIDSYNTH_API void fluid_synth_set_chorus(fluid_synth_t* synth, int nr, double level, 
00296                                          double speed, double depth_ms, int type);
00297 
00299 FLUIDSYNTH_API void fluid_synth_set_chorus_on(fluid_synth_t* synth, int on);
00300 
00302 FLUIDSYNTH_API int fluid_synth_get_chorus_nr(fluid_synth_t* synth);
00303 FLUIDSYNTH_API double fluid_synth_get_chorus_level(fluid_synth_t* synth);
00304 FLUIDSYNTH_API double fluid_synth_get_chorus_speed_Hz(fluid_synth_t* synth);
00305 FLUIDSYNTH_API double fluid_synth_get_chorus_depth_ms(fluid_synth_t* synth);
00306 FLUIDSYNTH_API int fluid_synth_get_chorus_type(fluid_synth_t* synth); /* see fluid_chorus_mod */
00307 
00308   /* Those are the default settings for the chorus. */
00309 #define FLUID_CHORUS_DEFAULT_N 3
00310 #define FLUID_CHORUS_DEFAULT_LEVEL 2.0f
00311 #define FLUID_CHORUS_DEFAULT_SPEED 0.3f
00312 #define FLUID_CHORUS_DEFAULT_DEPTH 8.0f
00313 #define FLUID_CHORUS_DEFAULT_TYPE FLUID_CHORUS_MOD_SINE 
00314 
00315 
00316 
00317   /*
00318    * 
00319    * Audio and MIDI channels 
00320    *
00321    */
00322 
00325 FLUIDSYNTH_API int fluid_synth_count_midi_channels(fluid_synth_t* synth);
00326 
00329 FLUIDSYNTH_API int fluid_synth_count_audio_channels(fluid_synth_t* synth);
00330 
00333 FLUIDSYNTH_API int fluid_synth_count_audio_groups(fluid_synth_t* synth);
00334 
00337 FLUIDSYNTH_API int fluid_synth_count_effects_channels(fluid_synth_t* synth);
00338 
00339 
00340 
00341   /*
00342    * 
00343    * Synthesis parameters 
00344    *
00345    */
00346 
00348 FLUIDSYNTH_API void fluid_synth_set_gain(fluid_synth_t* synth, float gain);
00349 
00351 FLUIDSYNTH_API float fluid_synth_get_gain(fluid_synth_t* synth);
00352 
00362 FLUIDSYNTH_API int fluid_synth_get_internal_bufsize(fluid_synth_t* synth);
00363 
00365 FLUIDSYNTH_API 
00366 int fluid_synth_set_interp_method(fluid_synth_t* synth, int chan, int interp_method);
00367 
00368   /* Flags to choose the interpolation method */
00369 enum fluid_interp {
00370   /* no interpolation: Fastest, but questionable audio quality */
00371   FLUID_INTERP_NONE = 0,
00372   /* Straight-line interpolation: A bit slower, reasonable audio quality */
00373   FLUID_INTERP_LINEAR = 1,
00374   /* Fourth-order interpolation: Requires 50 % of the whole DSP processing time, good quality 
00375    * Default. */
00376   FLUID_INTERP_DEFAULT = 4,
00377   FLUID_INTERP_4THORDER = 4,
00378   FLUID_INTERP_7THORDER = 7,
00379   FLUID_INTERP_HIGHEST=7
00380 };
00381 
00382 
00383 
00384 
00385   /*
00386    * 
00387    * Generator interface 
00388    *
00389    */
00390 
00405 FLUIDSYNTH_API 
00406 int fluid_synth_set_gen(fluid_synth_t* synth, int chan, int param, float value);
00407 
00408 
00417 FLUIDSYNTH_API float fluid_synth_get_gen(fluid_synth_t* synth, int chan, int param);
00418 
00419 
00420 
00421 
00422   /*
00423    * 
00424    * Tuning 
00425    *
00426    */
00427 
00439 FLUIDSYNTH_API 
00440 int fluid_synth_create_key_tuning(fluid_synth_t* synth, int tuning_bank, int tuning_prog,
00441                                  char* name, double* pitch);
00442 
00455 FLUIDSYNTH_API 
00456 int fluid_synth_create_octave_tuning(fluid_synth_t* synth, int tuning_bank, int tuning_prog,
00457                                     char* name, double* pitch);
00458 
00473 FLUIDSYNTH_API 
00474 int fluid_synth_tune_notes(fluid_synth_t* synth, int tuning_bank, int tuning_prog,
00475                           int len, int *keys, double* pitch, int apply);
00476 
00484 FLUIDSYNTH_API 
00485 int fluid_synth_select_tuning(fluid_synth_t* synth, int chan, int tuning_bank, int tuning_prog);
00486 
00492 FLUIDSYNTH_API int fluid_synth_reset_tuning(fluid_synth_t* synth, int chan);
00493 
00498 FLUIDSYNTH_API void fluid_synth_tuning_iteration_start(fluid_synth_t* synth);
00499 
00500 
00510 FLUIDSYNTH_API 
00511 int fluid_synth_tuning_iteration_next(fluid_synth_t* synth, int* bank, int* prog);
00512 
00513 
00525 FLUIDSYNTH_API int fluid_synth_tuning_dump(fluid_synth_t* synth, int bank, int prog, 
00526                                          char* name, int len, double* pitch);
00527 
00528 
00529 
00530 
00531   /*
00532    * 
00533    * Misc 
00534    *
00535    */
00536 
00542 FLUIDSYNTH_API double fluid_synth_get_cpu_load(fluid_synth_t* synth);
00543 
00545 FLUIDSYNTH_API char* fluid_synth_error(fluid_synth_t* synth);
00546 
00547 
00548   /*
00549    *  
00550    *    Synthesizer plugin
00551    *  
00552    *    
00553    *    To create a synthesizer plugin, create the synthesizer as
00554    *    explained above. Once the synthesizer is created you can call
00555    *    any of the functions below to get the audio. 
00556    * 
00557    */
00558 
00574 FLUIDSYNTH_API int fluid_synth_write_s16(fluid_synth_t* synth, int len, 
00575                                        void* lout, int loff, int lincr, 
00576                                        void* rout, int roff, int rincr);
00577 
00578 
00594 FLUIDSYNTH_API int fluid_synth_write_float(fluid_synth_t* synth, int len, 
00595                                          void* lout, int loff, int lincr, 
00596                                          void* rout, int roff, int rincr);
00597 
00598 FLUIDSYNTH_API int fluid_synth_nwrite_float(fluid_synth_t* synth, int len, 
00599                                           float** left, float** right, 
00600                                           float** fx_left, float** fx_right);
00601 
00616 FLUIDSYNTH_API int fluid_synth_process(fluid_synth_t* synth, int len,
00617                                      int nin, float** in, 
00618                                      int nout, float** out);
00619 
00620 
00621 
00622   /* Type definition of the synthesizer's audio callback function. */
00623 typedef int (*fluid_audio_callback_t)(fluid_synth_t* synth, int len, 
00624                                      void* out1, int loff, int lincr, 
00625                                      void* out2, int roff, int rincr);
00626 
00627 
00628 
00629 
00630 
00631   /*
00632    *  Synthesizer's interface to handle SoundFont loaders 
00633    */
00634 
00635 
00639 FLUIDSYNTH_API void fluid_synth_add_sfloader(fluid_synth_t* synth, fluid_sfloader_t* loader);
00640 
00647 FLUIDSYNTH_API fluid_voice_t* fluid_synth_alloc_voice(fluid_synth_t* synth, fluid_sample_t* sample, 
00648                                                    int channum, int key, int vel);
00649 
00655 FLUIDSYNTH_API void fluid_synth_start_voice(fluid_synth_t* synth, fluid_voice_t* voice);
00656 
00657 
00660 FLUIDSYNTH_API void fluid_synth_get_voicelist(fluid_synth_t* synth, 
00661                                             fluid_voice_t* buf[], int bufsize, int ID);
00662 
00663 
00665 FLUIDSYNTH_API int fluid_synth_handle_midi_event(void* data, fluid_midi_event_t* event);
00666 
00667 
00669 FLUIDSYNTH_API void fluid_synth_set_midi_router(fluid_synth_t* synth, 
00670                                               fluid_midi_router_t* router);
00671 
00672 #ifdef __cplusplus
00673 }
00674 #endif
00675 
00676 #endif /* _FLUIDSYNTH_SYNTH_H */

Generated on Wed May 5 22:41:38 2004 for libfluidsynth by doxygen 1.3.6-20040222