OSDN Git Service

Change around extension.
authorSaito <saito2@digitalme.com>
Thu, 26 Feb 2004 07:33:43 +0000 (07:33 +0000)
committerSaito <saito2@digitalme.com>
Thu, 26 Feb 2004 07:33:43 +0000 (07:33 +0000)
timidity/instrum.c
timidity/instrum.h
timidity/mix.c
timidity/playmidi.c
timidity/playmidi.h
timidity/timidity.c

index 266f7b3..5dafcfd 100644 (file)
@@ -479,6 +479,58 @@ static void apply_bank_parameter(Instrument *ip, ToneBankElement *tone)
                                                                to_offset(tone->modenvofs[i][j]);
                        }
                }
+       if (tone->envkeyfnum)
+               for (i = 0; i < ip->samples; i++) {
+                       sp = &ip->sample[i];
+                       if (tone->envkeyfnum == 1) {
+                               for (j = 0; j < 6; j++)
+                                       if (tone->envkeyf[0][j] != -1)
+                                               sp->envelope_keyf[j] = tone->envkeyf[0][j];
+                       } else if (i < tone->envkeyfnum) {
+                               for (j = 0; j < 6; j++)
+                                       if (tone->envkeyf[i][j] != -1)
+                                               sp->envelope_keyf[j] = tone->envkeyf[i][j];
+                       }
+               }
+       if (tone->modenvkeyfnum)
+               for (i = 0; i < ip->samples; i++) {
+                       sp = &ip->sample[i];
+                       if (tone->modenvkeyfnum == 1) {
+                               for (j = 0; j < 6; j++)
+                                       if (tone->modenvkeyf[0][j] != -1)
+                                               sp->modenv_keyf[j] = tone->modenvkeyf[0][j];
+                       } else if (i < tone->modenvkeyfnum) {
+                               for (j = 0; j < 6; j++)
+                                       if (tone->modenvkeyf[i][j] != -1)
+                                               sp->modenv_keyf[j] = tone->modenvkeyf[i][j];
+                       }
+               }
+       if (tone->modenvvelfnum)
+               for (i = 0; i < ip->samples; i++) {
+                       sp = &ip->sample[i];
+                       if (tone->modenvvelfnum == 1) {
+                               for (j = 0; j < 6; j++)
+                                       if (tone->modenvvelf[0][j] != -1)
+                                               sp->modenv_velf[j] = tone->modenvvelf[0][j];
+                       } else if (i < tone->modenvvelfnum) {
+                               for (j = 0; j < 6; j++)
+                                       if (tone->modenvvelf[i][j] != -1)
+                                               sp->modenv_velf[j] = tone->modenvvelf[i][j];
+                       }
+               }
+       if (tone->envvelfnum)
+               for (i = 0; i < ip->samples; i++) {
+                       sp = &ip->sample[i];
+                       if (tone->envvelfnum == 1) {
+                               for (j = 0; j < 6; j++)
+                                       if (tone->envvelf[0][j] != -1)
+                                               sp->envelope_velf[j] = tone->envvelf[0][j];
+                       } else if (i < tone->envvelfnum) {
+                               for (j = 0; j < 6; j++)
+                                       if (tone->envvelf[i][j] != -1)
+                                               sp->envelope_velf[j] = tone->envvelf[i][j];
+                       }
+               }
        if (tone->trempitchnum)
                for (i = 0; i < ip->samples; i++) {
                        sp = &ip->sample[i];
@@ -598,6 +650,8 @@ static Instrument *load_gus_instrument(char *name,
                        && tone->tremnum == 0 && tone->vibnum == 0
                        && tone->sclnotenum == 0 && tone->scltunenum == 0
                        && tone->modenvratenum == 0 && tone->modenvofsnum == 0
+                       && tone->modenvkeyfnum == 0 && tone->modenvvelfnum == 0
+                       && tone->envkeyfnum == 0 && tone->envvelfnum == 0
                        && tone->trempitchnum == 0 && tone->tremfcnum == 0
                        && tone->modpitchnum == 0 && tone->modfcnum == 0
                        && tone->fcnum == 0 && tone->resonum == 0)
@@ -1236,6 +1290,34 @@ void copy_tone_bank_element(ToneBankElement *elm, const ToneBankElement *src)
                        elm->modenvofs[i] = (int *) safe_memdup(elm->modenvofs[i],
                                        6 * sizeof(int));
        }
+       if (elm->envkeyfnum) {
+               elm->envkeyf = (int **) safe_memdup(elm->envkeyf,
+                               elm->envkeyfnum * sizeof(int *));
+               for (i = 0; i < elm->envkeyfnum; i++)
+                       elm->envkeyf[i] = (int *) safe_memdup(elm->envkeyf[i],
+                                       6 * sizeof(int));
+       }
+       if (elm->envvelfnum) {
+               elm->envvelf = (int **) safe_memdup(elm->envvelf,
+                               elm->envvelfnum * sizeof(int *));
+               for (i = 0; i < elm->envvelfnum; i++)
+                       elm->envvelf[i] = (int *) safe_memdup(elm->envvelf[i],
+                                       6 * sizeof(int));
+       }
+       if (elm->modenvkeyfnum) {
+               elm->modenvkeyf = (int **) safe_memdup(elm->modenvkeyf,
+                               elm->modenvkeyfnum * sizeof(int *));
+               for (i = 0; i < elm->modenvkeyfnum; i++)
+                       elm->modenvkeyf[i] = (int *) safe_memdup(elm->modenvkeyf[i],
+                                       6 * sizeof(int));
+       }
+       if (elm->modenvvelfnum) {
+               elm->modenvvelf = (int **) safe_memdup(elm->modenvvelf,
+                               elm->modenvvelfnum * sizeof(int *));
+               for (i = 0; i < elm->modenvvelfnum; i++)
+                       elm->modenvvelf[i] = (int *) safe_memdup(elm->modenvvelf[i],
+                                       6 * sizeof(int));
+       }
        if (elm->trempitchnum)
                elm->trempitch = (int16 *) safe_memdup(elm->trempitch,
                                elm->trempitchnum * sizeof(int16));
@@ -1322,6 +1404,18 @@ void free_tone_bank_element(ToneBankElement *elm)
        if (elm->modenvofsnum)
                free_ptr_list(elm->modenvofs, elm->modenvofsnum);
        elm->modenvofs = NULL, elm->modenvofsnum = 0;
+       if (elm->envkeyfnum)
+               free_ptr_list(elm->envkeyf, elm->envkeyfnum);
+       elm->envkeyf = NULL, elm->envkeyfnum = 0;
+       if (elm->envvelfnum)
+               free_ptr_list(elm->envvelf, elm->envvelfnum);
+       elm->envvelf = NULL, elm->envvelfnum = 0;
+       if (elm->modenvkeyfnum)
+               free_ptr_list(elm->modenvkeyf, elm->modenvkeyfnum);
+       elm->modenvkeyf = NULL, elm->modenvkeyfnum = 0;
+       if (elm->modenvvelfnum)
+               free_ptr_list(elm->modenvvelf, elm->modenvvelfnum);
+       elm->modenvvelf = NULL, elm->modenvvelfnum = 0;
        if (elm->trempitch)
                free(elm->trempitch);
        elm->trempitch = NULL, elm->trempitchnum = 0;
index 1c76841..936f42c 100644 (file)
@@ -97,7 +97,7 @@ typedef struct {
   char *comment;
   Instrument *instrument;
   int8 note, pan, strip_loop, strip_envelope, strip_tail, loop_timeout,
-       font_preset, font_keynote, legato, tva_level, play_note, redamper;
+       font_preset, font_keynote, legato, tva_level, play_note, damper_mode;
   uint8 font_bank;
   uint8 instype; /* 0: Normal
                    1: %font
@@ -121,7 +121,11 @@ typedef struct {
        int envratenum, envofsnum;
        int **envrate, **envofs;
        int modenvratenum, modenvofsnum;
-       int **modenvrate, **modenvofs;
+       int **modenvrate, **modenvofs;\r
+       int envvelfnum, envkeyfnum;\r
+       int **envvelf, **envkeyf;\r
+       int modenvvelfnum, modenvkeyfnum;\r
+       int **modenvvelf, **modenvkeyf;
        int tremnum, vibnum;
        struct Quantity_ **trem, **vib;
        int16 vel_to_fc, key_to_fc, vel_to_resonance;
index d18b950..dd39dd8 100644 (file)
@@ -1562,6 +1562,7 @@ static inline int next_stage(int v)
                                ? channel[ch].drums[vp->note]->drum_envelope_rate[eg_stage]
                                : -1;
        else {
+//             ctl->cmsg(CMSG_INFO,VERB_NOISY,"keyf: %ld", vp->sample->envelope_keyf[stage]);
                if (vp->sample->envelope_keyf[stage])   /* envelope key-follow */
                        rate *= pow(2.0, (double) (voice[v].note - 60)
                                        * (double)vp->sample->envelope_keyf[stage] / 1200.0f);
index eb4bec3..4d8fba7 100644 (file)
@@ -280,6 +280,7 @@ static void update_legato_controls(int ch);
 static void update_channel_freq(int ch);
 static void set_single_note_tuning(int, int, int, int);
 static void set_user_temper_entry(int, int, int);
+void recompute_bank_parameter(int, int);
 
 static void init_voice_filter(int);
 /* XG Part EQ */
@@ -501,7 +502,7 @@ static void reset_drum_controllers(struct DrumParts *d[], int note)
     else
     {
        d[note]->drum_panning = NO_PANNING;
-       for(j=0;j<6;j++) {d[note]->drum_envelope_rate[j] = -1;}
+       for(j = 0; j < 6; j++) {d[note]->drum_envelope_rate[j] = -1;}
        d[note]->pan_random = 0;
        d[note]->drum_level = 1.0f;
        d[note]->coarse = 0;
@@ -552,6 +553,14 @@ static void reset_module_dependent_controllers(int c)
        }
 }
 
+static void reset_instrument_parameters(int c)
+{
+  channel[c].legato = 0;
+  channel[c].damper_mode = 0;
+  channel[c].loop_timeout = 0;
+  recompute_bank_parameter(c, 0);
+}
+
 static void reset_nrpn_controllers(int c)
 {
   int i;
@@ -603,10 +612,6 @@ static void reset_nrpn_controllers(int c)
 
   free_drum_effect(c);
 
-  channel[c].legato = 0;
-  channel[c].redamper = 0;
-  channel[c].loop_timeout = 0;
-
   channel[c].sysex_gs_msb_addr = channel[c].sysex_gs_msb_val =
        channel[c].sysex_xg_msb_addr = channel[c].sysex_xg_msb_val =
        channel[c].sysex_msb_addr = channel[c].sysex_msb_val = 0;
@@ -645,7 +650,7 @@ static void reset_controllers(int c)
   channel[c].porta_control_ratio = 0;
   channel[c].portamento = 0;
   channel[c].last_note_fine = -1;
-  for(j=0;j<6;j++) {channel[c].envelope_rate[j] = -1;}
+  for(j = 0; j < 6; j++) {channel[c].envelope_rate[j] = -1;}
   update_portamento_controls(c);
   set_reverb_level(c, -1);
   if(opt_chorus_control == 1)
@@ -676,9 +681,10 @@ static void reset_midi(int playing)
        int i, cnt;
        
        for (i = 0; i < MAX_CHANNELS; i++) {
+               reset_instrument_parameters(i);
                reset_controllers(i);
                reset_nrpn_controllers(i);
-               reset_module_dependent_controllers(i);
+       reset_module_dependent_controllers(i);
                /* The rest of these are unaffected
                 * by the Reset All Controllers event
                 */
@@ -1293,12 +1299,12 @@ void recompute_bank_parameter(int ch, int note)
                }
        } else {
                nprog = channel[ch].program;
-               if(nprog == SPECIAL_PROGRAM) {return;}
+               if (nprog == SPECIAL_PROGRAM) {return;}
                instrument_map(channel[ch].mapID, &nbank, &nprog);
                bank = tonebank[nbank];
-               if(bank == NULL) {bank = tonebank[0];}
+               if (bank == NULL) {bank = tonebank[0];}
                channel[ch].legato = bank->tone[nprog].legato;
-               channel[ch].redamper = bank->tone[nprog].redamper;
+               channel[ch].damper_mode = bank->tone[nprog].damper_mode;
                channel[ch].loop_timeout = bank->tone[nprog].loop_timeout;
        }
 }
@@ -2817,7 +2823,7 @@ static void update_redamper_controls(int ch)
 {
   int uv = upper_voices, i;
 
-  if(ISDRUMCHANNEL(ch) || channel[ch].redamper == 0) {return;}
+  if(ISDRUMCHANNEL(ch) || channel[ch].damper_mode == 0) {return;}
 
   for(i = 0; i < uv; i++)
   {
@@ -3326,6 +3332,7 @@ void midi_program_change(int ch, int prog)
                        instrument_map(channel[ch].mapID, &b, &p);
                        play_midi_load_instrument(0, b, p);
                }
+               reset_instrument_parameters(ch);
        }
 }
 
@@ -5049,7 +5056,7 @@ static void seek_forward(int32 until_time)
 
          case ME_SUSTAIN:
                  channel[ch].sustain = current_event->a;
-                 if (channel[ch].redamper == 0) {      /* half-damper is not allowed. */
+                 if (channel[ch].damper_mode == 0) {   /* half-damper is not allowed. */
                          if (channel[ch].sustain >= 64) {channel[ch].sustain = 127;}
                          else {channel[ch].sustain = 0;}
                  }
@@ -6987,7 +6994,7 @@ int play_event(MidiEvent *ev)
                update_redamper_controls(ch);
        }
        channel[ch].sustain = ev->a;
-       if (channel[ch].redamper == 0) {        /* half-damper is not allowed. */
+       if (channel[ch].damper_mode == 0) {     /* half-damper is not allowed. */
                if (channel[ch].sustain >= 64) {channel[ch].sustain = 127;}
                else {channel[ch].sustain = 0;}
        }
index 3441255..e92c685 100644 (file)
@@ -348,7 +348,7 @@ typedef struct {
 
   int8 soft_pedal;
   int8 sostenuto;
-  int8 redamper;
+  int8 damper_mode;
 
   int8 tone_map0_number;
   FLOAT_T pitch_offset_fine;   /* in Hz */
@@ -362,7 +362,7 @@ typedef struct {
   ChannelBitMask channel_layer;
   int port_select;
 
-  struct part_eq_xg eq_xg;
+  struct part_eq_xg eq_xg;\r
 
   int8 dry_level;
   int8 note_limit_high, note_limit_low;        /* Note Limit (Keyboard Range) */
@@ -473,6 +473,9 @@ typedef struct {
 /* Anything but PANNED_MYSTERY only uses the left volume */
 
 #define ISDRUMCHANNEL(c)  IS_SET_CHANNELMASK(drumchannels, c)
+\r
+extern Channel channel[];\r
+extern Voice *voice;\r
 
 /* --module */
 extern int opt_default_module;
@@ -495,25 +498,22 @@ enum {
        /* Special modules */
        MODULE_TIMIDITY_SPECIAL1 = 0x70,
        MODULE_TIMIDITY_DEBUG = 0x7f,
-};
-
-static inline int is_gs_module(void)
-{
-    return (opt_default_module >= MODULE_SC55
-            && opt_default_module <= MODULE_MU100);
+};\r
+\r
+static inline int get_module() {return opt_default_module;}\r
+
+static inline int is_gs_module()
+{\r
+       int module = get_module();
+    return (module >= MODULE_SC55 && module <= MODULE_MU100);
 }
 
-static inline int is_xg_module(void)
-{
-    return (opt_default_module >= MODULE_MU50
-            && opt_default_module <= MODULE_MU100);
+static inline int is_xg_module()
+{\r
+       int module = get_module();
+    return (module >= MODULE_MU50 && module <= MODULE_MU100);
 }
 
-static inline int get_module(void) {return opt_default_module;}
-
-extern Channel channel[];
-extern Voice *voice;
-
 extern int32 control_ratio, amp_with_poly, amplification;
 
 extern ChannelBitMask default_drumchannel_mask;
index cfcdee7..50019b6 100644 (file)
@@ -831,6 +831,14 @@ static int set_gus_patchconf_opts(char *name,
                tone->modenvrate = config_parse_envelope(cp, &tone->modenvratenum);
        else if (! strcmp(opts, "modoffset"))
                tone->modenvofs = config_parse_envelope(cp, &tone->modenvofsnum);
+       else if (! strcmp(opts, "envkeyf"))
+               tone->envkeyf = config_parse_envelope(cp, &tone->envkeyfnum);
+       else if (! strcmp(opts, "envvelf"))
+               tone->envvelf = config_parse_envelope(cp, &tone->envvelfnum);
+       else if (! strcmp(opts, "modkeyf"))
+               tone->modenvkeyf = config_parse_envelope(cp, &tone->modenvkeyfnum);
+       else if (! strcmp(opts, "modvelf"))
+               tone->modenvvelf = config_parse_envelope(cp, &tone->modenvvelfnum);
        else if (! strcmp(opts, "trempitch"))
                tone->trempitch = config_parse_int16(cp, &tone->trempitchnum);
        else if (! strcmp(opts, "tremfc"))
@@ -866,7 +874,7 @@ static void reinit_tone_bank_element(ToneBankElement *tone)
        tone->amp = -1;
        tone->rnddelay = 0;
        tone->loop_timeout = 0;
-       tone->legato = tone->redamper = tone->key_to_fc = tone->vel_to_fc = 0;
+       tone->legato = tone->damper_mode = tone->key_to_fc = tone->vel_to_fc = 0;
        tone->reverb_send = tone->chorus_send = tone->delay_send = -1;
        tone->tva_level = -1;
        tone->play_note = -1;
@@ -1544,8 +1552,8 @@ MAIN_INTERFACE int read_config_file(char *name, int self)
                continue;
            }
            bank->tone[i].legato = atoi(w[2]);
-       }       /* #extension redamper [program] [0 or 1] */
-       else if(strcmp(w[0], "redamper") == 0)
+       }       /* #extension damper [program] [0 or 1] */
+       else if(strcmp(w[0], "damper") == 0)
        {
            if(words != 3)
            {
@@ -1566,12 +1574,12 @@ MAIN_INTERFACE int read_config_file(char *name, int self)
            if(i < 0 || i > 127)
            {
                ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
-                         "%s: line %d: extension redamper "
+                         "%s: line %d: extension damper "
                          "must be between 0 and 127", name, line);
                CHECKERRLIMIT;
                continue;
            }
-           bank->tone[i].redamper = atoi(w[2]);
+           bank->tone[i].damper_mode = atoi(w[2]);
        }       /* #extension rnddelay [program] [0 or 1] */
        else if(strcmp(w[0], "rnddelay") == 0)
        {