/FluidSynthWrapper/fluidsynth-1.0.8/doc/api/html/fluid__synth_8c-source.html
HTML | 3138 lines | 3137 code | 0 blank | 1 comment | 0 complexity | 852e724c5ee1c951e40c9f8660cfb603 MD5 | raw file
Possible License(s): LGPL-2.0, MPL-2.0-no-copyleft-exception
Large files files are truncated, but you can click here to view the full file
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
- <title>libfluidsynth: src/fluid_synth.c Source File</title>
- <link href="doxygen.css" rel="stylesheet" type="text/css">
- <link href="tabs.css" rel="stylesheet" type="text/css">
- </head><body>
- <!-- Generated by Doxygen 1.5.3 -->
- <div class="tabs">
- <ul>
- <li><a href="index.html"><span>Main Page</span></a></li>
- <li><a href="annotated.html"><span>Data Structures</span></a></li>
- <li class="current"><a href="files.html"><span>Files</span></a></li>
- </ul>
- </div>
- <h1>src/fluid_synth.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* FluidSynth - A Software Synthesizer</span>
- <a name="l00002"></a>00002 <span class="comment"> *</span>
- <a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 2003 Peter Hanappe and others.</span>
- <a name="l00004"></a>00004 <span class="comment"> *</span>
- <a name="l00005"></a>00005 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
- <a name="l00006"></a>00006 <span class="comment"> * modify it under the terms of the GNU Library General Public License</span>
- <a name="l00007"></a>00007 <span class="comment"> * as published by the Free Software Foundation; either version 2 of</span>
- <a name="l00008"></a>00008 <span class="comment"> * the License, or (at your option) any later version.</span>
- <a name="l00009"></a>00009 <span class="comment"> *</span>
- <a name="l00010"></a>00010 <span class="comment"> * This library is distributed in the hope that it will be useful, but</span>
- <a name="l00011"></a>00011 <span class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</span>
- <a name="l00012"></a>00012 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
- <a name="l00013"></a>00013 <span class="comment"> * Library General Public License for more details.</span>
- <a name="l00014"></a>00014 <span class="comment"> *</span>
- <a name="l00015"></a>00015 <span class="comment"> * You should have received a copy of the GNU Library General Public</span>
- <a name="l00016"></a>00016 <span class="comment"> * License along with this library; if not, write to the Free</span>
- <a name="l00017"></a>00017 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA</span>
- <a name="l00018"></a>00018 <span class="comment"> * 02111-1307, USA</span>
- <a name="l00019"></a>00019 <span class="comment"> */</span>
- <a name="l00020"></a>00020
- <a name="l00021"></a>00021 <span class="preprocessor">#include <math.h></span>
- <a name="l00022"></a>00022
- <a name="l00023"></a>00023 <span class="preprocessor">#include "fluid_synth.h"</span>
- <a name="l00024"></a>00024 <span class="preprocessor">#include "fluid_sys.h"</span>
- <a name="l00025"></a>00025 <span class="preprocessor">#include "fluid_chan.h"</span>
- <a name="l00026"></a>00026 <span class="preprocessor">#include "fluid_tuning.h"</span>
- <a name="l00027"></a>00027 <span class="preprocessor">#include "fluid_settings.h"</span>
- <a name="l00028"></a>00028 <span class="preprocessor">#include "fluid_sfont.h"</span>
- <a name="l00029"></a>00029
- <a name="l00030"></a>00030 <span class="preprocessor">#ifdef TRAP_ON_FPE</span>
- <a name="l00031"></a>00031 <span class="preprocessor"></span><span class="preprocessor">#define _GNU_SOURCE</span>
- <a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#include <fenv.h></span>
- <a name="l00033"></a>00033
- <a name="l00034"></a>00034 <span class="comment">/* seems to not be declared in fenv.h */</span>
- <a name="l00035"></a>00035 <span class="keyword">extern</span> <span class="keywordtype">int</span> feenableexcept (<span class="keywordtype">int</span> excepts);
- <a name="l00036"></a>00036 <span class="preprocessor">#endif</span>
- <a name="l00037"></a>00037 <span class="preprocessor"></span>
- <a name="l00038"></a>00038
- <a name="l00039"></a>00039 <a class="code" href="struct__fluid__sfloader__t.html">fluid_sfloader_t</a>* new_fluid_defsfloader(<span class="keywordtype">void</span>);
- <a name="l00040"></a>00040
- <a name="l00041"></a>00041 <span class="comment">/************************************************************************</span>
- <a name="l00042"></a>00042 <span class="comment"> *</span>
- <a name="l00043"></a>00043 <span class="comment"> * These functions were added after the v1.0 API freeze. They are not</span>
- <a name="l00044"></a>00044 <span class="comment"> * in synth.h. They should be added as soon as a new development</span>
- <a name="l00045"></a>00045 <span class="comment"> * version is started.</span>
- <a name="l00046"></a>00046 <span class="comment"> *</span>
- <a name="l00047"></a>00047 <span class="comment"> ************************************************************************/</span>
- <a name="l00048"></a>00048
- <a name="l00049"></a>00049 <span class="keywordtype">int</span> fluid_synth_program_select2(fluid_synth_t* synth,
- <a name="l00050"></a>00050 <span class="keywordtype">int</span> chan,
- <a name="l00051"></a>00051 <span class="keywordtype">char</span>* sfont_name,
- <a name="l00052"></a>00052 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bank_num,
- <a name="l00053"></a>00053 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> preset_num);
- <a name="l00054"></a>00054
- <a name="l00055"></a>00055 <a class="code" href="struct__fluid__sfont__t.html">fluid_sfont_t</a>* fluid_synth_get_sfont_by_name(fluid_synth_t* synth, <span class="keywordtype">char</span> *name);
- <a name="l00056"></a>00056
- <a name="l00057"></a>00057 <span class="keywordtype">int</span> fluid_synth_set_gen2(fluid_synth_t* synth, <span class="keywordtype">int</span> chan,
- <a name="l00058"></a>00058 <span class="keywordtype">int</span> param, <span class="keywordtype">float</span> value,
- <a name="l00059"></a>00059 <span class="keywordtype">int</span> absolute, <span class="keywordtype">int</span> normalized);
- <a name="l00060"></a>00060
- <a name="l00061"></a>00061
- <a name="l00062"></a>00062 <span class="comment">/***************************************************************</span>
- <a name="l00063"></a>00063 <span class="comment"> *</span>
- <a name="l00064"></a>00064 <span class="comment"> * GLOBAL</span>
- <a name="l00065"></a>00065 <span class="comment"> */</span>
- <a name="l00066"></a>00066
- <a name="l00067"></a>00067 <span class="comment">/* has the synth module been initialized? */</span>
- <a name="l00068"></a>00068 <span class="keyword">static</span> <span class="keywordtype">int</span> fluid_synth_initialized = 0;
- <a name="l00069"></a>00069 <span class="keyword">static</span> <span class="keywordtype">void</span> fluid_synth_init(<span class="keywordtype">void</span>);
- <a name="l00070"></a>00070 <span class="keyword">static</span> <span class="keywordtype">void</span> init_dither(<span class="keywordtype">void</span>);
- <a name="l00071"></a>00071
- <a name="l00072"></a>00072 <span class="comment">/* default modulators</span>
- <a name="l00073"></a>00073 <span class="comment"> * SF2.01 page 52 ff:</span>
- <a name="l00074"></a>00074 <span class="comment"> *</span>
- <a name="l00075"></a>00075 <span class="comment"> * There is a set of predefined default modulators. They have to be</span>
- <a name="l00076"></a>00076 <span class="comment"> * explicitly overridden by the sound font in order to turn them off.</span>
- <a name="l00077"></a>00077 <span class="comment"> */</span>
- <a name="l00078"></a>00078
- <a name="l00079"></a>00079 <a class="code" href="struct__fluid__mod__t.html">fluid_mod_t</a> default_vel2att_mod; <span class="comment">/* SF2.01 section 8.4.1 */</span>
- <a name="l00080"></a>00080 <a class="code" href="struct__fluid__mod__t.html">fluid_mod_t</a> default_vel2filter_mod; <span class="comment">/* SF2.01 section 8.4.2 */</span>
- <a name="l00081"></a>00081 <a class="code" href="struct__fluid__mod__t.html">fluid_mod_t</a> default_at2viblfo_mod; <span class="comment">/* SF2.01 section 8.4.3 */</span>
- <a name="l00082"></a>00082 <a class="code" href="struct__fluid__mod__t.html">fluid_mod_t</a> default_mod2viblfo_mod; <span class="comment">/* SF2.01 section 8.4.4 */</span>
- <a name="l00083"></a>00083 <a class="code" href="struct__fluid__mod__t.html">fluid_mod_t</a> default_att_mod; <span class="comment">/* SF2.01 section 8.4.5 */</span>
- <a name="l00084"></a>00084 <a class="code" href="struct__fluid__mod__t.html">fluid_mod_t</a> default_pan_mod; <span class="comment">/* SF2.01 section 8.4.6 */</span>
- <a name="l00085"></a>00085 <a class="code" href="struct__fluid__mod__t.html">fluid_mod_t</a> default_expr_mod; <span class="comment">/* SF2.01 section 8.4.7 */</span>
- <a name="l00086"></a>00086 <a class="code" href="struct__fluid__mod__t.html">fluid_mod_t</a> default_reverb_mod; <span class="comment">/* SF2.01 section 8.4.8 */</span>
- <a name="l00087"></a>00087 <a class="code" href="struct__fluid__mod__t.html">fluid_mod_t</a> default_chorus_mod; <span class="comment">/* SF2.01 section 8.4.9 */</span>
- <a name="l00088"></a>00088 <a class="code" href="struct__fluid__mod__t.html">fluid_mod_t</a> default_pitch_bend_mod; <span class="comment">/* SF2.01 section 8.4.10 */</span>
- <a name="l00089"></a>00089
- <a name="l00090"></a>00090 <span class="comment">/* reverb presets */</span>
- <a name="l00091"></a>00091 <span class="keyword">static</span> fluid_revmodel_presets_t revmodel_preset[] = {
- <a name="l00092"></a>00092 <span class="comment">/* name */</span> <span class="comment">/* roomsize */</span> <span class="comment">/* damp */</span> <span class="comment">/* width */</span> <span class="comment">/* level */</span>
- <a name="l00093"></a>00093 { <span class="stringliteral">"Test 1"</span>, 0.2f, 0.0f, 0.5f, 0.9f },
- <a name="l00094"></a>00094 { <span class="stringliteral">"Test 2"</span>, 0.4f, 0.2f, 0.5f, 0.8f },
- <a name="l00095"></a>00095 { <span class="stringliteral">"Test 3"</span>, 0.6f, 0.4f, 0.5f, 0.7f },
- <a name="l00096"></a>00096 { <span class="stringliteral">"Test 4"</span>, 0.8f, 0.7f, 0.5f, 0.6f },
- <a name="l00097"></a>00097 { <span class="stringliteral">"Test 5"</span>, 0.8f, 1.0f, 0.5f, 0.5f },
- <a name="l00098"></a>00098 { NULL, 0.0f, 0.0f, 0.0f, 0.0f }
- <a name="l00099"></a>00099 };
- <a name="l00100"></a>00100
- <a name="l00101"></a>00101
- <a name="l00102"></a>00102 <span class="comment">/***************************************************************</span>
- <a name="l00103"></a>00103 <span class="comment"> *</span>
- <a name="l00104"></a>00104 <span class="comment"> * INITIALIZATION & UTILITIES</span>
- <a name="l00105"></a>00105 <span class="comment"> */</span>
- <a name="l00106"></a>00106
- <a name="l00107"></a>00107
- <a name="l00108"></a>00108 <span class="keywordtype">void</span> fluid_synth_settings(fluid_settings_t* settings)
- <a name="l00109"></a>00109 {
- <a name="l00110"></a>00110 fluid_settings_register_str(settings, <span class="stringliteral">"synth.verbose"</span>, <span class="stringliteral">"no"</span>, 0, NULL, NULL);
- <a name="l00111"></a>00111 fluid_settings_register_str(settings, <span class="stringliteral">"synth.dump"</span>, <span class="stringliteral">"no"</span>, 0, NULL, NULL);
- <a name="l00112"></a>00112 fluid_settings_register_str(settings, <span class="stringliteral">"synth.reverb.active"</span>, <span class="stringliteral">"yes"</span>, 0, NULL, NULL);
- <a name="l00113"></a>00113 fluid_settings_register_str(settings, <span class="stringliteral">"synth.chorus.active"</span>, <span class="stringliteral">"yes"</span>, 0, NULL, NULL);
- <a name="l00114"></a>00114 fluid_settings_register_str(settings, <span class="stringliteral">"synth.ladspa.active"</span>, <span class="stringliteral">"no"</span>, 0, NULL, NULL);
- <a name="l00115"></a>00115
- <a name="l00116"></a>00116 fluid_settings_register_int(settings, <span class="stringliteral">"synth.polyphony"</span>,
- <a name="l00117"></a>00117 256, 16, 4096, 0, NULL, NULL);
- <a name="l00118"></a>00118 fluid_settings_register_int(settings, <span class="stringliteral">"synth.midi-channels"</span>,
- <a name="l00119"></a>00119 16, 16, 256, 0, NULL, NULL);
- <a name="l00120"></a>00120 fluid_settings_register_num(settings, <span class="stringliteral">"synth.gain"</span>,
- <a name="l00121"></a>00121 0.2f, 0.0f, 10.0f,
- <a name="l00122"></a>00122 0, NULL, NULL);
- <a name="l00123"></a>00123 fluid_settings_register_int(settings, <span class="stringliteral">"synth.audio-channels"</span>,
- <a name="l00124"></a>00124 1, 1, 256, 0, NULL, NULL);
- <a name="l00125"></a>00125 fluid_settings_register_int(settings, <span class="stringliteral">"synth.audio-groups"</span>,
- <a name="l00126"></a>00126 1, 1, 256, 0, NULL, NULL);
- <a name="l00127"></a>00127 fluid_settings_register_int(settings, <span class="stringliteral">"synth.effects-channels"</span>,
- <a name="l00128"></a>00128 2, 2, 2, 0, NULL, NULL);
- <a name="l00129"></a>00129 fluid_settings_register_num(settings, <span class="stringliteral">"synth.sample-rate"</span>,
- <a name="l00130"></a>00130 44100.0f, 22050.0f, 96000.0f,
- <a name="l00131"></a>00131 0, NULL, NULL);
- <a name="l00132"></a>00132 }
- <a name="l00133"></a>00133
- <a name="l00134"></a>00134 <span class="comment">/*</span>
- <a name="l00135"></a>00135 <span class="comment"> * fluid_version</span>
- <a name="l00136"></a>00136 <span class="comment"> */</span>
- <a name="l00137"></a>00137 <span class="keywordtype">void</span> fluid_version(<span class="keywordtype">int</span> *major, <span class="keywordtype">int</span> *minor, <span class="keywordtype">int</span> *micro)
- <a name="l00138"></a>00138 {
- <a name="l00139"></a>00139 *major = FLUIDSYNTH_VERSION_MAJOR;
- <a name="l00140"></a>00140 *minor = FLUIDSYNTH_VERSION_MINOR;
- <a name="l00141"></a>00141 *micro = FLUIDSYNTH_VERSION_MICRO;
- <a name="l00142"></a>00142 }
- <a name="l00143"></a>00143
- <a name="l00144"></a>00144 <span class="comment">/*</span>
- <a name="l00145"></a>00145 <span class="comment"> * fluid_version_str</span>
- <a name="l00146"></a>00146 <span class="comment"> */</span>
- <a name="l00147"></a>00147 <span class="keywordtype">char</span>* fluid_version_str(<span class="keywordtype">void</span>)
- <a name="l00148"></a>00148 {
- <a name="l00149"></a>00149 <span class="keywordflow">return</span> FLUIDSYNTH_VERSION;
- <a name="l00150"></a>00150 }
- <a name="l00151"></a>00151
- <a name="l00152"></a>00152
- <a name="l00153"></a>00153 <span class="comment">/*</span>
- <a name="l00154"></a>00154 <span class="comment"> * void fluid_synth_init</span>
- <a name="l00155"></a>00155 <span class="comment"> *</span>
- <a name="l00156"></a>00156 <span class="comment"> * Does all the initialization for this module.</span>
- <a name="l00157"></a>00157 <span class="comment"> */</span>
- <a name="l00158"></a>00158 <span class="keyword">static</span> <span class="keywordtype">void</span>
- <a name="l00159"></a>00159 fluid_synth_init()
- <a name="l00160"></a>00160 {
- <a name="l00161"></a>00161 fluid_synth_initialized++;
- <a name="l00162"></a>00162
- <a name="l00163"></a>00163 <span class="preprocessor">#ifdef TRAP_ON_FPE</span>
- <a name="l00164"></a>00164 <span class="preprocessor"></span> <span class="comment">/* Turn on floating point exception traps */</span>
- <a name="l00165"></a>00165 feenableexcept (FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID);
- <a name="l00166"></a>00166 <span class="preprocessor">#endif</span>
- <a name="l00167"></a>00167 <span class="preprocessor"></span>
- <a name="l00168"></a>00168 fluid_conversion_config();
- <a name="l00169"></a>00169
- <a name="l00170"></a>00170 fluid_dsp_float_config();
- <a name="l00171"></a>00171
- <a name="l00172"></a>00172 fluid_sys_config();
- <a name="l00173"></a>00173
- <a name="l00174"></a>00174 init_dither();
- <a name="l00175"></a>00175
- <a name="l00176"></a>00176
- <a name="l00177"></a>00177 <span class="comment">/* SF2.01 page 53 section 8.4.1: MIDI Note-On Velocity to Initial Attenuation */</span>
- <a name="l00178"></a>00178 fluid_mod_set_source1(&default_vel2att_mod, <span class="comment">/* The modulator we are programming here */</span>
- <a name="l00179"></a>00179 FLUID_MOD_VELOCITY, <span class="comment">/* Source. VELOCITY corresponds to 'index=2'. */</span>
- <a name="l00180"></a>00180 FLUID_MOD_GC <span class="comment">/* Not a MIDI continuous controller */</span>
- <a name="l00181"></a>00181 | FLUID_MOD_CONCAVE <span class="comment">/* Curve shape. Corresponds to 'type=1' */</span>
- <a name="l00182"></a>00182 | FLUID_MOD_UNIPOLAR <span class="comment">/* Polarity. Corresponds to 'P=0' */</span>
- <a name="l00183"></a>00183 | FLUID_MOD_NEGATIVE <span class="comment">/* Direction. Corresponds to 'D=1' */</span>
- <a name="l00184"></a>00184 );
- <a name="l00185"></a>00185 fluid_mod_set_source2(&default_vel2att_mod, 0, 0); <span class="comment">/* No 2nd source */</span>
- <a name="l00186"></a>00186 fluid_mod_set_dest(&default_vel2att_mod, <a class="code" href="gen_8h.html#d17a24ae3b25f3b8cc5762f818eef9b42db65ad593aeff4e814f9a7b7324c0df" title="Initial volume attenuation.">GEN_ATTENUATION</a>); <span class="comment">/* Target: Initial attenuation */</span>
- <a name="l00187"></a>00187 fluid_mod_set_amount(&default_vel2att_mod, 960.0); <span class="comment">/* Modulation amount: 960 */</span>
- <a name="l00188"></a>00188
- <a name="l00189"></a>00189
- <a name="l00190"></a>00190
- <a name="l00191"></a>00191 <span class="comment">/* SF2.01 page 53 section 8.4.2: MIDI Note-On Velocity to Filter Cutoff</span>
- <a name="l00192"></a>00192 <span class="comment"> * Have to make a design decision here. The specs don't make any sense this way or another.</span>
- <a name="l00193"></a>00193 <span class="comment"> * One sound font, 'Kingston Piano', which has been praised for its quality, tries to</span>
- <a name="l00194"></a>00194 <span class="comment"> * override this modulator with an amount of 0 and positive polarity (instead of what</span>
- <a name="l00195"></a>00195 <span class="comment"> * the specs say, D=1) for the secondary source.</span>
- <a name="l00196"></a>00196 <span class="comment"> * So if we change the polarity to 'positive', one of the best free sound fonts works...</span>
- <a name="l00197"></a>00197 <span class="comment"> */</span>
- <a name="l00198"></a>00198 fluid_mod_set_source1(&default_vel2filter_mod, FLUID_MOD_VELOCITY, <span class="comment">/* Index=2 */</span>
- <a name="l00199"></a>00199 FLUID_MOD_GC <span class="comment">/* CC=0 */</span>
- <a name="l00200"></a>00200 | FLUID_MOD_LINEAR <span class="comment">/* type=0 */</span>
- <a name="l00201"></a>00201 | FLUID_MOD_UNIPOLAR <span class="comment">/* P=0 */</span>
- <a name="l00202"></a>00202 | FLUID_MOD_NEGATIVE <span class="comment">/* D=1 */</span>
- <a name="l00203"></a>00203 );
- <a name="l00204"></a>00204 fluid_mod_set_source2(&default_vel2filter_mod, FLUID_MOD_VELOCITY, <span class="comment">/* Index=2 */</span>
- <a name="l00205"></a>00205 FLUID_MOD_GC <span class="comment">/* CC=0 */</span>
- <a name="l00206"></a>00206 | FLUID_MOD_SWITCH <span class="comment">/* type=3 */</span>
- <a name="l00207"></a>00207 | FLUID_MOD_UNIPOLAR <span class="comment">/* P=0 */</span>
- <a name="l00208"></a>00208 <span class="comment">// do not remove | FLUID_MOD_NEGATIVE /* D=1 */</span>
- <a name="l00209"></a>00209 | FLUID_MOD_POSITIVE <span class="comment">/* D=0 */</span>
- <a name="l00210"></a>00210 );
- <a name="l00211"></a>00211 fluid_mod_set_dest(&default_vel2filter_mod, <a class="code" href="gen_8h.html#d17a24ae3b25f3b8cc5762f818eef9b4e43e689b0b6349a676d26ea3096ed8d2" title="Filter cutoff.">GEN_FILTERFC</a>); <span class="comment">/* Target: Initial filter cutoff */</span>
- <a name="l00212"></a>00212 fluid_mod_set_amount(&default_vel2filter_mod, -2400);
- <a name="l00213"></a>00213
- <a name="l00214"></a>00214
- <a name="l00215"></a>00215
- <a name="l00216"></a>00216 <span class="comment">/* SF2.01 page 53 section 8.4.3: MIDI Channel pressure to Vibrato LFO pitch depth */</span>
- <a name="l00217"></a>00217 fluid_mod_set_source1(&default_at2viblfo_mod, FLUID_MOD_CHANNELPRESSURE, <span class="comment">/* Index=13 */</span>
- <a name="l00218"></a>00218 FLUID_MOD_GC <span class="comment">/* CC=0 */</span>
- <a name="l00219"></a>00219 | FLUID_MOD_LINEAR <span class="comment">/* type=0 */</span>
- <a name="l00220"></a>00220 | FLUID_MOD_UNIPOLAR <span class="comment">/* P=0 */</span>
- <a name="l00221"></a>00221 | FLUID_MOD_POSITIVE <span class="comment">/* D=0 */</span>
- <a name="l00222"></a>00222 );
- <a name="l00223"></a>00223 fluid_mod_set_source2(&default_at2viblfo_mod, 0,0); <span class="comment">/* no second source */</span>
- <a name="l00224"></a>00224 fluid_mod_set_dest(&default_at2viblfo_mod, <a class="code" href="gen_8h.html#d17a24ae3b25f3b8cc5762f818eef9b499387606556a9024de640b4519f7e559" title="Vibrato LFO to pitch.">GEN_VIBLFOTOPITCH</a>); <span class="comment">/* Target: Vib. LFO => pitch */</span>
- <a name="l00225"></a>00225 fluid_mod_set_amount(&default_at2viblfo_mod, 50);
- <a name="l00226"></a>00226
- <a name="l00227"></a>00227
- <a name="l00228"></a>00228
- <a name="l00229"></a>00229 <span class="comment">/* SF2.01 page 53 section 8.4.4: Mod wheel (Controller 1) to Vibrato LFO pitch depth */</span>
- <a name="l00230"></a>00230 fluid_mod_set_source1(&default_mod2viblfo_mod, 1, <span class="comment">/* Index=1 */</span>
- <a name="l00231"></a>00231 FLUID_MOD_CC <span class="comment">/* CC=1 */</span>
- <a name="l00232"></a>00232 | FLUID_MOD_LINEAR <span class="comment">/* type=0 */</span>
- <a name="l00233"></a>00233 | FLUID_MOD_UNIPOLAR <span class="comment">/* P=0 */</span>
- <a name="l00234"></a>00234 | FLUID_MOD_POSITIVE <span class="comment">/* D=0 */</span>
- <a name="l00235"></a>00235 );
- <a name="l00236"></a>00236 fluid_mod_set_source2(&default_mod2viblfo_mod, 0,0); <span class="comment">/* no second source */</span>
- <a name="l00237"></a>00237 fluid_mod_set_dest(&default_mod2viblfo_mod, <a class="code" href="gen_8h.html#d17a24ae3b25f3b8cc5762f818eef9b499387606556a9024de640b4519f7e559" title="Vibrato LFO to pitch.">GEN_VIBLFOTOPITCH</a>); <span class="comment">/* Target: Vib. LFO => pitch */</span>
- <a name="l00238"></a>00238 fluid_mod_set_amount(&default_mod2viblfo_mod, 50);
- <a name="l00239"></a>00239
- <a name="l00240"></a>00240
- <a name="l00241"></a>00241
- <a name="l00242"></a>00242 <span class="comment">/* SF2.01 page 55 section 8.4.5: MIDI continuous controller 7 to initial attenuation*/</span>
- <a name="l00243"></a>00243 fluid_mod_set_source1(&default_att_mod, 7, <span class="comment">/* index=7 */</span>
- <a name="l00244"></a>00244 FLUID_MOD_CC <span class="comment">/* CC=1 */</span>
- <a name="l00245"></a>00245 | FLUID_MOD_CONCAVE <span class="comment">/* type=1 */</span>
- <a name="l00246"></a>00246 | FLUID_MOD_UNIPOLAR <span class="comment">/* P=0 */</span>
- <a name="l00247"></a>00247 | FLUID_MOD_NEGATIVE <span class="comment">/* D=1 */</span>
- <a name="l00248"></a>00248 );
- <a name="l00249"></a>00249 fluid_mod_set_source2(&default_att_mod, 0, 0); <span class="comment">/* No second source */</span>
- <a name="l00250"></a>00250 fluid_mod_set_dest(&default_att_mod, <a class="code" href="gen_8h.html#d17a24ae3b25f3b8cc5762f818eef9b42db65ad593aeff4e814f9a7b7324c0df" title="Initial volume attenuation.">GEN_ATTENUATION</a>); <span class="comment">/* Target: Initial attenuation */</span>
- <a name="l00251"></a>00251 fluid_mod_set_amount(&default_att_mod, 960.0); <span class="comment">/* Amount: 960 */</span>
- <a name="l00252"></a>00252
- <a name="l00253"></a>00253
- <a name="l00254"></a>00254
- <a name="l00255"></a>00255 <span class="comment">/* SF2.01 page 55 section 8.4.6 MIDI continuous controller 10 to Pan Position */</span>
- <a name="l00256"></a>00256 fluid_mod_set_source1(&default_pan_mod, 10, <span class="comment">/* index=10 */</span>
- <a name="l00257"></a>00257 FLUID_MOD_CC <span class="comment">/* CC=1 */</span>
- <a name="l00258"></a>00258 | FLUID_MOD_LINEAR <span class="comment">/* type=0 */</span>
- <a name="l00259"></a>00259 | FLUID_MOD_BIPOLAR <span class="comment">/* P=1 */</span>
- <a name="l00260"></a>00260 | FLUID_MOD_POSITIVE <span class="comment">/* D=0 */</span>
- <a name="l00261"></a>00261 );
- <a name="l00262"></a>00262 fluid_mod_set_source2(&default_pan_mod, 0, 0); <span class="comment">/* No second source */</span>
- <a name="l00263"></a>00263 fluid_mod_set_dest(&default_pan_mod, <a class="code" href="gen_8h.html#d17a24ae3b25f3b8cc5762f818eef9b45b713ab8c931017d98f11b5ed5a81fb1" title="Stereo panning.">GEN_PAN</a>); <span class="comment">/* Target: pan */</span>
- <a name="l00264"></a>00264 <span class="comment">/* Amount: 500. The SF specs $8.4.6, p. 55 syas: "Amount = 1000</span>
- <a name="l00265"></a>00265 <span class="comment"> tenths of a percent". The center value (64) corresponds to 50%,</span>
- <a name="l00266"></a>00266 <span class="comment"> so it follows that amount = 50% x 1000/% = 500. */</span>
- <a name="l00267"></a>00267 fluid_mod_set_amount(&default_pan_mod, 500.0);
- <a name="l00268"></a>00268
- <a name="l00269"></a>00269
- <a name="l00270"></a>00270 <span class="comment">/* SF2.01 page 55 section 8.4.7: MIDI continuous controller 11 to initial attenuation*/</span>
- <a name="l00271"></a>00271 fluid_mod_set_source1(&default_expr_mod, 11, <span class="comment">/* index=11 */</span>
- <a name="l00272"></a>00272 FLUID_MOD_CC <span class="comment">/* CC=1 */</span>
- <a name="l00273"></a>00273 | FLUID_MOD_CONCAVE <span class="comment">/* type=1 */</span>
- <a name="l00274"></a>00274 | FLUID_MOD_UNIPOLAR <span class="comment">/* P=0 */</span>
- <a name="l00275"></a>00275 | FLUID_MOD_NEGATIVE <span class="comment">/* D=1 */</span>
- <a name="l00276"></a>00276 );
- <a name="l00277"></a>00277 fluid_mod_set_source2(&default_expr_mod, 0, 0); <span class="comment">/* No second source */</span>
- <a name="l00278"></a>00278 fluid_mod_set_dest(&default_expr_mod, <a class="code" href="gen_8h.html#d17a24ae3b25f3b8cc5762f818eef9b42db65ad593aeff4e814f9a7b7324c0df" title="Initial volume attenuation.">GEN_ATTENUATION</a>); <span class="comment">/* Target: Initial attenuation */</span>
- <a name="l00279"></a>00279 fluid_mod_set_amount(&default_expr_mod, 960.0); <span class="comment">/* Amount: 960 */</span>
- <a name="l00280"></a>00280
- <a name="l00281"></a>00281
- <a name="l00282"></a>00282
- <a name="l00283"></a>00283 <span class="comment">/* SF2.01 page 55 section 8.4.8: MIDI continuous controller 91 to Reverb send */</span>
- <a name="l00284"></a>00284 fluid_mod_set_source1(&default_reverb_mod, 91, <span class="comment">/* index=91 */</span>
- <a name="l00285"></a>00285 FLUID_MOD_CC <span class="comment">/* CC=1 */</span>
- <a name="l00286"></a>00286 | FLUID_MOD_LINEAR <span class="comment">/* type=0 */</span>
- <a name="l00287"></a>00287 | FLUID_MOD_UNIPOLAR <span class="comment">/* P=0 */</span>
- <a name="l00288"></a>00288 | FLUID_MOD_POSITIVE <span class="comment">/* D=0 */</span>
- <a name="l00289"></a>00289 );
- <a name="l00290"></a>00290 fluid_mod_set_source2(&default_reverb_mod, 0, 0); <span class="comment">/* No second source */</span>
- <a name="l00291"></a>00291 fluid_mod_set_dest(&default_reverb_mod, <a class="code" href="gen_8h.html#d17a24ae3b25f3b8cc5762f818eef9b48de830acd064933f55e0c1615d1e7f78" title="Reverb send amount.">GEN_REVERBSEND</a>); <span class="comment">/* Target: Reverb send */</span>
- <a name="l00292"></a>00292 fluid_mod_set_amount(&default_reverb_mod, 200); <span class="comment">/* Amount: 200 ('tenths of a percent') */</span>
- <a name="l00293"></a>00293
- <a name="l00294"></a>00294
- <a name="l00295"></a>00295
- <a name="l00296"></a>00296 <span class="comment">/* SF2.01 page 55 section 8.4.9: MIDI continuous controller 93 to Reverb send */</span>
- <a name="l00297"></a>00297 fluid_mod_set_source1(&default_chorus_mod, 93, <span class="comment">/* index=93 */</span>
- <a name="l00298"></a>00298 FLUID_MOD_CC <span class="comment">/* CC=1 */</span>
- <a name="l00299"></a>00299 | FLUID_MOD_LINEAR <span class="comment">/* type=0 */</span>
- <a name="l00300"></a>00300 | FLUID_MOD_UNIPOLAR <span class="comment">/* P=0 */</span>
- <a name="l00301"></a>00301 | FLUID_MOD_POSITIVE <span class="comment">/* D=0 */</span>
- <a name="l00302"></a>00302 );
- <a name="l00303"></a>00303 fluid_mod_set_source2(&default_chorus_mod, 0, 0); <span class="comment">/* No second source */</span>
- <a name="l00304"></a>00304 fluid_mod_set_dest(&default_chorus_mod, <a class="code" href="gen_8h.html#d17a24ae3b25f3b8cc5762f818eef9b420dc580d6c53d30eb97efe3e910793b6" title="Chorus send amount.">GEN_CHORUSSEND</a>); <span class="comment">/* Target: Chorus */</span>
- <a name="l00305"></a>00305 fluid_mod_set_amount(&default_chorus_mod, 200); <span class="comment">/* Amount: 200 ('tenths of a percent') */</span>
- <a name="l00306"></a>00306
- <a name="l00307"></a>00307
- <a name="l00308"></a>00308
- <a name="l00309"></a>00309 <span class="comment">/* SF2.01 page 57 section 8.4.10 MIDI Pitch Wheel to Initial Pitch ... */</span>
- <a name="l00310"></a>00310 fluid_mod_set_source1(&default_pitch_bend_mod, FLUID_MOD_PITCHWHEEL, <span class="comment">/* Index=14 */</span>
- <a name="l00311"></a>00311 FLUID_MOD_GC <span class="comment">/* CC =0 */</span>
- <a name="l00312"></a>00312 | FLUID_MOD_LINEAR <span class="comment">/* type=0 */</span>
- <a name="l00313"></a>00313 | FLUID_MOD_BIPOLAR <span class="comment">/* P=1 */</span>
- <a name="l00314"></a>00314 | FLUID_MOD_POSITIVE <span class="comment">/* D=0 */</span>
- <a name="l00315"></a>00315 );
- <a name="l00316"></a>00316 fluid_mod_set_source2(&default_pitch_bend_mod, FLUID_MOD_PITCHWHEELSENS, <span class="comment">/* Index = 16 */</span>
- <a name="l00317"></a>00317 FLUID_MOD_GC <span class="comment">/* CC=0 */</span>
- <a name="l00318"></a>00318 | FLUID_MOD_LINEAR <span class="comment">/* type=0 */</span>
- <a name="l00319"></a>00319 | FLUID_MOD_UNIPOLAR <span class="comment">/* P=0 */</span>
- <a name="l00320"></a>00320 | FLUID_MOD_POSITIVE <span class="comment">/* D=0 */</span>
- <a name="l00321"></a>00321 );
- <a name="l00322"></a>00322 fluid_mod_set_dest(&default_pitch_bend_mod, <a class="code" href="gen_8h.html#d17a24ae3b25f3b8cc5762f818eef9b4b9a5716b5af1baf131a6225da6687ff0" title="Pitch (NOTE: Not a real SoundFont generator).">GEN_PITCH</a>); <span class="comment">/* Destination: Initial pitch */</span>
- <a name="l00323"></a>00323 fluid_mod_set_amount(&default_pitch_bend_mod, 12700.0); <span class="comment">/* Amount: 12700 cents */</span>
- <a name="l00324"></a>00324 }
- <a name="l00325"></a>00325
- <a name="l00326"></a>00326
- <a name="l00327"></a>00327 <span class="keywordtype">int</span> fluid_synth_verify_settings(fluid_settings_t *settings)
- <a name="l00328"></a>00328 {
- <a name="l00329"></a>00329 <span class="keywordflow">return</span> 0;
- <a name="l00330"></a>00330 }
- <a name="l00331"></a>00331
- <a name="l00332"></a>00332 <span class="comment">/***************************************************************</span>
- <a name="l00333"></a>00333 <span class="comment"> *</span>
- <a name="l00334"></a>00334 <span class="comment"> * FLUID SYNTH</span>
- <a name="l00335"></a>00335 <span class="comment"> */</span>
- <a name="l00336"></a>00336
- <a name="l00337"></a>00337 <span class="comment">/*</span>
- <a name="l00338"></a>00338 <span class="comment"> * new_fluid_synth</span>
- <a name="l00339"></a>00339 <span class="comment"> */</span>
- <a name="l00340"></a>00340 fluid_synth_t*
- <a name="l00341"></a>00341 new_fluid_synth(fluid_settings_t *settings)
- <a name="l00342"></a>00342 {
- <a name="l00343"></a>00343 <span class="keywordtype">int</span> i;
- <a name="l00344"></a>00344 fluid_synth_t* synth;
- <a name="l00345"></a>00345 <a class="code" href="struct__fluid__sfloader__t.html">fluid_sfloader_t</a>* loader;
- <a name="l00346"></a>00346
- <a name="l00347"></a>00347 <span class="comment">/* initialize all the conversion tables and other stuff */</span>
- <a name="l00348"></a>00348 <span class="keywordflow">if</span> (fluid_synth_initialized == 0) {
- <a name="l00349"></a>00349 fluid_synth_init();
- <a name="l00350"></a>00350 }
- <a name="l00351"></a>00351
- <a name="l00352"></a>00352 fluid_synth_verify_settings(settings);
- <a name="l00353"></a>00353
- <a name="l00354"></a>00354 <span class="comment">/* allocate a new synthesizer object */</span>
- <a name="l00355"></a>00355 synth = FLUID_NEW(fluid_synth_t);
- <a name="l00356"></a>00356 <span class="keywordflow">if</span> (synth == NULL) {
- <a name="l00357"></a>00357 FLUID_LOG(<a class="code" href="log_8h.html#a341232c15addd9c336131984840ed9ebc0ff48d192b3b0fc721946ccf095d25" title="Serious error occurred.">FLUID_ERR</a>, <span class="stringliteral">"Out of memory"</span>);
- <a name="l00358"></a>00358 <span class="keywordflow">return</span> NULL;
- <a name="l00359"></a>00359 }
- <a name="l00360"></a>00360 FLUID_MEMSET(synth, 0, <span class="keyword">sizeof</span>(fluid_synth_t));
- <a name="l00361"></a>00361
- <a name="l00362"></a>00362 fluid_mutex_init(synth->busy);
- <a name="l00363"></a>00363
- <a name="l00364"></a>00364 synth->settings = settings;
- <a name="l00365"></a>00365
- <a name="l00366"></a>00366 synth->with_reverb = fluid_settings_str_equal(settings, <span class="stringliteral">"synth.reverb.active"</span>, <span class="stringliteral">"yes"</span>);
- <a name="l00367"></a>00367 synth->with_chorus = fluid_settings_str_equal(settings, <span class="stringliteral">"synth.chorus.active"</span>, <span class="stringliteral">"yes"</span>);
- <a name="l00368"></a>00368 synth->verbose = fluid_settings_str_equal(settings, <span class="stringliteral">"synth.verbose"</span>, <span class="stringliteral">"yes"</span>);
- <a name="l00369"></a>00369 synth->dump = fluid_settings_str_equal(settings, <span class="stringliteral">"synth.dump"</span>, <span class="stringliteral">"yes"</span>);
- <a name="l00370"></a>00370
- <a name="l00371"></a>00371 fluid_settings_getint(settings, <span class="stringliteral">"synth.polyphony"</span>, &synth->polyphony);
- <a name="l00372"></a>00372 fluid_settings_getnum(settings, <span class="stringliteral">"synth.sample-rate"</span>, &synth->sample_rate);
- <a name="l00373"></a>00373 fluid_settings_getint(settings, <span class="stringliteral">"synth.midi-channels"</span>, &synth->midi_channels);
- <a name="l00374"></a>00374 fluid_settings_getint(settings, <span class="stringliteral">"synth.audio-channels"</span>, &synth->audio_channels);
- <a name="l00375"></a>00375 fluid_settings_getint(settings, <span class="stringliteral">"synth.audio-groups"</span>, &synth->audio_groups);
- <a name="l00376"></a>00376 fluid_settings_getint(settings, <span class="stringliteral">"synth.effects-channels"</span>, &synth->effects_channels);
- <a name="l00377"></a>00377 fluid_settings_getnum(settings, <span class="stringliteral">"synth.gain"</span>, &synth->gain);
- <a name="l00378"></a>00378
- <a name="l00379"></a>00379 <span class="comment">/* register the callbacks */</span>
- <a name="l00380"></a>00380 fluid_settings_register_num(settings, <span class="stringliteral">"synth.gain"</span>,
- <a name="l00381"></a>00381 0.2f, 0.0f, 10.0f, 0,
- <a name="l00382"></a>00382 (fluid_num_update_t) fluid_synth_update_gain, synth);
- <a name="l00383"></a>00383 fluid_settings_register_int(settings, <span class="stringliteral">"synth.polyphony"</span>,
- <a name="l00384"></a>00384 synth->polyphony, 16, 4096, 0,
- <a name="l00385"></a>00385 (fluid_int_update_t) fluid_synth_update_polyphony,
- <a name="l00386"></a>00386 synth);
- <a name="l00387"></a>00387
- <a name="l00388"></a>00388 <span class="comment">/* do some basic sanity checking on the settings */</span>
- <a name="l00389"></a>00389
- <a name="l00390"></a>00390 <span class="keywordflow">if</span> (synth->midi_channels % 16 != 0) {
- <a name="l00391"></a>00391 <span class="keywordtype">int</span> n = synth->midi_channels / 16;
- <a name="l00392"></a>00392 synth->midi_channels = (n + 1) * 16;
- <a name="l00393"></a>00393 fluid_settings_setint(settings, <span class="stringliteral">"synth.midi-channels"</span>, synth->midi_channels);
- <a name="l00394"></a>00394 FLUID_LOG(<a class="code" href="log_8h.html#a341232c15addd9c336131984840ed9e394460be1ec74fce15e1ff683606df0f" title="Warning.">FLUID_WARN</a>, <span class="stringliteral">"Requested number of MIDI channels is not a multiple of 16. "</span>
- <a name="l00395"></a>00395 <span class="stringliteral">"I'll increase the number of channels to the next multiple."</span>);
- <a name="l00396"></a>00396 }
- <a name="l00397"></a>00397
- <a name="l00398"></a>00398 <span class="keywordflow">if</span> (synth->audio_channels < 1) {
- <a name="l00399"></a>00399 FLUID_LOG(<a class="code" href="log_8h.html#a341232c15addd9c336131984840ed9e394460be1ec74fce15e1ff683606df0f" title="Warning.">FLUID_WARN</a>, <span class="stringliteral">"Requested number of audio channels is smaller than 1. "</span>
- <a name="l00400"></a>00400 <span class="stringliteral">"Changing this setting to 1."</span>);
- <a name="l00401"></a>00401 synth->audio_channels = 1;
- <a name="l00402"></a>00402 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (synth->audio_channels > 128) {
- <a name="l00403"></a>00403 FLUID_LOG(<a class="code" href="log_8h.html#a341232c15addd9c336131984840ed9e394460be1ec74fce15e1ff683606df0f" title="Warning.">FLUID_WARN</a>, <span class="stringliteral">"Requested number of audio channels is too big (%d). "</span>
- <a name="l00404"></a>00404 <span class="stringliteral">"Limiting this setting to 128."</span>, synth->audio_channels);
- <a name="l00405"></a>00405 synth->audio_channels = 128;
- <a name="l00406"></a>00406 }
- <a name="l00407"></a>00407
- <a name="l00408"></a>00408 <span class="keywordflow">if</span> (synth->audio_groups < 1) {
- <a name="l00409"></a>00409 FLUID_LOG(<a class="code" href="log_8h.html#a341232c15addd9c336131984840ed9e394460be1ec74fce15e1ff683606df0f" title="Warning.">FLUID_WARN</a>, <span class="stringliteral">"Requested number of audio groups is smaller than 1. "</span>
- <a name="l00410"></a>00410 <span class="stringliteral">"Changing this setting to 1."</span>);
- <a name="l00411"></a>00411 synth->audio_groups = 1;
- <a name="l00412"></a>00412 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (synth->audio_groups > 128) {
- <a name="l00413"></a>00413 FLUID_LOG(<a class="code" href="log_8h.html#a341232c15addd9c336131984840ed9e394460be1ec74fce15e1ff683606df0f" title="Warning.">FLUID_WARN</a>, <span class="stringliteral">"Requested number of audio groups is too big (%d). "</span>
- <a name="l00414"></a>00414 <span class="stringliteral">"Limiting this setting to 128."</span>, synth->audio_groups);
- <a name="l00415"></a>00415 synth->audio_groups = 128;
- <a name="l00416"></a>00416 }
- <a name="l00417"></a>00417
- <a name="l00418"></a>00418 <span class="keywordflow">if</span> (synth->effects_channels != 2) {
- <a name="l00419"></a>00419 FLUID_LOG(<a class="code" href="log_8h.html#a341232c15addd9c336131984840ed9e394460be1ec74fce15e1ff683606df0f" title="Warning.">FLUID_WARN</a>, <span class="stringliteral">"Invalid number of effects channels (%d)."</span>
- <a name="l00420"></a>00420 <span class="stringliteral">"Setting effects channels to 2."</span>, synth->effects_channels);
- <a name="l00421"></a>00421 synth->effects_channels = 2;
- <a name="l00422"></a>00422 }
- <a name="l00423"></a>00423
- <a name="l00424"></a>00424
- <a name="l00425"></a>00425 <span class="comment">/* The number of buffers is determined by the higher number of nr</span>
- <a name="l00426"></a>00426 <span class="comment"> * groups / nr audio channels. If LADSPA is unused, they should be</span>
- <a name="l00427"></a>00427 <span class="comment"> * the same. */</span>
- <a name="l00428"></a>00428 synth->nbuf = synth->audio_channels;
- <a name="l00429"></a>00429 <span class="keywordflow">if</span> (synth->audio_groups > synth->nbuf) {
- <a name="l00430"></a>00430 synth->nbuf = synth->audio_groups;
- <a name="l00431"></a>00431 }
- <a name="l00432"></a>00432
- <a name="l00433"></a>00433 <span class="preprocessor">#ifdef LADSPA</span>
- <a name="l00434"></a>00434 <span class="preprocessor"></span> <span class="comment">/* Create and initialize the Fx unit.*/</span>
- <a name="l00435"></a>00435 synth->LADSPA_FxUnit = new_fluid_LADSPA_FxUnit(synth);
- <a name="l00436"></a>00436 <span class="preprocessor">#endif</span>
- <a name="l00437"></a>00437 <span class="preprocessor"></span>
- <a name="l00438"></a>00438 <span class="comment">/* as soon as the synth is created it starts playing. */</span>
- <a name="l00439"></a>00439 synth->state = FLUID_SYNTH_PLAYING;
- <a name="l00440"></a>00440 synth->sfont = NULL;
- <a name="l00441"></a>00441 synth->noteid = 0;
- <a name="l00442"></a>00442 synth->ticks = 0;
- <a name="l00443"></a>00443 synth->tuning = NULL;
- <a name="l00444"></a>00444
- <a name="l00445"></a>00445 <span class="comment">/* allocate and add the default sfont loader */</span>
- <a name="l00446"></a>00446 loader = new_fluid_defsfloader();
- <a name="l00447"></a>00447
- <a name="l00448"></a>00448 <span class="keywordflow">if</span> (loader == NULL) {
- <a name="l00449"></a>00449 FLUID_LOG(<a class="code" href="log_8h.html#a341232c15addd9c336131984840ed9e394460be1ec74fce15e1ff683606df0f" title="Warning.">FLUID_WARN</a>, <span class="stringliteral">"Failed to create the default SoundFont loader"</span>);
- <a name="l00450"></a>00450 } <span class="keywordflow">else</span> {
- <a name="l00451"></a>00451 fluid_synth_add_sfloader(synth, loader);
- <a name="l00452"></a>00452 }
- <a name="l00453"></a>00453
- <a name="l00454"></a>00454 <span class="comment">/* allocate all channel objects */</span>
- <a name="l00455"></a>00455 synth->channel = FLUID_ARRAY(fluid_channel_t*, synth->midi_channels);
- <a name="l00456"></a>00456 <span class="keywordflow">if</span> (synth->channel == NULL) {
- <a name="l00457"></a>00457 FLUID_LOG(<a class="code" href="log_8h.html#a341232c15addd9c336131984840ed9ebc0ff48d192b3b0fc721946ccf095d25" title="Serious error occurred.">FLUID_ERR</a>, <span class="stringliteral">"Out of memory"</span>);
- <a name="l00458"></a>00458 <span class="keywordflow">goto</span> error_recovery;
- <a name="l00459"></a>00459 }
- <a name="l00460"></a>00460 <span class="keywordflow">for</span> (i = 0; i < synth->midi_channels; i++) {
- <a name="l00461"></a>00461 synth->channel[i] = new_fluid_channel(synth, i);
- <a name="l00462"></a>00462 <span class="keywordflow">if</span> (synth->channel[i] == NULL) {
- <a name="l00463"></a>00463 <span class="keywordflow">goto</span> error_recovery;
- <a name="l00464"></a>00464 }
- <a name="l00465"></a>00465 }
- <a name="l00466"></a>00466
- <a name="l00467"></a>00467 <span class="comment">/* allocate all synthesis processes */</span>
- <a name="l00468"></a>00468 synth->nvoice = synth->polyphony;
- <a name="l00469"></a>00469 synth->voice = FLUID_ARRAY(fluid_voice_t*, synth->nvoice);
- <a name="l00470"></a>00470 <span class="keywordflow">if</span> (synth->voice == NULL) {
- <a name="l00471"></a>00471 <span class="keywordflow">goto</span> error_recovery;
- <a name="l00472"></a>00472 }
- <a name="l00473"></a>00473 <span class="keywordflow">for</span> (i = 0; i < synth->nvoice; i++) {
- <a name="l00474"></a>00474 synth->voice[i] = new_fluid_voice(synth->sample_rate);
- <a name="l00475"></a>00475 <span class="keywordflow">if</span> (synth->voice[i] == NULL) {
- <a name="l00476"></a>00476 <span class="keywordflow">goto</span> error_recovery;
- <a name="l00477"></a>00477 }
- <a name="l00478"></a>00478 }
- <a name="l00479"></a>00479
- <a name="l00480"></a>00480 <span class="comment">/* Allocate the sample buffers */</span>
- <a name="l00481"></a>00481 synth->left_buf = NULL;
- <a name="l00482"></a>00482 synth->right_buf = NULL;
- <a name="l00483"></a>00483 synth->fx_left_buf = NULL;
- <a name="l00484"></a>00484 synth->fx_right_buf = NULL;
- <a name="l00485"></a>00485
- <a name="l00486"></a>00486 <span class="comment">/* Left and right audio buffers */</span>
- <a name="l00487"></a>00487
- <a name="l00488"></a>00488 synth->left_buf = FLUID_ARRAY(fluid_real_t*, synth->nbuf);
- <a name="l00489"></a>00489 synth->right_buf = FLUID_ARRAY(fluid_real_t*, synth->nbuf);
- <a name="l00490"></a>00490
- <a name="l00491"></a>00491 <span class="keywordflow">if</span> ((synth->left_buf == NULL) || (synth->right_buf == NULL)) {
- <a name="l00492"></a>00492 FLUID_LOG(<a class="code" href="log_8h.html#a341232c15addd9c336131984840ed9ebc0ff48d192b3b0fc721946ccf095d25" title="Serious error occurred.">FLUID_ERR</a>, <span class="stringliteral">"Out of memory"</span>);
- <a name="l00493"></a>00493 <span class="keywordflow">goto</span> error_recovery;
- <a name="l00494"></a>00494 }
- <a name="l00495"></a>00495
- <a name="l00496"></a>00496 FLUID_MEMSET(synth->left_buf, 0, synth->nbuf * <span class="keyword">sizeof</span>(fluid_real_t*));
- <a name="l00497"></a>00497 FLUID_MEMSET(synth->right_buf, 0, synth->nbuf * <span class="keyword">sizeof</span>(fluid_real_t*));
- <a name="l00498"></a>00498
- <a name="l00499"></a>00499 <span class="keywordflow">for</span> (i = 0; i < synth->nbuf; i++) {
- <a name="l00500"></a>00500
- <a name="l00501"></a>00501 synth->left_buf[i] = FLUID_ARRAY(fluid_real_t, FLUID_BUFSIZE);
- <a name="l00502"></a>00502 synth->right_buf[i] = FLUID_ARRAY(fluid_real_t, FLUID_BUFSIZE);
- <a name="l00503"></a>00503
- <a name="l00504"></a>00504 <span class="keywordflow">if</span> ((synth->left_buf[i] == NULL) || (synth->right_buf[i] == NULL)) {
- <a name="l00505"></a>00505 FLUID_LOG(<a class="code" href="log_8h.html#a341232c15addd9c336131984840ed9ebc0ff48d192b3b0fc721946ccf095d25" title="Serious error occurred.">FLUID_ERR</a>, <span class="stringli…
Large files files are truncated, but you can click here to view the full file