src/fluid_seqbind.c

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 
00022 
00023 /*
00024  2002 : API design by Peter Hanappe and Antoine Schmitt
00025  August 2002 : Implementation by Antoine Schmitt as@gratin.org
00026                as part of the infiniteCD author project
00027                http://www.infiniteCD.org/
00028 */
00029 
00030 #include "fluidsynth_priv.h"
00031 
00032  /***************************************************************
00033  *
00034  *                           SEQUENCER BINDING
00035  */
00036 
00037 void fluid_seq_fluidsynth_callback(unsigned int time, fluid_event_t* event, fluid_sequencer_t* seq, void* data);
00038 
00039 /* registering the synth */
00040 short fluid_sequencer_register_fluidsynth(fluid_sequencer_t* seq, fluid_synth_t* synth)
00041 {
00042         /* register fluidsynth itself */
00043         return fluid_sequencer_register_client(seq, "fluidsynth", fluid_seq_fluidsynth_callback, (void *)synth);
00044 }
00045 
00046 /* the callback itself */
00047 void fluid_seq_fluidsynth_callback(unsigned int time, fluid_event_t* evt, fluid_sequencer_t* seq, void* data)
00048 {
00049         fluid_synth_t* synth = (fluid_synth_t *)data;
00050 
00051   switch (fluid_event_get_type(evt)) {
00052 
00053   case FLUID_SEQ_NOTEON:
00054         fluid_synth_noteon(synth, fluid_event_get_channel(evt), fluid_event_get_key(evt), fluid_event_get_velocity(evt));
00055         break;
00056 
00057   case FLUID_SEQ_NOTEOFF:
00058         fluid_synth_noteoff(synth, fluid_event_get_channel(evt), fluid_event_get_key(evt));
00059         break;
00060 
00061   case FLUID_SEQ_NOTE:
00062           {
00063                 unsigned int dur;
00064                 fluid_synth_noteon(synth, fluid_event_get_channel(evt), fluid_event_get_key(evt), fluid_event_get_velocity(evt));
00065                 dur = fluid_event_get_duration(evt);
00066                 fluid_event_noteoff(evt, fluid_event_get_channel(evt), fluid_event_get_key(evt));
00067                 fluid_sequencer_send_at(seq, evt, dur, 0);
00068           }
00069         break;
00070 
00071         case FLUID_SEQ_ALLSOUNDSOFF:
00072                 /* NYI */
00073         break;
00074 
00075   case FLUID_SEQ_ALLNOTESOFF:
00076         fluid_synth_cc(synth, fluid_event_get_channel(evt), 0x7B, 0);
00077         break;
00078 
00079   case FLUID_SEQ_BANKSELECT:
00080         fluid_synth_bank_select(synth, fluid_event_get_channel(evt), fluid_event_get_bank(evt));
00081         break;
00082 
00083   case FLUID_SEQ_PROGRAMCHANGE:
00084         fluid_synth_program_change(synth, fluid_event_get_channel(evt), fluid_event_get_program(evt));
00085         break;
00086 
00087   case FLUID_SEQ_PROGRAMSELECT:
00088         fluid_synth_program_select(synth, fluid_event_get_channel(evt), fluid_event_get_sfont_id(evt),
00089                 fluid_event_get_bank(evt), fluid_event_get_program(evt));
00090         break;
00091 
00092   case FLUID_SEQ_ANYCONTROLCHANGE:
00093         /* nothing = only used by remove_events */
00094         break;
00095 
00096   case FLUID_SEQ_PITCHBEND:
00097         fluid_synth_pitch_bend(synth, fluid_event_get_channel(evt), fluid_event_get_pitch(evt));
00098         break;
00099 
00100   case FLUID_SEQ_PITCHWHHELSENS:
00101         fluid_synth_pitch_wheel_sens(synth, fluid_event_get_channel(evt), fluid_event_get_value(evt));
00102         break;
00103 
00104   case FLUID_SEQ_CONTROLCHANGE:
00105          fluid_synth_cc(synth, fluid_event_get_channel(evt), fluid_event_get_control(evt), fluid_event_get_value(evt));
00106         break;
00107 
00108   case FLUID_SEQ_MODULATION:
00109           {
00110                 short ctrl = 0x01;      // MODULATION_MSB
00111                 fluid_synth_cc(synth, fluid_event_get_channel(evt), ctrl, fluid_event_get_value(evt));
00112           }
00113         break;
00114 
00115   case FLUID_SEQ_SUSTAIN:
00116           {
00117                 short ctrl = 0x40;      // SUSTAIN_SWITCH
00118                 fluid_synth_cc(synth, fluid_event_get_channel(evt), ctrl, fluid_event_get_value(evt));
00119           }
00120         break;
00121 
00122   case FLUID_SEQ_PAN:
00123           {
00124                 short ctrl = 0x0A;      // PAN_MSB
00125                 fluid_synth_cc(synth, fluid_event_get_channel(evt), ctrl, fluid_event_get_value(evt));
00126           }
00127         break;
00128 
00129   case FLUID_SEQ_VOLUME:
00130           {
00131                 short ctrl = 0x07;      // VOLUME_MSB
00132                 fluid_synth_cc(synth, fluid_event_get_channel(evt), ctrl, fluid_event_get_value(evt));
00133           }
00134         break;
00135 
00136   case FLUID_SEQ_REVERBSEND:
00137           {
00138                 short ctrl = 0x5B;      // EFFECTS_DEPTH1
00139                 fluid_synth_cc(synth, fluid_event_get_channel(evt), ctrl, fluid_event_get_value(evt));
00140           }
00141         break;
00142 
00143   case FLUID_SEQ_CHORUSSEND:
00144           {
00145                 short ctrl = 0x5D;      // EFFECTS_DEPTH3
00146                 fluid_synth_cc(synth, fluid_event_get_channel(evt), ctrl, fluid_event_get_value(evt));
00147           }
00148         break;
00149 
00150   case FLUID_SEQ_TIMER:
00151           /* nothing in fluidsynth */
00152         break;
00153 
00154         default:
00155         break;
00156         }
00157 }
00158 
00159 

Generated on Sat Nov 17 13:40:23 2007 for libfluidsynth by  doxygen 1.5.3