OSDN Git Service

Fix to fit with MAX_CHANNELS > 32
authorShoichi Tamuki <tamuki@linet.gr.jp>
Wed, 4 Mar 2009 09:51:36 +0000 (09:51 +0000)
committerShoichi Tamuki <tamuki@linet.gr.jp>
Wed, 4 Mar 2009 09:51:36 +0000 (09:51 +0000)
ChangeLog
interface/ncurs_c.c
timidity/playmidi.c
timidity/readmidi.c

index 636e1e8..94c675c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-03-04  TAMUKI Shoichi <tamuki@linet.gr.jp>
+
+       * interface/ncurs_c.c, timidity/readmidi.c:
+         Fix to fit with MAX_CHANNELS > 32
+       * timidity/playmidi.c (find_voice): Beautify
+
 2008-12-06  Keishi Suenaga <skeishi@yahoo.co.jp>
 
        * configure.in: Fix mingw detection and replace wsock32 by ws2_32.
index 5967913..1526daa 100644 (file)
@@ -729,38 +729,37 @@ static void display_intonation(int mode)
 
 static void ctl_ncurs_mode_init(void)
 {
-    int i;
-
-    display_channels = LINES - 8;
-    if(display_channels > MAX_CHANNELS)
-       display_channels = MAX_CHANNELS;
-    if(current_file_info != NULL && current_file_info->max_channel < 16)
-       display_channels = 16;
-
-    display_play_system(play_system_mode);
-    display_intonation(opt_pure_intonation);
-    switch(ctl_ncurs_mode)
-    {
-      case NCURS_MODE_MAIN:
-       touchwin(msgwin);
-       wrefresh(msgwin);
-       break;
-      case NCURS_MODE_TRACE:
-       touchwin(dftwin);
-       for(i = 0; i < MAX_CHANNELS; i++)
-           init_trace_window_chan(i);
-       N_ctl_refresh();
-       break;
-      case NCURS_MODE_HELP:
-       break;
-      case NCURS_MODE_LIST:
-       touchwin(listwin);
-       ctl_list_mode(NC_LIST_NOW);
-       break;
-      case NCURS_MODE_DIR:
-       ctl_cmd_L_dir(0);
-       break;
-    }
+       int i;
+       
+       if (current_file_info != NULL)
+               display_channels = (current_file_info->max_channel / 16) * 16 + 16;
+       else
+               display_channels = LINES - 8;
+       if (display_channels > LINES - 8)
+               display_channels = LINES - 8;
+       display_play_system(play_system_mode);
+       display_intonation(opt_pure_intonation);
+       switch (ctl_ncurs_mode) {
+       case NCURS_MODE_MAIN:
+               touchwin(msgwin);
+               wrefresh(msgwin);
+               break;
+       case NCURS_MODE_TRACE:
+               touchwin(dftwin);
+               for (i = 0; i < MAX_CHANNELS; i++)
+                       init_trace_window_chan(i);
+               N_ctl_refresh();
+               break;
+       case NCURS_MODE_HELP:
+               break;
+       case NCURS_MODE_LIST:
+               touchwin(listwin);
+               ctl_list_mode(NC_LIST_NOW);
+               break;
+       case NCURS_MODE_DIR:
+               ctl_cmd_L_dir(0);
+               break;
+       }
 }
 
 static void display_key_helpmsg(void)
index c578ab3..c4e76f6 100644 (file)
@@ -2143,13 +2143,13 @@ static int find_voice(MidiEvent *e)
                                        finish_note(i); /* drop sustain */
                                else
                                        kill_note(i);
-                       } else if (mono_check
-                                       || (altassign && find_altassign(altassign, voice[i].note)))
+                       } else if (mono_check)
                                kill_note(i);
-                       else if (voice[i].note == note &&
-                                (channel[ch].assign_mode == 0
-                                       || (channel[ch].assign_mode == 1
-                                       && voice[i].proximate_flag == 0)))
+                       else if (altassign && find_altassign(altassign, voice[i].note))
+                               kill_note(i);
+                       else if (voice[i].note == note && (channel[ch].assign_mode == 0
+                                       || channel[ch].assign_mode == 1
+                                       && voice[i].proximate_flag == 0))
                                kill_note(i);
                }
        for (i = 0; i < upper_voices; i++)
index 02aa49b..599e328 100644 (file)
@@ -2833,7 +2833,7 @@ int parse_sysex_event_multi(uint8 *val, int32 len, MidiEvent *evm)
                                                        0, val[7], (val[0] == 0x7f));
                                        num_events++;
                                } else {
-                                       for (i = j = 0; i < MAX_CHANNELS; i++)
+                                       for (i = j = 0; i < 32; i++)
                                                if (channel_tt & 1 << i) {
                                                        SETMIDIEVENT(evm[j], 0, ME_TEMPER_TYPE,
                                                                        MERGE_CHANNEL_PORT(i),
@@ -3866,15 +3866,17 @@ static void move_channels(int *chidx)
                                if (chidx[ch = e->event.channel] != -1)
                                        ch = e->event.channel = chidx[ch];
                                else {  /* -1 */
-                                       newch = ch % REDUCE_CHANNELS;
-                                       while (newch < ch && newch < MAX_CHANNELS) {
-                                               if (chidx[newch] == -1) {
-                                                       ctl->cmsg(CMSG_INFO, VERB_VERBOSE,
-                                                                       "channel %d => %d", ch, newch);
-                                                       ch = e->event.channel = chidx[ch] = newch;
-                                                       break;
+                                       if (ch >= MAX_CHANNELS) {
+                                               newch = ch % REDUCE_CHANNELS;
+                                               while (newch < ch && newch < MAX_CHANNELS) {
+                                                       if (chidx[newch] == -1) {
+                                                               ctl->cmsg(CMSG_INFO, VERB_VERBOSE,
+                                                                               "channel %d => %d", ch, newch);
+                                                               ch = e->event.channel = chidx[ch] = newch;
+                                                               break;
+                                                       }
+                                                       newch += REDUCE_CHANNELS;
                                                }
-                                               newch += REDUCE_CHANNELS;
                                        }
                                        if (chidx[ch] == -1) {
                                                if (ch < MAX_CHANNELS)