ToyMaker Game Engine 0.0.2
ToyMaker is a game engine developed and maintained by Zoheb Shujauddin.
Loading...
Searching...
No Matches
ToyMaker::SoundSystem Class Reference

System responsible for servicing sound playback commands from the game and managing platform audio hardware. More...

#include <system.hpp>

Inheritance diagram for ToyMaker::SoundSystem:
ToyMaker::System< SoundSystem, std::tuple<>, std::tuple<> >

Public Member Functions

 SoundSystem (std::weak_ptr< ECSWorld > world)
 Constructs a new SoundSystem object.
bool isSingleton () const override
 Informs this System's ECSWorld that the SoundSystem is a singleton, i.e., there should not be more than one instance of it in the entire project, regardless of how many ECSWorlds are present.
void onApplicationInitialize ()
 Creates a sound mixer device object to be managed by this system.
void onApplicationEnd ()
 Called during the application shutdown procedure, destroying owned sound mixer device.
std::unique_ptr< SoundChannelcreateChannel ()
 Returns a single sound channel, to be managed by the caller, mixed with other channels by this system.
float getMasterGain () const
 Returns a value from 0 to 1, representing the factor by which the mixed sound is multiplied.
void setMasterGain (float newVolume)
 Sets the volume of the mixed output sound.

Static Public Member Functions

static std::string getSystemTypeName ()
 The system type string associated with the SoundSystem.

Private Attributes

std::unique_ptr< SoundMixermMixer {}
 The sound mixer managed by this system.

Detailed Description

System responsible for servicing sound playback commands from the game and managing platform audio hardware.

@NOTE: Mainly just a simple wrapper over SDL_mixer, since I haven't fully worked out quite how I'd like to manage this

Constructor & Destructor Documentation

◆ SoundSystem()

ToyMaker::SoundSystem::SoundSystem ( std::weak_ptr< ECSWorld > world)
inlineexplicit

Constructs a new SoundSystem object.

Parameters
worldThe world this SoundSystem will belong to, which is always the prototype ECSWorld.

Member Function Documentation

◆ createChannel()

std::unique_ptr< SoundChannel > SoundSystem::createChannel ( )

Returns a single sound channel, to be managed by the caller, mixed with other channels by this system.

As a general rule, use this for sounds that play continuously.

◆ getMasterGain()

float SoundSystem::getMasterGain ( ) const

Returns a value from 0 to 1, representing the factor by which the mixed sound is multiplied.

0 means silence, while 1 means the mixed sound is left untouched.

◆ getSystemTypeName()

std::string ToyMaker::SoundSystem::getSystemTypeName ( )
inlinestatic

The system type string associated with the SoundSystem.

Returns
std::string This system's system type string.

◆ isSingleton()

bool ToyMaker::SoundSystem::isSingleton ( ) const
inlineoverride

Informs this System's ECSWorld that the SoundSystem is a singleton, i.e., there should not be more than one instance of it in the entire project, regardless of how many ECSWorlds are present.

Return values
trueSoundSystem is a singleton System;

@TODO: This is obviously stupid and I should do something about it.

◆ onApplicationEnd()

void SoundSystem::onApplicationEnd ( )

Called during the application shutdown procedure, destroying owned sound mixer device.

@TODO: Clarify relationship between singleton systems and ECS. Right now, this call is made manually by Application, explicitly once per singleton system.

◆ onApplicationInitialize()

void SoundSystem::onApplicationInitialize ( )

Creates a sound mixer device object to be managed by this system.

@TODO: Clarify relationship between singleton systems and ECS. Right now, this call is made manually by Application, explicitly once per singleton system.

◆ setMasterGain()

void SoundSystem::setMasterGain ( float newVolume)

Sets the volume of the mixed output sound.

0 means silence, while 1 means the mixed sound is untouched.

Member Data Documentation

◆ mMixer

std::unique_ptr<SoundMixer> ToyMaker::SoundSystem::mMixer {}
private

The sound mixer managed by this system.

Allocated once SoundSystem::onApplicationInitialize is called.


The documentation for this class was generated from the following files:
  • ToyMaker_Main/include/toymaker/engine/sound/system.hpp
  • ToyMaker_Main/src/sound/system.cpp