- fixed the fire sound in the intro.

This commit is contained in:
Christoph Oelckers 2019-12-27 23:09:05 +01:00
parent bea7391ac9
commit 93fccfd767
3 changed files with 24 additions and 27 deletions

View file

@ -1343,9 +1343,7 @@ void FinishLevel()
if (levelnum != kMap20) if (levelnum != kMap20)
{ {
EraseScreen(4); EraseScreen(4);
SetLocalChan(1); PlayLocalSound(StaticSound[59], 0, true);
PlayLocalSound(StaticSound[59], 0);
SetLocalChan(0);
videoNextPage(); videoNextPage();
WaitTicks(12); WaitTicks(12);
WaitVBL(); WaitVBL();
@ -2570,10 +2568,7 @@ void DoTitle()
SetOverscan(BASEPAL); SetOverscan(BASEPAL);
GrabPalette(); GrabPalette();
SetLocalChan(1); PlayLocalSound(StaticSound[59], 0, true);
PlayLocalSound(StaticSound[59], 0);
SetLocalChan(0);
EraseScreen(4); EraseScreen(4);

View file

@ -160,11 +160,6 @@ enum
nSwirlyChan4, nSwirlyChan4,
}; };
void SetLocalChan(int c)
{
nLocalChan = c;
}
//========================================================================== //==========================================================================
// //
// //
@ -337,33 +332,41 @@ void BendAmbientSound(void)
// //
//========================================================================== //==========================================================================
void PlayLocalSound(short nSound, short nRate) void PlayLocalSound(short nSound, short nRate, bool unattached)
{ {
if (nSound < 0 || nSound >= kMaxSounds || !soundEngine->isValidSoundId(nSound + 1)) if (nSound < 0 || nSound >= kMaxSounds || !soundEngine->isValidSoundId(nSound + 1))
{ {
initprintf("PlayLocalSound: Invalid sound nSound == %i, nRate == %i\n", nSound, nRate); initprintf("PlayLocalSound: Invalid sound nSound == %i, nRate == %i\n", nSound, nRate);
return; return;
} }
int bLoop = looped[nSound];
if (nLocalChan == nAmbientChannel) if (nLocalChan == nAmbientChannel)
nAmbientChannel = -1; nAmbientChannel = -1;
int bLoop = looped[nSound];
ActiveSound* pASound = &sActiveSound[nLocalChan]; ActiveSound* pASound = nullptr;
if (pASound->snd_channel != nullptr)
soundEngine->StopChannel(pASound->snd_channel);
// There is exactly one occurence in the entire game which alters the pitch. if (!unattached)
pASound->snd_channel = soundEngine->StartSound(SOURCE_Unattached, nullptr, nullptr, CHAN_BODY, CHANF_OVERLAP, nSound + 1, 1.f, ATTN_NONE, nullptr);
if (nRate && pASound->snd_channel)
{ {
float ratefac = (11025 + nRate) / 11025.f; pASound = &sActiveSound[nLocalChan];
soundEngine->SetPitch(pASound->snd_channel, ratefac); if (pASound->snd_channel != nullptr)
soundEngine->StopChannel(pASound->snd_channel);
} }
pASound->snd_id = nSound; // There is exactly one occurence in the entire game which alters the pitch, and that's the laugh on the logo.
auto chan = soundEngine->StartSound(SOURCE_Unattached, nullptr, nullptr, CHAN_BODY, CHANF_OVERLAP, nSound + 1, 1.f, ATTN_NONE, nullptr);
if (nRate && chan)
{
float ratefac = (11025 + nRate) / 11025.f;
soundEngine->SetPitch(chan, ratefac);
}
if (pASound)
{
pASound->snd_id = nSound;
pASound->snd_channel = chan;
}
} }
//========================================================================== //==========================================================================

View file

@ -125,11 +125,10 @@ int fadecdaudio();
int LocalSoundPlaying(); int LocalSoundPlaying();
void LoadFX(); void LoadFX();
void StopAllSounds(); void StopAllSounds();
void SetLocalChan(int nChannel);
int GetLocalSound(); int GetLocalSound();
void UpdateLocalSound(); void UpdateLocalSound();
void StopLocalSound(); void StopLocalSound();
void PlayLocalSound(short nSound, short val); void PlayLocalSound(short nSound, short val, bool unattached = false);
int LoadSound(const char* sound); int LoadSound(const char* sound);
void BendAmbientSound(); void BendAmbientSound();