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    * SoundFont management 
00155    *
00156    */
00157 
00168 FLUIDSYNTH_API 
00169 int fluid_synth_sfload(fluid_synth_t* synth, const char* filename, int reset_presets);
00170 
00178 FLUIDSYNTH_API int fluid_synth_sfreload(fluid_synth_t* synth, unsigned int id);
00179 
00186 FLUIDSYNTH_API int fluid_synth_sfunload(fluid_synth_t* synth, unsigned int id, int reset_presets);
00187 
00195 FLUIDSYNTH_API int fluid_synth_add_sfont(fluid_synth_t* synth, fluid_sfont_t* sfont);
00196 
00202 FLUIDSYNTH_API int fluid_synth_sfcount(fluid_synth_t* synth);
00203 
00211 FLUIDSYNTH_API fluid_sfont_t* fluid_synth_get_sfont(fluid_synth_t* synth, unsigned int num);
00212 
00219 FLUIDSYNTH_API fluid_sfont_t* fluid_synth_get_sfont_by_id(fluid_synth_t* synth, unsigned int id);
00220 
00221 
00223 FLUIDSYNTH_API fluid_preset_t* fluid_synth_get_channel_preset(fluid_synth_t* synth, int chan);
00224 
00225 
00226 
00227 
00228   /*
00229    * 
00230    * Reverb 
00231    *
00232    */
00233 
00235 FLUIDSYNTH_API void fluid_synth_set_reverb(fluid_synth_t* synth, double roomsize, 
00236                                          double damping, double width, double level);
00237 
00239 FLUIDSYNTH_API void fluid_synth_set_reverb_on(fluid_synth_t* synth, int on);
00240 
00241 
00243 FLUIDSYNTH_API double fluid_synth_get_reverb_roomsize(fluid_synth_t* synth);
00244 FLUIDSYNTH_API double fluid_synth_get_reverb_damp(fluid_synth_t* synth);
00245 FLUIDSYNTH_API double fluid_synth_get_reverb_level(fluid_synth_t* synth);
00246 FLUIDSYNTH_API double fluid_synth_get_reverb_width(fluid_synth_t* synth);
00247 
00248   /* Those are the default settings for the reverb */
00249 #define FLUID_REVERB_DEFAULT_ROOMSIZE 0.2f
00250 #define FLUID_REVERB_DEFAULT_DAMP 0.0f
00251 #define FLUID_REVERB_DEFAULT_WIDTH 0.5f
00252 #define FLUID_REVERB_DEFAULT_LEVEL 0.9f
00253 
00254 
00255 
00256   /*
00257    * 
00258    * Chorus 
00259    *
00260    */
00261 
00262 enum fluid_chorus_mod {
00263   FLUID_CHORUS_MOD_SINE = 0,
00264   FLUID_CHORUS_MOD_TRIANGLE = 1
00265 };
00266 
00271 FLUIDSYNTH_API void fluid_synth_set_chorus(fluid_synth_t* synth, int nr, double level, 
00272                                          double speed, double depth_ms, int type);
00273 
00275 FLUIDSYNTH_API void fluid_synth_set_chorus_on(fluid_synth_t* synth, int on);
00276 
00278 FLUIDSYNTH_API int fluid_synth_get_chorus_nr(fluid_synth_t* synth);
00279 FLUIDSYNTH_API double fluid_synth_get_chorus_level(fluid_synth_t* synth);
00280 FLUIDSYNTH_API double fluid_synth_get_chorus_speed_Hz(fluid_synth_t* synth);
00281 FLUIDSYNTH_API double fluid_synth_get_chorus_depth_ms(fluid_synth_t* synth);
00282 FLUIDSYNTH_API int fluid_synth_get_chorus_type(fluid_synth_t* synth); /* see fluid_chorus_mod */
00283 
00284   /* Those are the default settings for the chorus. */
00285 #define FLUID_CHORUS_DEFAULT_N 3
00286 #define FLUID_CHORUS_DEFAULT_LEVEL 2.0f
00287 #define FLUID_CHORUS_DEFAULT_SPEED 0.3f
00288 #define FLUID_CHORUS_DEFAULT_DEPTH 8.0f
00289 #define FLUID_CHORUS_DEFAULT_TYPE FLUID_CHORUS_MOD_SINE 
00290 
00291 
00292 
00293   /*
00294    * 
00295    * Audio and MIDI channels 
00296    *
00297    */
00298 
00301 FLUIDSYNTH_API int fluid_synth_count_midi_channels(fluid_synth_t* synth);
00302 
00305 FLUIDSYNTH_API int fluid_synth_count_audio_channels(fluid_synth_t* synth);
00306 
00309 FLUIDSYNTH_API int fluid_synth_count_audio_groups(fluid_synth_t* synth);
00310 
00313 FLUIDSYNTH_API int fluid_synth_count_effects_channels(fluid_synth_t* synth);
00314 
00315 
00316 
00317   /*
00318    * 
00319    * Synthesis parameters 
00320    *
00321    */
00322 
00324 FLUIDSYNTH_API void fluid_synth_set_gain(fluid_synth_t* synth, float gain);
00325 
00327 FLUIDSYNTH_API float fluid_synth_get_gain(fluid_synth_t* synth);
00328 
00338 FLUIDSYNTH_API int fluid_synth_get_internal_bufsize(fluid_synth_t* synth);
00339 
00341 FLUIDSYNTH_API 
00342 int fluid_synth_set_interp_method(fluid_synth_t* synth, int chan, int interp_method);
00343 
00344   /* Flags to choose the interpolation method */
00345 enum fluid_interp {
00346   /* no interpolation: Fastest, but questionable audio quality */
00347   FLUID_INTERP_NONE = 0,
00348   /* Straight-line interpolation: A bit slower, reasonable audio quality */
00349   FLUID_INTERP_LINEAR = 1,
00350   /* Fourth-order interpolation: Requires 50 % of the whole DSP processing time, good quality 
00351    * Default. */
00352   FLUID_INTERP_DEFAULT = 4,
00353   FLUID_INTERP_4THORDER = 4,
00354   FLUID_INTERP_7THORDER = 7,
00355   FLUID_INTERP_HIGHEST=7
00356 };
00357 
00358 
00359 
00360 
00361   /*
00362    * 
00363    * Generator interface 
00364    *
00365    */
00366 
00381 FLUIDSYNTH_API 
00382 int fluid_synth_set_gen(fluid_synth_t* synth, int chan, int param, float value);
00383 
00384 
00393 FLUIDSYNTH_API float fluid_synth_get_gen(fluid_synth_t* synth, int chan, int param);
00394 
00395 
00396 
00397 
00398   /*
00399    * 
00400    * Tuning 
00401    *
00402    */
00403 
00415 FLUIDSYNTH_API 
00416 int fluid_synth_create_key_tuning(fluid_synth_t* synth, int tuning_bank, int tuning_prog,
00417                                  char* name, double* pitch);
00418 
00431 FLUIDSYNTH_API 
00432 int fluid_synth_create_octave_tuning(fluid_synth_t* synth, int tuning_bank, int tuning_prog,
00433                                     char* name, double* pitch);
00434 
00449 FLUIDSYNTH_API 
00450 int fluid_synth_tune_notes(fluid_synth_t* synth, int tuning_bank, int tuning_prog,
00451                           int len, int *keys, double* pitch, int apply);
00452 
00460 FLUIDSYNTH_API 
00461 int fluid_synth_select_tuning(fluid_synth_t* synth, int chan, int tuning_bank, int tuning_prog);
00462 
00468 FLUIDSYNTH_API int fluid_synth_reset_tuning(fluid_synth_t* synth, int chan);
00469 
00474 FLUIDSYNTH_API void fluid_synth_tuning_iteration_start(fluid_synth_t* synth);
00475 
00476 
00486 FLUIDSYNTH_API 
00487 int fluid_synth_tuning_iteration_next(fluid_synth_t* synth, int* bank, int* prog);
00488 
00489 
00501 FLUIDSYNTH_API int fluid_synth_tuning_dump(fluid_synth_t* synth, int bank, int prog, 
00502                                          char* name, int len, double* pitch);
00503 
00504 
00505 
00506 
00507   /*
00508    * 
00509    * Misc 
00510    *
00511    */
00512 
00518 FLUIDSYNTH_API double fluid_synth_get_cpu_load(fluid_synth_t* synth);
00519 
00521 FLUIDSYNTH_API char* fluid_synth_error(fluid_synth_t* synth);
00522 
00523 
00524   /*
00525    *  
00526    *    Synthesizer plugin
00527    *  
00528    *    
00529    *    To create a synthesizer plugin, create the synthesizer as
00530    *    explained above. Once the synthesizer is created you can call
00531    *    any of the functions below to get the audio. 
00532    * 
00533    */
00534 
00550 FLUIDSYNTH_API int fluid_synth_write_s16(fluid_synth_t* synth, int len, 
00551                                        void* lout, int loff, int lincr, 
00552                                        void* rout, int roff, int rincr);
00553 
00554 
00570 FLUIDSYNTH_API int fluid_synth_write_float(fluid_synth_t* synth, int len, 
00571                                          void* lout, int loff, int lincr, 
00572                                          void* rout, int roff, int rincr);
00573 
00574 FLUIDSYNTH_API int fluid_synth_nwrite_float(fluid_synth_t* synth, int len, 
00575                                           float** left, float** right, 
00576                                           float** fx_left, float** fx_right);
00577 
00592 FLUIDSYNTH_API int fluid_synth_process(fluid_synth_t* synth, int len,
00593                                      int nin, float** in, 
00594                                      int nout, float** out);
00595 
00596 
00597 
00598   /* Type definition of the synthesizer's audio callback function. */
00599 typedef int (*fluid_audio_callback_t)(fluid_synth_t* synth, int len, 
00600                                      void* out1, int loff, int lincr, 
00601                                      void* out2, int roff, int rincr);
00602 
00603 
00604 
00605 
00606 
00607   /*
00608    *  Synthesizer's interface to handle SoundFont loaders 
00609    */
00610 
00611 
00615 FLUIDSYNTH_API void fluid_synth_add_sfloader(fluid_synth_t* synth, fluid_sfloader_t* loader);
00616 
00623 FLUIDSYNTH_API fluid_voice_t* fluid_synth_alloc_voice(fluid_synth_t* synth, fluid_sample_t* sample, 
00624                                                    int channum, int key, int vel);
00625 
00631 FLUIDSYNTH_API void fluid_synth_start_voice(fluid_synth_t* synth, fluid_voice_t* voice);
00632 
00633 
00636 FLUIDSYNTH_API void fluid_synth_get_voicelist(fluid_synth_t* synth, 
00637                                             fluid_voice_t* buf[], int bufsize, int ID);
00638 
00639 
00641 FLUIDSYNTH_API int fluid_synth_handle_midi_event(void* data, fluid_midi_event_t* event);
00642 
00643 
00645 FLUIDSYNTH_API void fluid_synth_set_midi_router(fluid_synth_t* synth, 
00646                                               fluid_midi_router_t* router);
00647 
00648 #ifdef __cplusplus
00649 }
00650 #endif
00651 
00652 #endif /* _FLUIDSYNTH_SYNTH_H */

Generated on Thu Mar 13 19:09:34 2003 for libfluidsynth by doxygen1.2.15