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 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 * 02110-1301, USA 19 */ 20 21 #ifndef _FLUIDSYNTH_MOD_H 22 #define _FLUIDSYNTH_MOD_H 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /** 29 * @file mod.h 30 * @brief SoundFont modulator functions and constants. 31 */ 32 33 #define FLUID_NUM_MOD 64 /**< Maximum number of modulators in a voice */ 34 35 /** 36 * Modulator structure. See SoundFont 2.04 PDF section 8.2. 37 */ 38 struct _fluid_mod_t 39 { 40 unsigned char dest; /**< Destination generator to control */ 41 unsigned char src1; /**< Source controller 1 */ 42 unsigned char flags1; /**< Source controller 1 flags */ 43 unsigned char src2; /**< Source controller 2 */ 44 unsigned char flags2; /**< Source controller 2 flags */ 45 double amount; /**< Multiplier amount */ 46 /* The 'next' field allows to link modulators into a list. It is 47 * not used in fluid_voice.c, there each voice allocates memory for a 48 * fixed number of modulators. Since there may be a huge number of 49 * different zones, this is more efficient. 50 */ 51 fluid_mod_t * next; 52 }; 53 54 /** 55 * Flags defining the polarity, mapping function and type of a modulator source. 56 * Compare with SoundFont 2.04 PDF section 8.2. 57 * 58 * Note: Bit values do not correspond to the SoundFont spec! Also note that 59 * #FLUID_MOD_GC and #FLUID_MOD_CC are in the flags field instead of the source field. 60 */ 61 enum fluid_mod_flags 62 { 63 FLUID_MOD_POSITIVE = 0, /**< Mapping function is positive */ 64 FLUID_MOD_NEGATIVE = 1, /**< Mapping function is negative */ 65 FLUID_MOD_UNIPOLAR = 0, /**< Mapping function is unipolar */ 66 FLUID_MOD_BIPOLAR = 2, /**< Mapping function is bipolar */ 67 FLUID_MOD_LINEAR = 0, /**< Linear mapping function */ 68 FLUID_MOD_CONCAVE = 4, /**< Concave mapping function */ 69 FLUID_MOD_CONVEX = 8, /**< Convex mapping function */ 70 FLUID_MOD_SWITCH = 12, /**< Switch (on/off) mapping function */ 71 FLUID_MOD_GC = 0, /**< General controller source type (#fluid_mod_src) */ 72 FLUID_MOD_CC = 16 /**< MIDI CC controller (source will be a MIDI CC number) */ 73 }; 74 75 /** 76 * General controller (if #FLUID_MOD_GC in flags). This 77 * corresponds to SoundFont 2.04 PDF section 8.2.1 78 */ 79 enum fluid_mod_src 80 { 81 FLUID_MOD_NONE = 0, /**< No source controller */ 82 FLUID_MOD_VELOCITY = 2, /**< MIDI note-on velocity */ 83 FLUID_MOD_KEY = 3, /**< MIDI note-on note number */ 84 FLUID_MOD_KEYPRESSURE = 10, /**< MIDI key pressure */ 85 FLUID_MOD_CHANNELPRESSURE = 13, /**< MIDI channel pressure */ 86 FLUID_MOD_PITCHWHEEL = 14, /**< Pitch wheel */ 87 FLUID_MOD_PITCHWHEELSENS = 16 /**< Pitch wheel sensitivity */ 88 }; 89 90 FLUIDSYNTH_API fluid_mod_t* fluid_mod_new(void); 91 FLUIDSYNTH_API void fluid_mod_delete(fluid_mod_t * mod); 92 93 FLUIDSYNTH_API void fluid_mod_set_source1(fluid_mod_t* mod, int src, int flags); 94 FLUIDSYNTH_API void fluid_mod_set_source2(fluid_mod_t* mod, int src, int flags); 95 FLUIDSYNTH_API void fluid_mod_set_dest(fluid_mod_t* mod, int dst); 96 FLUIDSYNTH_API void fluid_mod_set_amount(fluid_mod_t* mod, double amount); 97 98 FLUIDSYNTH_API int fluid_mod_get_source1(fluid_mod_t* mod); 99 FLUIDSYNTH_API int fluid_mod_get_flags1(fluid_mod_t* mod); 100 FLUIDSYNTH_API int fluid_mod_get_source2(fluid_mod_t* mod); 101 FLUIDSYNTH_API int fluid_mod_get_flags2(fluid_mod_t* mod); 102 FLUIDSYNTH_API int fluid_mod_get_dest(fluid_mod_t* mod); 103 FLUIDSYNTH_API double fluid_mod_get_amount(fluid_mod_t* mod); 104 105 FLUIDSYNTH_API int fluid_mod_test_identity(fluid_mod_t * mod1, fluid_mod_t * mod2); 106 107 108 #ifdef __cplusplus 109 } 110 #endif 111 #endif /* _FLUIDSYNTH_MOD_H */ 112 113