1#ifndef TOYMAKER_SOUNDTYPES_H
2#define TOYMAKER_SOUNDTYPES_H
4#include <SDL3_mixer/SDL_mixer.h>
31 Sound(MIX_Audio* sound);
54 std::unique_ptr<MIX_Audio,
decltype(&MIX_DestroyAudio)>
mAudio;
56 friend class SoundChannel;
119 void stop(uint32_t millis);
215 void addTag(
const std::string& tag);
233 std::vector<std::string>
getTags()
const;
240 std::unique_ptr<MIX_Track,
decltype(&MIX_DestroyTrack)>
mTrack;
288 void stopTagged(
const std::string& tag, uint32_t millis);
307 std::unique_ptr<MIX_Mixer,
decltype(&MIX_DestroyMixer)>
mMixer;
309 friend class SoundChannel;
342 std::shared_ptr<IResource>
createResource(
const nlohmann::json& methodParameters)
override;
ResourceConstructor(int explicitlyInitializeMe)
Definition resource_database.hpp:488
Resource(int explicitlyInitializeMe)
Definition resource_database.hpp:386
Class representing a single voice to be mixed with other voices that may play simultaneiously to prod...
Definition types.hpp:72
SoundChannel(const SoundChannel &other)=delete
Copy constructor.
void unsetSound()
Unsets whichever sound this channel was reading from earlier.
Definition types.cpp:195
void removeAllTags()
Removes all tags associated with this channel.
Definition types.cpp:244
SoundChannel(const SoundMixer &mixer)
Constructs a channel owned and used by mixer.
Definition types.cpp:78
SoundChannel & operator=(const SoundChannel &other)=delete
Copy assignment.
void pause()
Pauses sound attached to this channel.
Definition types.cpp:128
std::vector< std::string > getTags() const
Returns all the tags associated with this channel.
Definition types.cpp:248
void setPlayEnd(uint32_t millis)
When this channel plays, what frame on the track is considered the end of the sound clip.
Definition types.cpp:179
void setLoopStart(uint32_t millis)
The timestamp in milliseconds at which the sound is restarted after the end of the first iteration,...
Definition types.cpp:211
~SoundChannel()
Destroys sound channel and any related properties it owns.
Definition types.hpp:84
void setSound(const Sound &sound)
Sets which sound this channel may play.
Definition types.cpp:186
bool isPlaying() const
Whether or not this channel is currently playing any sound.
Definition types.cpp:150
void setPlayStart(uint32_t millis)
When this channel plays, at which point in the input sound clip to start from.
Definition types.cpp:174
void setPosition(const glm::vec3 &position)
Sets the 3D position associated with this channel.
Definition types.cpp:158
void setGain(float gain)
Sets the factor by which the sound from this channel will be multiplied.
Definition types.cpp:225
void play()
Starts playing sound attached to this channel.
Definition types.cpp:110
SDL_PropertiesID mProperties
The SDL properties controlling the playback for this track.
Definition types.hpp:246
void removeTag(const std::string &tag)
Removes a string tag from this channel.
Definition types.cpp:240
float getGain() const
Gets the factor by which the sound from this channel is multiplied.
Definition types.cpp:231
bool isChannelPositional() const
Whether this channel will have direction related effects applied when mixed into the final sound outp...
Definition types.cpp:167
void unsetPosition()
Unsets the 3D position associated with this channel, making audio independent of sound source.
Definition types.cpp:163
void addTag(const std::string &tag)
Adds a string tag to this channel, allowing channels sharing the same tag to be controlled together.
Definition types.cpp:235
void restart()
Start playback with newly configured properties right away.
Definition types.cpp:123
void setFadeInDuration(uint32_t millis)
At the first playback iteration, the period over which the sound goes from quiet to its full volume.
Definition types.cpp:218
void stop(uint32_t millis)
Stops playing sound attached to this channel, fading over the duration specified.
Definition types.cpp:133
SoundChannel & operator=(SoundChannel &&other)
Move assignment.
Definition types.cpp:97
std::unique_ptr< MIX_Track, decltype(&MIX_DestroyTrack)> mTrack
The underlying SDL3_mixer track object object.
Definition types.hpp:240
bool isPaused() const
Whether or not this channel is paused.
Definition types.cpp:154
void setLoopCount(int32_t count)
The number of times the sound should loop before ending, with -1 indicating infinity.
Definition types.cpp:204
std::shared_ptr< IResource > createResource(const nlohmann::json &methodParameters) override
Creates a Sound resource based on its parameters.
Definition types.cpp:266
static std::string getResourceConstructorName()
Gets the resource constructor type string for this constructor.
Definition types.hpp:331
SoundFromFile()
Creates a SoundFromFile object.
Definition types.cpp:36
Class managing a group of sound channels, as many as permitted by the underlying hardware,...
Definition types.hpp:256
void pauseTagged(const std::string &tag)
Pauses playback of all channels marked with a specific tag.
Definition types.cpp:68
SoundMixer()
Creates a mixer for the default audio playback device.
Definition types.cpp:38
void setGainTagged(const std::string &tag, float gain)
Sets the gain applied to all channels marked with a particular tag.
Definition types.cpp:57
void resumeTagged(const std::string &tag)
Resumes playback of all channels marked with a specific tag.
Definition types.cpp:73
float getGainMaster() const
Returns the gain applied to the mixed sound output applied by this mixer.
Definition types.cpp:47
void setGainMaster(float gain)
Sets the factor by which the sound returned by this mixer is multiplied.
Definition types.cpp:51
void stopTagged(const std::string &tag, uint32_t millis)
Stops the playback of all channels marked with a specific tag.
Definition types.cpp:63
std::unique_ptr< MIX_Mixer, decltype(&MIX_DestroyMixer)> mMixer
The SDL3_mixer object this class is a wrapper over.
Definition types.hpp:307
Class representing a single playable piece of audio.
Definition types.hpp:19
int32_t getDuration() const
Returns the duration of this sound in millis, with -1 indicating the audio is infinite.
Definition types.cpp:31
Sound & operator=(Sound &&other)
Move assignment.
Definition types.cpp:21
std::unique_ptr< MIX_Audio, decltype(&MIX_DestroyAudio)> mAudio
The underlying SDL3_mixer audio object.
Definition types.hpp:54
Sound(const Sound &other)=delete
Copy constructor.
Sound(MIX_Audio *sound)
Initializer for this sound.
Definition types.cpp:11
Sound & operator=(const Sound &other)=delete
Copy assignment.
static std::string getResourceTypeName()
The id string representing this kind of resource.
Definition types.hpp:25
Namespace containing all class definitions and functions related to the ToyMaker engine.
Definition application.hpp:26
Headers relating to resources and their management for a given project.