00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "fluidsynth_priv.h"
00031
00032
00033
00034
00035
00036
00037 void fluid_seq_fluidsynth_callback(unsigned int time, fluid_event_t* event, fluid_sequencer_t* seq, void* data);
00038
00039
00040 short fluid_sequencer_register_fluidsynth(fluid_sequencer_t* seq, fluid_synth_t* synth)
00041 {
00042
00043 return fluid_sequencer_register_client(seq, "fluidsynth", fluid_seq_fluidsynth_callback, (void *)synth);
00044 }
00045
00046
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
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
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;
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;
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;
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;
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;
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;
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
00152 break;
00153
00154 default:
00155 break;
00156 }
00157 }
00158
00159