MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / SoundCore_TimerFunc

Function SoundCore_TimerFunc

source/SoundCore.cpp:338–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336// FADE_IN : Switch to FADE_NONE & StopTimer()
337
338static VOID CALLBACK SoundCore_TimerFunc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
339{
340 if((g_pSpeakerVoice == NULL) || (g_pSpeakerVoice->bActive == false))
341 g_FadeType = FADE_NONE;
342
343 // Timer expired
344 if(g_FadeType == FADE_NONE)
345 {
346 SoundCore_StopTimer();
347 return;
348 }
349
350 //
351
352#if 1
353 if(g_FadeType == FADE_IN)
354 g_FadeType = FADE_NONE;
355 else
356 SpkrUpdate_Timer();
357#else
358 const LONG nFadeUnit_Fast = (DSBVOLUME_MAX - DSBVOLUME_MIN) / 10;
359 const LONG nFadeUnit_Slow = (DSBVOLUME_MAX - DSBVOLUME_MIN) / 1000; // Less noisy for 'silence'
360
361 LONG nFadeUnit = g_pSpeakerVoice->bRecentlyActive ? nFadeUnit_Fast : nFadeUnit_Slow;
362 LONG nFadeVolume = g_pSpeakerVoice->nFadeVolume;
363
364 if(g_FadeType == FADE_IN)
365 {
366 if(nFadeVolume == g_pSpeakerVoice->nVolume)
367 {
368 g_FadeType = FADE_NONE;
369 SoundCore_StopTimer();
370 return;
371 }
372
373 nFadeVolume += nFadeUnit;
374
375 if(nFadeVolume > g_pSpeakerVoice->nVolume)
376 nFadeVolume = g_pSpeakerVoice->nVolume;
377 }
378 else // FADE_OUT
379 {
380 if(nFadeVolume == DSBVOLUME_MIN)
381 {
382 g_FadeType = FADE_NONE;
383 SoundCore_StopTimer();
384 return;
385 }
386
387 nFadeVolume -= nFadeUnit;
388
389 if(nFadeVolume < DSBVOLUME_MIN)
390 nFadeVolume = DSBVOLUME_MIN;
391 }
392
393 g_pSpeakerVoice->nFadeVolume = nFadeVolume;
394 g_pSpeakerVoice->lpDSBvoice->SetVolume(nFadeVolume);
395#endif

Callers

nothing calls this directly

Calls 3

SoundCore_StopTimerFunction · 0.85
SpkrUpdate_TimerFunction · 0.85
SetVolumeMethod · 0.45

Tested by

no test coverage detected