+++ /dev/null
-/***************************************************************************\r
- adsr.h - description\r
- -------------------\r
- begin : Wed May 15 2002\r
- copyright : (C) 2002 by Pete Bernert\r
- email : BlackDove@addcom.de\r
- ***************************************************************************/\r
-/***************************************************************************\r
- * *\r
- * This program is free software; you can redistribute it and/or modify *\r
- * it under the terms of the GNU General Public License as published by *\r
- * the Free Software Foundation; either version 2 of the License, or *\r
- * (at your option) any later version. See also the license.txt file for *\r
- * additional informations. *\r
- * *\r
- ***************************************************************************/\r
-\r
-#ifndef __P_ADER_H__\r
-#define __P_ADER_H__\r
-\r
-INLINE void StartADSR(int ch);\r
-INLINE int MixADSR(int ch);\r
-\r
-#endif /* __P_ADER_H__ */\r
unsigned int dwNoiseVal; // global noise generator\r
unsigned int dwNoiseCount;\r
unsigned int dwNewChannel; // flags for faster testing, if new channel starts\r
- unsigned int dwChannelOn; // not silent channels\r
+ unsigned int dwChannelsAudible; // not silent channels\r
unsigned int dwChannelDead; // silent+not useful channels\r
\r
unsigned char * pSpuBuffer;\r
d->iStart = (regAreaGet(ch,6)&~1)<<3;\r
d->iCurr = 0; // set by the caller\r
d->iLoop = 0; // set by the caller\r
- d->bOn = !!(spu.dwChannelOn & (1<<ch));\r
+ d->bOn = !!(spu.dwChannelsAudible & (1<<ch));\r
d->bStop = s->ADSRX.State == ADSR_RELEASE;\r
d->bReverb = s->bReverb;\r
d->iActFreq = 1;\r
d->ADSRX.ReleaseModeExp = s->ADSRX.ReleaseModeExp;\r
d->ADSRX.ReleaseRate = s->ADSRX.ReleaseRate;\r
d->ADSRX.EnvelopeVol = s->ADSRX.EnvelopeVol;\r
- if (s->bOn) spu.dwChannelOn |= 1<<ch;\r
+ if (s->bOn) spu.dwChannelsAudible |= 1<<ch;\r
else d->ADSRX.EnvelopeVol = 0;\r
}\r
\r
spu.decode_pos = pFO->decode_pos & 0x1ff;\r
\r
spu.dwNewChannel=0;\r
- spu.dwChannelOn=0;\r
+ spu.dwChannelsAudible=0;\r
spu.dwChannelDead=0;\r
for(i=0;i<MAXCHAN;i++)\r
{\r
}\r
\r
spu.dwNewChannel=0;\r
- spu.dwChannelOn=0;\r
+ spu.dwChannelsAudible=0;\r
spu.dwChannelDead=0;\r
spu.pSpuIrq=spu.spuMemC;\r
\r
{\r
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
+ if((spu.dwChannelsAudible&(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
spu.s_chan[ch].sinc = NP << 4;\r
spu.s_chan[ch].sinc_inv = 0;\r
spu.SB[ch * SB_SIZE + 32] = 1; // -> freq change in simple interpolation mode: set flag\r
+ if (val)\r
+ spu.dwChannelsAudible |= 1u << ch;\r
+ else\r
+ spu.dwChannelsAudible &= ~(1u << ch);\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
s_chan->pCurr = spu.spuMemC+((regAreaGet(ch,6)&~1)<<3);
spu.dwNewChannel&=~(1<<ch); // clear new channel bit
- spu.dwChannelOn|=1<<ch;
spu.dwChannelDead&=~(1<<ch);
+ if (s_chan->iRawPitch)
+ spu.dwChannelsAudible|=1<<ch;
}
static void StartSound(int ch)
StartSound(ch);
}
- mask = spu.dwChannelOn & 0xffffff;
+ mask = spu.dwChannelsAudible & 0xffffff;
for (ch = 0; mask != 0; ch++, mask >>= 1) // loop em all...
{
if (!(mask & 1)) continue; // channel not playing? next
d = MixADSR(&s_chan->ADSRX, d);
if (d < ns_to) {
- spu.dwChannelOn &= ~(1 << ch);
+ spu.dwChannelsAudible &= ~(1 << ch);
+ s_chan->ADSRX.State = ADSR_RELEASE;
s_chan->ADSRX.EnvelopeVol = 0;
memset(&ChanBuf[d], 0, (ns_to - d) * sizeof(ChanBuf[0]));
}
StartSoundMain(ch);
}
- mask = work->channels_on = spu.dwChannelOn & 0xffffff;
+ mask = work->channels_on = spu.dwChannelsAudible & 0xffffff;
spu.decode_dirty_ch |= mask & 0x0a;
for (ch = 0; mask != 0; ch++, mask >>= 1)
// note: d is not accurate on skip
d = SkipADSR(&s_chan->ADSRX, d);
if (d < ns_to) {
- spu.dwChannelOn &= ~(1 << ch);
+ spu.dwChannelsAudible &= ~(1 << ch);
s_chan->ADSRX.EnvelopeVol = 0;
}
}
return;
}
- silentch = ~(spu.dwChannelOn | spu.dwNewChannel) & 0xffffff;
+ silentch = ~(spu.dwChannelsAudible | spu.dwNewChannel) & 0xffffff;
do_direct |= (silentch == 0xffffff);
if (worker != NULL)
for(;ch<MAXCHAN;ch++)
{
- if (!(spu.dwChannelOn & (1<<ch)))
+ if (!(spu.dwChannelsAudible & (1<<ch)))
continue;
if (spu.s_chan[ch].bFMod == 2)
fmod_chans |= 1 << ch;
irq_chans |= 1 << ch;
}
- *chans_out = spu.dwChannelOn;
- *run_chans = ~spu.dwChannelOn & ~spu.dwChannelDead & irq_chans;
+ *chans_out = spu.dwChannelsAudible;
+ *run_chans = ~spu.dwChannelsAudible & ~spu.dwChannelDead & irq_chans;
*fmod_chans_out = fmod_chans;
*noise_chans_out = noise_chans;
}