|
Player12
An open source football management simulator
|
#include <match_audio.h>
Classes | |
| struct | PendingShot |
Public Member Functions | |
| MatchAudio (bool openDevice=true) | |
| ~MatchAudio () | |
| MatchAudio (const MatchAudio &)=delete | |
| MatchAudio & | operator= (const MatchAudio &)=delete |
| void | setLevels (const Audio::BusLevels &levels) |
| void | update (float wallSeconds, const MatchAudioFrame &frame, std::span< const MatchEvent > events) |
| Audio::Mixer & | mixer () |
| bool | deviceOpen () |
Static Public Member Functions | |
| static Audio::BusLevels | levelsFrom (const Settings &settings) |
Private Types | |
| enum class | Priority : std::uint8_t { MINOR , MAJOR , KEY } |
Private Member Functions | |
| void | react (const MatchEvent &event) |
| void | reactToGoal (const MatchEvent &event) |
| void | reactToMiss (float x) |
| void | detectKicks (const MatchAudioFrame &frame, bool replaying) |
| void | updateCrowd (float wallSeconds, const MatchAudioFrame &frame) |
| bool | allowed (Priority priority) const |
| void | play (Priority priority, Audio::SoundCommand command) |
| void | whistle (Priority priority, Audio::WhistlePattern pattern, float x) |
Private Attributes | |
| std::unique_ptr< Audio::Mixer > | mixerInstance |
| std::unique_ptr< Audio::AudioDevice > | device |
| MatchEventCursor | cursor |
| std::vector< const MatchEvent * > | freshEvents |
| float | playbackSpeed = 1.0f |
| float | previousBallSpeed = 0.0f |
| bool | previousShot = false |
| bool | previousLoose = false |
| PlayerID | previousKicker = 0 |
| bool | haveBallHistory = false |
| float | kickCooldown = 0.0f |
| float | sinceReaction = 10.0f |
| Priority | lastReaction = Priority::MINOR |
| float | tension = 0.0f |
| PendingShot | pendingShot |
| int | latestPeriod = 0 |
| float | latestMinute = -1.0f |
Match audio: turns the live match into sound. Each frame the scene passes a MatchAudioFrame and the engine's event log; new events become crowd reactions, whistles and ball sounds (from the home crowd's point of view), ball launches become kicks panned by the ball's position, and the crowd bed follows the danger on the pitch. Above 4x playback the minor sounds are thinned out; a pause fades the crowd down. Purely presentational: it only reads copies and never feeds anything back into the simulation.
|
strongprivate |
|
explicit |
openDevice false keeps the mixer silent-to-the-world (tests).
| MatchAudio::~MatchAudio | ( | ) |
|
delete |
|
private |
|
private |
replaying: a moment already heard (seek back); history only.
| bool MatchAudio::deviceOpen | ( | ) |
Waits for the output device to open; true when it plays.
|
static |
Master/crowd/effects volumes and mute from the settings.
|
inline |
|
delete |
|
private |
|
private |
|
private |
|
private |
| void MatchAudio::setLevels | ( | const Audio::BusLevels & | levels | ) |
| void MatchAudio::update | ( | float | wallSeconds, |
| const MatchAudioFrame & | frame, | ||
| std::span< const MatchEvent > | events | ||
| ) |
|
private |
|
private |
|
private |
|
private |
Declared after the mixer so it stops pulling audio first.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Latest match moment heard, so a replay of it stays quiet.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Seconds since the last crowd reaction and its priority.
|
private |
Short-lived excitement on top of the crowd bed (can dip below 0).