MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / ImUpdate

Function ImUpdate

TheForceEngine/TFE_Jedi/IMuse/imuse.cpp:646–710  ·  view source on GitHub ↗

////////////////////////////////////////////////////// Internal "main loop" ////////////////////////////////////////////////////// Main update entry point which is called at a fixed rate (see ImGetDeltaTime). This is responsible for updating the midi players and updating digital audio playback.

Source from the content-addressed store, hash-verified

644 // Main update entry point which is called at a fixed rate (see ImGetDeltaTime).
645 // This is responsible for updating the midi players and updating digital audio playback.
646 void ImUpdate()
647 {
648 const s32 dtInMicrosec = ImGetDeltaTime();
649
650 // Update Midi and Audio
651 ImUpdateMidi();
652 if (s_imPause)
653 {
654 return;
655 }
656
657 // Update faders and deferred commands that update at a rate of 60 fps.
658 s_iMuseTimeInMicrosec += dtInMicrosec;
659 while (s_iMuseTimeInMicrosec >= 16667)
660 {
661 s_iMuseTimeInMicrosec -= 16667;
662 s32 prevTime = s_iMuseSystemTime;
663 s_iMuseSystemTime++; // increment the system time every 1/60th of a second.
664
665 ImUpdateSoundFaders();
666 ImHandleDeferredCommands();
667 }
668
669 // Update Group Volumes every 6 "frames".
670 s_iMuseTimeLong += dtInMicrosec;
671 while (s_iMuseTimeLong >= 100000) // ~6 frames @ 60Hz
672 {
673 s_iMuseTimeLong -= 100000;
674
675 s32 musicVolume = ImSetGroupVol(groupMusic, imGetValue);
676 ImSoundId soundId = IM_NULL_SOUNDID;
677 do
678 {
679 soundId = ImGetNextSound(soundId);
680 if (soundId)
681 {
682 if (ImGetParam(soundId, soundGroup) == groupVoice)
683 {
684 musicVolume = (musicVolume * 82) >> imVolumeShift;
685 break;
686 }
687 }
688 } while (soundId);
689
690 s32 dippedMusicVolume = ImSetGroupVol(groupDippedMusic, imGetValue);
691 if (dippedMusicVolume > musicVolume)
692 {
693 dippedMusicVolume -= 6;
694 if (dippedMusicVolume <= musicVolume)
695 {
696 dippedMusicVolume = musicVolume;
697 }
698 ImSetGroupVol(groupDippedMusic, dippedMusicVolume);
699 }
700 else if (dippedMusicVolume != musicVolume)
701 {
702 dippedMusicVolume += 3;
703 if (dippedMusicVolume >= musicVolume)

Callers

nothing calls this directly

Calls 7

ImGetDeltaTimeFunction · 0.85
ImUpdateMidiFunction · 0.85
ImUpdateSoundFadersFunction · 0.85
ImHandleDeferredCommandsFunction · 0.85
ImSetGroupVolFunction · 0.85
ImGetNextSoundFunction · 0.85
ImGetParamFunction · 0.85

Tested by

no test coverage detected