-
Notifications
You must be signed in to change notification settings - Fork 965
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce SoundVisualization struct to resolve code duplications
- Loading branch information
1 parent
a348a90
commit 34b27ba
Showing
8 changed files
with
31 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <algorithm> | ||
|
||
template <typename SoundType> | ||
struct SoundVisualization { | ||
[[nodiscard]] static constexpr float getScale(float clipSpaceZ) noexcept | ||
{ | ||
return (std::max)(1.0f - clipSpaceZ / 1000.0f, SoundType::kMinScale); | ||
} | ||
|
||
[[nodiscard]] static constexpr float getOpacity(float timeAlive) noexcept | ||
{ | ||
if (timeAlive >= SoundType::kFadeAwayStart) { | ||
return 1.0f - (std::min)((timeAlive - SoundType::kFadeAwayStart) / SoundType::kFadeAwayDuration, 1.0f); | ||
} else { | ||
return 1.0f; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters