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

Class representing a single voice to be mixed with other voices that may play simultaneiously to produce the final sound output. More...

#include <types.hpp>

Public Member Functions

 SoundChannel (const SoundMixer &mixer)
 Constructs a channel owned and used by mixer.
 ~SoundChannel ()
 Destroys sound channel and any related properties it owns.
 SoundChannel (SoundChannel &&other)
 Move constructor.
 SoundChannel (const SoundChannel &other)=delete
 Copy constructor.
SoundChanneloperator= (SoundChannel &&other)
 Move assignment.
SoundChanneloperator= (const SoundChannel &other)=delete
 Copy assignment.
void play ()
 Starts playing sound attached to this channel.
void restart ()
 Start playback with newly configured properties right away.
void pause ()
 Pauses sound attached to this channel.
void stop (uint32_t millis)
 Stops playing sound attached to this channel, fading over the duration specified.
bool isPlaying () const
 Whether or not this channel is currently playing any sound.
bool isPaused () const
 Whether or not this channel is paused.
void setPosition (const glm::vec3 &position)
 Sets the 3D position associated with this channel.
void unsetPosition ()
 Unsets the 3D position associated with this channel, making audio independent of sound source.
void setSound (const Sound &sound)
 Sets which sound this channel may play.
void unsetSound ()
 Unsets whichever sound this channel was reading from earlier.
bool isChannelPositional () const
 Whether this channel will have direction related effects applied when mixed into the final sound output.
void setPlayStart (uint32_t millis)
 When this channel plays, at which point in the input sound clip to start from.
void setPlayEnd (uint32_t millis)
 When this channel plays, what frame on the track is considered the end of the sound clip.
void setLoopCount (int32_t count)
 The number of times the sound should loop before ending, with -1 indicating infinity.
void setLoopStart (uint32_t millis)
 The timestamp in milliseconds at which the sound is restarted after the end of the first iteration, and every subsequent iteration, of the playback loop.
void setFadeInDuration (uint32_t millis)
 At the first playback iteration, the period over which the sound goes from quiet to its full volume.
void setGain (float gain)
 Sets the factor by which the sound from this channel will be multiplied.
float getGain () const
 Gets the factor by which the sound from this channel is multiplied.
void addTag (const std::string &tag)
 Adds a string tag to this channel, allowing channels sharing the same tag to be controlled together.
void removeTag (const std::string &tag)
 Removes a string tag from this channel.
void removeAllTags ()
 Removes all tags associated with this channel.
std::vector< std::string > getTags () const
 Returns all the tags associated with this channel.

Private Attributes

std::unique_ptr< MIX_Track, decltype(&MIX_DestroyTrack)> mTrack
 The underlying SDL3_mixer track object object.
SDL_PropertiesID mProperties
 The SDL properties controlling the playback for this track.

Detailed Description

Class representing a single voice to be mixed with other voices that may play simultaneiously to produce the final sound output.

Defines properties to control the playback of the audio being read from – which segment of the audio to play, how many times the audio should be looped, whether the audio should fade in and out.

@NOTE: Currently no more than an abstraction of SDL_mixer tracks.

Member Function Documentation

◆ setGain()

void SoundChannel::setGain ( float gain)

Sets the factor by which the sound from this channel will be multiplied.

Accepts any value greater than 0.


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