Player12
An open source football management simulator
Loading...
Searching...
No Matches
Audio::Voice Class Reference

#include <synth.h>

Public Member Functions

void start (const SoundCommand &command, std::uint32_t seed)
 
bool render (float *out, int frames)
 
void stop ()
 
bool active () const
 
Sound sound () const
 
float age () const
 

Private Member Functions

float renderKick ()
 
float renderNet ()
 
float renderWoodwork ()
 
float renderWhistle ()
 
float renderCrowdVowel (float firstFormant, float secondFormant)
 
float renderCrowdWhistles ()
 
float renderApplause (float &right)
 
float crowdEnvelope () const
 
float whistleEnvelope () const
 
void updateControl ()
 

Private Attributes

SoundCommand command
 
bool playing = false
 
float time = 0.0f
 
float duration = 0.0f
 
float delay = 0.0f
 
float leftGain = 0.0f
 
float rightGain = 0.0f
 
int controlCounter = 0
 
Noise noise
 
Noise noiseRight {0x1234567U}
 
Svf filterA
 
Svf filterB
 
Svf filterC
 
Svf filterD
 
Darken toneLeft
 
Darken toneRight
 
std::array< float, PARTIALS > phase {}
 
std::array< float, PARTIALS > frequency {}
 
std::array< float, PARTIALS > amplitude {}
 
std::array< float, PARTIALS > decay {}
 
std::array< float, PARTIALS > onset {}
 
float lfoPhase = 0.0f
 
float glide = 0.0f
 
float excitation = 0.0f
 
float excitationRight = 0.0f
 
float envelope = 0.0f
 
float attack = 0.1f
 
float hold = 0.5f
 
float release = 1.0f
 

Static Private Attributes

static constexpr int PARTIALS = 6
 

Detailed Description

One playing sound. start() prepares it from a command; render() adds its stereo output to out and returns false once finished. All state lives inline so a fixed pool of voices never allocates.

Member Function Documentation

◆ active()

bool Audio::Voice::active ( ) const
inline

◆ age()

float Audio::Voice::age ( ) const
inline

Seconds played so far (for voice stealing).

◆ crowdEnvelope()

float Audio::Voice::crowdEnvelope ( ) const
private

Crowd envelope: attack, hold scaled by intensity, release.

◆ render()

bool Audio::Voice::render ( float *  out,
int  frames 
)

◆ renderApplause()

float Audio::Voice::renderApplause ( float &  right)
private

◆ renderCrowdVowel()

float Audio::Voice::renderCrowdVowel ( float  firstFormant,
float  secondFormant 
)
private

◆ renderCrowdWhistles()

float Audio::Voice::renderCrowdWhistles ( )
private

◆ renderKick()

float Audio::Voice::renderKick ( )
private

◆ renderNet()

float Audio::Voice::renderNet ( )
private

◆ renderWhistle()

float Audio::Voice::renderWhistle ( )
private

◆ renderWoodwork()

float Audio::Voice::renderWoodwork ( )
private

◆ sound()

Sound Audio::Voice::sound ( ) const
inline

◆ start()

void Audio::Voice::start ( const SoundCommand &  command,
std::uint32_t  seed 
)

◆ stop()

void Audio::Voice::stop ( )
inline

◆ updateControl()

void Audio::Voice::updateControl ( )
private

◆ whistleEnvelope()

float Audio::Voice::whistleEnvelope ( ) const
private

0..1 envelope of the whistle pattern at the current time.

Member Data Documentation

◆ amplitude

std::array<float, PARTIALS> Audio::Voice::amplitude {}
private

◆ attack

float Audio::Voice::attack = 0.1f
private

◆ command

SoundCommand Audio::Voice::command
private

◆ controlCounter

int Audio::Voice::controlCounter = 0
private

◆ decay

std::array<float, PARTIALS> Audio::Voice::decay {}
private

◆ delay

float Audio::Voice::delay = 0.0f
private

◆ duration

float Audio::Voice::duration = 0.0f
private

◆ envelope

float Audio::Voice::envelope = 0.0f
private

Crowd envelope, refreshed at control rate.

◆ excitation

float Audio::Voice::excitation = 0.0f
private

◆ excitationRight

float Audio::Voice::excitationRight = 0.0f
private

◆ filterA

Svf Audio::Voice::filterA
private

◆ filterB

Svf Audio::Voice::filterB
private

◆ filterC

Svf Audio::Voice::filterC
private

◆ filterD

Svf Audio::Voice::filterD
private

◆ frequency

std::array<float, PARTIALS> Audio::Voice::frequency {}
private

◆ glide

float Audio::Voice::glide = 0.0f
private

◆ hold

float Audio::Voice::hold = 0.5f
private

◆ leftGain

float Audio::Voice::leftGain = 0.0f
private

◆ lfoPhase

float Audio::Voice::lfoPhase = 0.0f
private

◆ noise

Noise Audio::Voice::noise
private

◆ noiseRight

Noise Audio::Voice::noiseRight {0x1234567U}
private

◆ onset

std::array<float, PARTIALS> Audio::Voice::onset {}
private

◆ PARTIALS

constexpr int Audio::Voice::PARTIALS = 6
staticconstexprprivate

◆ phase

std::array<float, PARTIALS> Audio::Voice::phase {}
private

◆ playing

bool Audio::Voice::playing = false
private

◆ release

float Audio::Voice::release = 1.0f
private

◆ rightGain

float Audio::Voice::rightGain = 0.0f
private

◆ time

float Audio::Voice::time = 0.0f
private

◆ toneLeft

Darken Audio::Voice::toneLeft
private

◆ toneRight

Darken Audio::Voice::toneRight
private

The documentation for this class was generated from the following files: