This commit is contained in:
parent
41b1bd58d1
commit
548fff4a27
4 changed files with 59 additions and 36 deletions
|
@ -593,7 +593,7 @@ void CSoundMediator::setSfxBank(SFXBANKID _bankId)
|
||||||
same time as *lots* of other sfx.
|
same time as *lots* of other sfx.
|
||||||
Returns:
|
Returns:
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
xmPlayingId CSoundMediator::playSfx(SFXID _sfxId,int _lock=false)
|
xmPlayingId CSoundMediator::playSfx(SFXID _sfxId,int _lock=false,int _dontPlayIfSFXAlreadyAudible=false)
|
||||||
{
|
{
|
||||||
if(!s_canPlaySfx)
|
if(!s_canPlaySfx)
|
||||||
{
|
{
|
||||||
|
@ -609,6 +609,12 @@ xmPlayingId CSoundMediator::playSfx(SFXID _sfxId,int _lock=false)
|
||||||
|
|
||||||
// Play!
|
// Play!
|
||||||
sfx=&s_sfxDetails[_sfxId];
|
sfx=&s_sfxDetails[_sfxId];
|
||||||
|
|
||||||
|
if(_dontPlayIfSFXAlreadyAudible&&s_xmplaySound->isSfxPatternPlaying(sfx->m_pattern))
|
||||||
|
{
|
||||||
|
return NOT_PLAYING;
|
||||||
|
}
|
||||||
|
|
||||||
if(sfx->m_looping)
|
if(sfx->m_looping)
|
||||||
{
|
{
|
||||||
playId=s_xmplaySound->playLoopingSfx(s_sfxSampleId,s_sfxModId,sfx->m_pattern,10);
|
playId=s_xmplaySound->playLoopingSfx(s_sfxSampleId,s_sfxModId,sfx->m_pattern,10);
|
||||||
|
|
|
@ -203,7 +203,7 @@ public:
|
||||||
|
|
||||||
// SFX interface
|
// SFX interface
|
||||||
static void setSfxBank(SFXBANKID _bankId);
|
static void setSfxBank(SFXBANKID _bankId);
|
||||||
static xmPlayingId playSfx(SFXID _sfxId,int _lock=false);
|
static xmPlayingId playSfx(SFXID _sfxId,int _lock=false,int _dontPlayIfSFXAlreadyAudible=false);
|
||||||
static void setposition(xmPlayingId _playingId,VECTOR *pos);
|
static void setposition(xmPlayingId _playingId,VECTOR *pos);
|
||||||
static void stopAndUnlockSfx(xmPlayingId _playingId);
|
static void stopAndUnlockSfx(xmPlayingId _playingId);
|
||||||
static void stopAllSfx();
|
static void stopAllSfx();
|
||||||
|
|
|
@ -163,15 +163,12 @@ void CXMPlaySound::think()
|
||||||
#ifdef __USER_paul__
|
#ifdef __USER_paul__
|
||||||
if(dump)
|
if(dump)
|
||||||
{
|
{
|
||||||
static char *text[]={"SONG","SFX","LOOPINGSFX","SILENT","FREE","CONTINUE"};
|
static char *text[]={"SONG","SFX","LOOPINGSFX","SILENTSONG","SILENTSFX","FREE","CONTINUE"};
|
||||||
spuChannelUse *ch=m_spuChannelUse;
|
spuChannelUse *ch=m_spuChannelUse;
|
||||||
PAUL_DBGMSG("=======");
|
PAUL_DBGMSG("=======");
|
||||||
for(int i=0;i<24;i++,ch++)
|
for(int i=0;i<24;i++,ch++)
|
||||||
{
|
{
|
||||||
PAUL_DBGMSG("%02d] u:%s l:%d pid:%04x",i,text[ch->m_useType],ch->m_locked,ch->m_playingId);
|
PAUL_DBGMSG("%02d] u:%s l:%d pid:%04x sPtn:%03d",i,text[ch->m_useType],ch->m_locked,ch->m_playingId,ch->m_startPattern);
|
||||||
#ifdef SFX_DEBUG
|
|
||||||
PAUL_DBGMSG(" sfxId:%d",ch->m_sfxId);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
PAUL_DBGMSG("=======");
|
PAUL_DBGMSG("=======");
|
||||||
dump=false;
|
dump=false;
|
||||||
|
@ -191,7 +188,8 @@ void CXMPlaySound::think()
|
||||||
switch(ch->m_useType)
|
switch(ch->m_useType)
|
||||||
{
|
{
|
||||||
// Silent and unlocked sounds can be freed
|
// Silent and unlocked sounds can be freed
|
||||||
case SILENT:
|
case SILENTSONG:
|
||||||
|
case SILENTSFX:
|
||||||
if(!ch->m_locked)
|
if(!ch->m_locked)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
|
@ -208,11 +206,9 @@ void CXMPlaySound::think()
|
||||||
case SONG:
|
case SONG:
|
||||||
case SFX:
|
case SFX:
|
||||||
if(XM_GetFeedback(ch->m_internalId,&fb))
|
if(XM_GetFeedback(ch->m_internalId,&fb))
|
||||||
// XM_GetFeedback(ch->m_internalId,&fb);
|
|
||||||
// if(fb.Status==XM_STOPPED)
|
|
||||||
{
|
{
|
||||||
// Just mark it as silent, if it's unlocked then it'll die next frame
|
// Just mark it as silent, if it's unlocked then it'll die next frame
|
||||||
ch->m_useType=SILENT;
|
ch->m_useType=ch->m_useType==SFX?SILENTSFX:SILENTSONG;
|
||||||
|
|
||||||
// And kill it in the player
|
// And kill it in the player
|
||||||
XM_Quit(ch->m_internalId);
|
XM_Quit(ch->m_internalId);
|
||||||
|
@ -235,12 +231,13 @@ if(PadGetDown(1)&PAD_L1&&PadGetHeld(1)&(PAD_L2|PAD_R1|PAD_R2))
|
||||||
}
|
}
|
||||||
if(sounddebug)
|
if(sounddebug)
|
||||||
{
|
{
|
||||||
static const int colours[6][3]=
|
static const int colours[7][3]=
|
||||||
{
|
{
|
||||||
{ 255,255,255 }, // SONG
|
{ 255,255,255 }, // SONG
|
||||||
{ 255, 0,255 }, // SFX
|
{ 255, 0,255 }, // SFX
|
||||||
{ 0, 0,255 }, // LOOPINGSFX
|
{ 0, 0,255 }, // LOOPINGSFX
|
||||||
{ 255,255, 0 }, // SILENT
|
{ 255,255, 0 }, // SILENTSONG
|
||||||
|
{ 255,255, 0 }, // SILENTSFX
|
||||||
{ 0,255, 0 }, // FREE
|
{ 0,255, 0 }, // FREE
|
||||||
{ 128,128,128 }, // CONTINUE
|
{ 128,128,128 }, // CONTINUE
|
||||||
};
|
};
|
||||||
|
@ -535,7 +532,8 @@ void CXMPlaySound::setVolume(xmPlayingId _playingId,unsigned char _volume)
|
||||||
ch->m_vol=_volume; // Update volume
|
ch->m_vol=_volume; // Update volume
|
||||||
switch(ch->m_useType)
|
switch(ch->m_useType)
|
||||||
{
|
{
|
||||||
case SILENT:
|
case SILENTSONG:
|
||||||
|
case SILENTSFX:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SONG:
|
case SONG:
|
||||||
|
@ -581,7 +579,8 @@ void CXMPlaySound::setPanning(xmPlayingId _playingId,char _pan)
|
||||||
ch->m_pan=_pan; // Update pan
|
ch->m_pan=_pan; // Update pan
|
||||||
switch(ch->m_useType)
|
switch(ch->m_useType)
|
||||||
{
|
{
|
||||||
case SILENT:
|
case SILENTSONG:
|
||||||
|
case SILENTSFX:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SONG:
|
case SONG:
|
||||||
|
@ -699,9 +698,7 @@ xmPlayingId CXMPlaySound::playSong(xmSampleId _sampleId,xmModId _modId,int _star
|
||||||
XM_Music, // Music
|
XM_Music, // Music
|
||||||
_startPattern); // Where to start from
|
_startPattern); // Where to start from
|
||||||
markChannelsAsActive(baseChannel,channelCount,SONG,retId,id,255);
|
markChannelsAsActive(baseChannel,channelCount,SONG,retId,id,255);
|
||||||
#ifdef SFX_DEBUG
|
m_spuChannelUse[baseChannel].m_startPattern=_startPattern;
|
||||||
m_spuChannelUse[baseChannel].m_sfxId=_startPattern;
|
|
||||||
#endif
|
|
||||||
setVolume(retId,MAX_VOLUME);
|
setVolume(retId,MAX_VOLUME);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -726,7 +723,7 @@ int CXMPlaySound::isStillPlaying(xmPlayingId _playingId)
|
||||||
if(ch->m_playingId==_playingId)
|
if(ch->m_playingId==_playingId)
|
||||||
{
|
{
|
||||||
ASSERT(ch->m_locked!=false); // Can't do this on an unlocked sound!
|
ASSERT(ch->m_locked!=false); // Can't do this on an unlocked sound!
|
||||||
return ch->m_useType!=SILENT;
|
return ch->m_useType!=SILENTSFX&&ch->m_useType!=SILENTSONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(0); // Couldn't find the sound to check it!
|
ASSERT(0); // Couldn't find the sound to check it!
|
||||||
|
@ -734,6 +731,31 @@ int CXMPlaySound::isStillPlaying(xmPlayingId _playingId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
int CXMPlaySound::isSfxPatternPlaying(int _startPattern)
|
||||||
|
{
|
||||||
|
spuChannelUse *ch;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
ch=m_spuChannelUse;
|
||||||
|
for(i=0;i<NUM_SPU_CHANNELS;i++)
|
||||||
|
{
|
||||||
|
if((ch->m_useType==SFX||ch->m_useType==SILENTSFX)&&ch->m_startPattern==_startPattern)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ch++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Function:
|
Function:
|
||||||
Purpose:
|
Purpose:
|
||||||
|
@ -777,16 +799,17 @@ void CXMPlaySound::stopPlayingId(xmPlayingId _playingId)
|
||||||
{
|
{
|
||||||
XM_PlayStop(ch->m_internalId);
|
XM_PlayStop(ch->m_internalId);
|
||||||
XM_Quit(ch->m_internalId);
|
XM_Quit(ch->m_internalId);
|
||||||
ch->m_useType=SILENT;
|
ch->m_useType=ch->m_useType==SFX?SILENTSFX:SILENTSONG;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOOPINGSFX:
|
case LOOPINGSFX:
|
||||||
XM_StopSample(ch->m_internalId);
|
XM_StopSample(ch->m_internalId);
|
||||||
ch->m_useType=SILENT;
|
ch->m_useType=SILENTSFX;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SILENT:
|
case SILENTSONG:
|
||||||
|
case SILENTSFX:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FREE:
|
case FREE:
|
||||||
|
@ -849,9 +872,7 @@ xmPlayingId CXMPlaySound::playSfx(xmSampleId _sampleId,xmModId _modId,int _sfxPa
|
||||||
_sfxPattern); // SFX pattern to play
|
_sfxPattern); // SFX pattern to play
|
||||||
XM_ClearSFXRange();
|
XM_ClearSFXRange();
|
||||||
markChannelsAsActive(baseChannel,channelCount,SFX,retId,id,_priority);
|
markChannelsAsActive(baseChannel,channelCount,SFX,retId,id,_priority);
|
||||||
#ifdef SFX_DEBUG
|
m_spuChannelUse[baseChannel].m_startPattern=_sfxPattern;
|
||||||
m_spuChannelUse[baseChannel].m_sfxId=_sfxPattern;
|
|
||||||
#endif
|
|
||||||
setVolume(retId,MAX_VOLUME);
|
setVolume(retId,MAX_VOLUME);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -915,8 +936,10 @@ xmPlayingId CXMPlaySound::getNextSparePlayingId(int _baseChannel)
|
||||||
ch=m_spuChannelUse;
|
ch=m_spuChannelUse;
|
||||||
for(i=0;i<NUM_SPU_CHANNELS&&validId!=NOT_PLAYING;i++)
|
for(i=0;i<NUM_SPU_CHANNELS&&validId!=NOT_PLAYING;i++)
|
||||||
{
|
{
|
||||||
if(ch->m_playingId==validId&&!(ch->m_locked==false&&ch->m_useType==SILENT))
|
if(ch->m_playingId==validId&&!(ch->m_locked==false&&(ch->m_useType==SILENTSONG||ch->m_useType==SILENTSFX)))
|
||||||
|
{
|
||||||
validId=NOT_PLAYING;
|
validId=NOT_PLAYING;
|
||||||
|
}
|
||||||
ch++;
|
ch++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,12 +39,6 @@ typedef enum {NOT_PLAYING=-1} xmPlayingId;
|
||||||
// 8 bits are the base channel of the playing sound.
|
// 8 bits are the base channel of the playing sound.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Define this to store the SFX number in the channel details. Useful for finding tracing sounds
|
|
||||||
// that are being left locked
|
|
||||||
//#define SFX_DEBUG
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Structure defintions
|
Structure defintions
|
||||||
-------------------- */
|
-------------------- */
|
||||||
|
@ -87,6 +81,7 @@ public:
|
||||||
xmPlayingId playLoopingSfx(xmSampleId _sampleId,xmModId _modId,int _soundId,u8 _priority,int _pitch=0x400);
|
xmPlayingId playLoopingSfx(xmSampleId _sampleId,xmModId _modId,int _soundId,u8 _priority,int _pitch=0x400);
|
||||||
|
|
||||||
int isStillPlaying(xmPlayingId _playingId);
|
int isStillPlaying(xmPlayingId _playingId);
|
||||||
|
int isSfxPatternPlaying(int _startPattern);
|
||||||
|
|
||||||
void unlockPlayingId(xmPlayingId _playingId);
|
void unlockPlayingId(xmPlayingId _playingId);
|
||||||
void stopPlayingId(xmPlayingId _playingId);
|
void stopPlayingId(xmPlayingId _playingId);
|
||||||
|
@ -110,7 +105,8 @@ private:
|
||||||
SFX,
|
SFX,
|
||||||
LOOPINGSFX,
|
LOOPINGSFX,
|
||||||
|
|
||||||
SILENT, // Channel is silent
|
SILENTSONG, // Channel is silent
|
||||||
|
SILENTSFX, // " " " "
|
||||||
FREE, // Channel is free for re-allocation
|
FREE, // Channel is free for re-allocation
|
||||||
CONTINUE, // Channel is a continuation of the previous channel
|
CONTINUE, // Channel is a continuation of the previous channel
|
||||||
} CHANNELUSETYPE;
|
} CHANNELUSETYPE;
|
||||||
|
@ -140,9 +136,7 @@ private:
|
||||||
u8 m_priority;
|
u8 m_priority;
|
||||||
u8 m_locked;
|
u8 m_locked;
|
||||||
u8 m_vol,m_pan;
|
u8 m_vol,m_pan;
|
||||||
#ifdef SFX_DEBUG
|
u8 m_startPattern;
|
||||||
u8 m_sfxId;
|
|
||||||
#endif
|
|
||||||
} spuChannelUse;
|
} spuChannelUse;
|
||||||
|
|
||||||
xmPlayingId getNextSparePlayingId(int _baseChannel);
|
xmPlayingId getNextSparePlayingId(int _baseChannel);
|
||||||
|
|
Loading…
Add table
Reference in a new issue