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

Generated on Sun Nov 30 06:16:37 2003 for libfluidsynth by doxygen 1.3.3