- const int ch=(r>>4)-0xc0;\r
- if(spu.dwNewChannel&(1<<ch)) return 1; // we are started, but not processed? return 1\r
- if((spu.dwChannelOn&(1<<ch)) && // same here... we haven't decoded one sample yet, so no envelope yet. return 1 as well\r
- !spu.s_chan[ch].ADSRX.EnvelopeVol)\r
- return 1;\r
- return (unsigned short)(spu.s_chan[ch].ADSRX.EnvelopeVol>>16);\r
+ // this used to return 1 immediately after keyon to deal with\r
+ // some poor timing, but that causes Rayman 2 to lose track of\r
+ // it's channels on busy scenes and start looping some of them forever\r
+ const int ch = (r>>4) - 0xc0;\r
+ if (spu.s_chan[ch].bStarting)\r
+ do_samples_if_needed(cycles, 0, 2);\r
+ return (unsigned short)(spu.s_chan[ch].ADSRX.EnvelopeVol >> 16);\r