diff --git a/Plugins/MIDI/MIDI/SCPlayer.cpp b/Plugins/MIDI/MIDI/SCPlayer.cpp index a2de8a863..75d031b7b 100644 --- a/Plugins/MIDI/MIDI/SCPlayer.cpp +++ b/Plugins/MIDI/MIDI/SCPlayer.cpp @@ -140,7 +140,11 @@ void SCPlayer::reset(uint32_t port) { if (initialized) { - switch (mode) + sampler[port].TG_LongMidiIn(syx_reset_xg, 0); junk(port, 1024); + sampler[port].TG_LongMidiIn(syx_reset_gm2, 0); junk(port, 1024); + sampler[port].TG_LongMidiIn(syx_reset_gm, 0); junk(port, 1024); + + switch (mode) { case sc_gm: sampler[port].TG_LongMidiIn( syx_reset_gm, 0 ); @@ -165,28 +169,43 @@ void SCPlayer::reset(uint32_t port) break; } + junk(port, 1024); + { unsigned int i; for (i = 0; i < 16; ++i) { - sampler[port].TG_ShortMidiIn( 0x78B0 + i, 0 ); - sampler[port].TG_ShortMidiIn( 0x79B0 + i, 0 ); + sampler[port].TG_ShortMidiIn(0x78B0 + i, 0); + sampler[port].TG_ShortMidiIn(0x79B0 + i, 0); + sampler[port].TG_ShortMidiIn(0x20B0 + i, 0); + sampler[port].TG_ShortMidiIn(0x00B0 + i, 0); + sampler[port].TG_ShortMidiIn(0xC0 + i, 0); } } - { - float temp[1024]; - unsigned long i, j; - for (i = 0, j = (uSampleRate / 1536 + 1); i < j; ++i) - { - memset(temp, 0, sizeof(temp)); - sampler[port].TG_setInterruptThreadIdAtThisTime(); - sampler[port].TG_Process(temp, temp, 1024); - } - } + junk(port, uSampleRate * 2 / 3); } } +void SCPlayer::junk(uint32_t port, unsigned long count) +{ + float temp[2][1024]; + unsigned long i, j; + for (i = 0, j = count / 1024; i < j; ++i) + { + memset(temp, 0, sizeof(temp)); + sampler[port].TG_setInterruptThreadIdAtThisTime(); + sampler[port].TG_Process(temp[0], temp[1], 1024); + } + count %= 1024; + if (count) + { + memset(temp, 0, sizeof(temp)); + sampler[port].TG_setInterruptThreadIdAtThisTime(); + sampler[port].TG_Process(temp[0], temp[1], (unsigned int) count); + } +} + void SCPlayer::set_mode(sc_mode m) { mode = m; @@ -299,7 +318,6 @@ bool SCPlayer::startup() for (int i = 0; i < 3; i++) { reset(i); - sampler[i].TG_flushMidi(); } return true; diff --git a/Plugins/MIDI/MIDI/SCPlayer.h b/Plugins/MIDI/MIDI/SCPlayer.h index 962f77a35..c1009191e 100644 --- a/Plugins/MIDI/MIDI/SCPlayer.h +++ b/Plugins/MIDI/MIDI/SCPlayer.h @@ -47,6 +47,8 @@ private: void reset(uint32_t port); + void junk(uint32_t port, unsigned long count); + unsigned int instance_id; bool initialized; SCCore * sampler;