@@ -2237,10 +2237,6 @@ fluid_synth_sysex(fluid_synth_t *synth, const char *data, int len,
22372237 result = fluid_synth_sysex_gs_dt1 (synth , data , len , response ,
22382238 response_len , avail_response ,
22392239 handled , dryrun );
2240- if (synth -> verbose )
2241- {
2242- FLUID_LOG (FLUID_INFO , "Processing SysEX GS DT1 message, bank selection mode might have been changed." );
2243- }
22442240 FLUID_API_RETURN (result );
22452241 }
22462242
@@ -2568,7 +2564,7 @@ fluid_synth_sysex_gs_dt1(fluid_synth_t *synth, const char *data, int len,
25682564
25692565 if (len < 9 ) // at least one byte of data should be transmitted
25702566 {
2571- FLUID_LOG (FLUID_INFO , "SysEx DT1: message too short, dropping it." );
2567+ FLUID_LOG (FLUID_INFO , "SysEx GS DT1: message too short, dropping it." );
25722568 return FLUID_FAILED ;
25732569 }
25742570 len_data = len - 8 ;
@@ -2582,24 +2578,26 @@ fluid_synth_sysex_gs_dt1(fluid_synth_t *synth, const char *data, int len,
25822578 // An intermediate checksum of 0x80 must be treated as zero! #1578
25832579 if ((checksum & 0x7F ) != data [len - 1 ])
25842580 {
2585- FLUID_LOG (FLUID_INFO , "SysEx DT1: dropping message on addr 0x%x due to incorrect checksum 0x%x. Correct checksum: 0x%x" , addr , (int )data [len - 1 ], checksum );
2581+ FLUID_LOG (FLUID_INFO , "SysEx GS DT1: dropping message on addr 0x%x due to incorrect checksum 0x%x. Correct checksum: 0x%x" , addr , (int )data [len - 1 ], checksum );
25862582 return FLUID_FAILED ;
25872583 }
25882584
25892585 if (addr == 0x40007F ) // Mode set
25902586 {
25912587 if (len_data > 1 || (data [7 ] != 0 && data [7 ] != 0x7f ))
25922588 {
2593- FLUID_LOG (FLUID_INFO , "SysEx DT1: dropping invalid mode set message" );
2589+ FLUID_LOG (FLUID_INFO , "SysEx GS DT1: dropping invalid mode set message" );
25942590 return FLUID_FAILED ;
25952591 }
25962592 if (handled )
25972593 {
25982594 * handled = TRUE;
25992595 }
2596+
2597+ i = data [7 ];
26002598 if (!dryrun )
26012599 {
2602- if (data [ 7 ] == 0 )
2600+ if (i == 0 )
26032601 {
26042602 synth -> bank_select = FLUID_BANK_STYLE_GS ;
26052603 }
@@ -2609,6 +2607,12 @@ fluid_synth_sysex_gs_dt1(fluid_synth_t *synth, const char *data, int len,
26092607 }
26102608 return fluid_synth_system_reset_LOCAL (synth );
26112609 }
2610+ if (synth -> verbose )
2611+ {
2612+ FLUID_LOG (FLUID_INFO , "%sSysEX GS DT1: bank selection mode is now %s" ,
2613+ dryrun ? "[DRYRUN] " : "" ,
2614+ i == 0 ? "GS" : "GM" );
2615+ }
26122616 return FLUID_OK ;
26132617 }
26142618
@@ -2621,7 +2625,7 @@ fluid_synth_sysex_gs_dt1(fluid_synth_t *synth, const char *data, int len,
26212625 {
26222626 if (len_data > 1 || data [7 ] > 0x02 )
26232627 {
2624- FLUID_LOG (FLUID_INFO , "SysEx DT1: dropping invalid rhythm part message" );
2628+ FLUID_LOG (FLUID_INFO , "SysEx GS DT1: dropping invalid rhythm part message" );
26252629 return FLUID_FAILED ;
26262630 }
26272631 if (handled )
@@ -2630,15 +2634,25 @@ fluid_synth_sysex_gs_dt1(fluid_synth_t *synth, const char *data, int len,
26302634 }
26312635 if (!dryrun )
26322636 {
2633- int chan = (addr >> 8 ) & 0x0F ;
2637+ int chan = (addr >> 8 ) & 0x0F , type ;
26342638 //See the Patch Part parameters section in SC-88Pro/8850 owner's manual
26352639 chan = chan >= 0x0a ? chan : (chan == 0 ? 9 : chan - 1 );
2636- synth -> channel [chan ]-> channel_type =
2637- data [7 ] == 0x00 ? CHANNEL_TYPE_MELODIC : CHANNEL_TYPE_DRUM ;
2638-
2639- FLUID_LOG (FLUID_DBG , "SysEx DT1: setting MIDI channel %d to type %d" , chan , (int )synth -> channel [chan ]-> channel_type );
2640- //Roland synths seem to "remember" the last instrument a channel
2641- //used in the selected mode. This behavior is not replicated here.
2640+ type = data [7 ] == 0x00 ? CHANNEL_TYPE_MELODIC : CHANNEL_TYPE_DRUM ;
2641+ synth -> channel [chan ]-> channel_type = type ;
2642+
2643+ FLUID_LOG (FLUID_DBG , "SysEx GS DT1: setting MIDI channel %d to type %d" , chan , (int )synth -> channel [chan ]-> channel_type );
2644+ // Roland synths seem to "remember" the last instrument a channel
2645+ // used in the selected mode. This behavior is not replicated here.
2646+ // Issue 1579: The preset selected for the channel needs to be forcibly changed. Therefore it is not sufficient
2647+ // to send a prog change, as the old bank is still active in the channel.
2648+ // MSGS selects the standard drum kit right after this message (which is equivalent to sending a prog change 0).
2649+ // However, this behavior is insonsistent with the note on site 60:
2650+ // "To select a drum set after setting the part mode, transmit a program change [...]"
2651+ fluid_synth_cc_LOCAL (synth , chan , ALL_CTRL_OFF );
2652+ fluid_channel_set_sfont_bank_prog (synth -> channel [chan ],
2653+ -1 ,
2654+ type == CHANNEL_TYPE_DRUM ? DRUM_INST_BANK : 0 ,
2655+ -1 );
26422656 fluid_synth_program_change (synth , chan , 0 );
26432657 }
26442658 return FLUID_OK ;
0 commit comments