SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SDL::Track Class Reference

An opaque object that represents a source of sound output to be mixed. More...

Inheritance diagram for SDL::Track:
Inheritance graph
[legend]

Public Member Functions

constexpr Track (std::nullptr_t=nullptr) noexcept
 Default ctor.
 
constexpr Track (TrackRaw resource) noexcept
 Constructs from raw Track. More...
 
constexpr Track (const Track &other) noexcept=delete
 Copy constructor.
 
constexpr Track (Track &&other) noexcept
 Move constructor.
 
constexpr Track (const TrackRef &other)=delete
 
constexpr Track (TrackRef &&other)=delete
 
 Track (MixerRef mixer)
 Create a new track on a mixer. More...
 
 ~Track ()
 Destructor.
 
constexpr Trackoperator= (Track &&other) noexcept
 Assignment operator.
 
Trackoperator= (const Track &other)=delete
 Assignment operator.
 
constexpr TrackRaw get () const noexcept
 Retrieves underlying TrackRaw.
 
constexpr TrackRaw release () noexcept
 Retrieves underlying TrackRaw and clear this.
 
constexpr auto operator<=> (const Track &other) const noexcept=default
 Comparison.
 
constexpr operator bool () const noexcept
 Converts to bool.
 
void Destroy ()
 Destroy the specified track. More...
 
PropertiesRef GetProperties ()
 Get the properties associated with a track. More...
 
MixerRef GetMixer ()
 Get the Mixer that owns a Track. More...
 
void SetAudio (AudioRef audio)
 Set a Track's input to a Audio. More...
 
void SetAudioStream (AudioStreamRef stream)
 Set a Track's input to an AudioStream. More...
 
void SetIOStream (IOStreamRef io, bool closeio=false)
 Set a Track's input to an IOStream. More...
 
void SetRawIOStream (IOStreamRef io, const AudioSpec &spec, bool closeio=false)
 Set a Track's input to an IOStream providing raw PCM data. More...
 
void Tag (StringParam tag)
 Assign an arbitrary tag to a track. More...
 
void Untag (StringParam tag)
 Remove an arbitrary tag from a track. More...
 
OwnArray< char * > GetTags ()
 Get the tags currently associated with a track. More...
 
void SetPlaybackPosition (Sint64 frames)
 Seek a playing track to a new position in its input. More...
 
Sint64 GetPlaybackPosition ()
 Get the current input position of a playing track. More...
 
Sint64 GetFadeFrames ()
 Query whether a given track is fading. More...
 
int GetLoops ()
 Query how many loops remain for a given track. More...
 
void SetLoops (int num_loops)
 Change the number of times a currently-playing track will loop. More...
 
AudioRef GetAudio ()
 Query the Audio assigned to a track. More...
 
AudioStreamRef GetAudioStream ()
 Query the AudioStream assigned to a track. More...
 
Sint64 GetRemaining ()
 Return the number of sample frames remaining to be mixed in a track. More...
 
Sint64 MSToFrames (Milliseconds ms)
 Convert milliseconds to sample frames for a track's current format. More...
 
Milliseconds FramesToMS (Sint64 frames)
 Convert sample frames for a track's current format to milliseconds. More...
 
void Play (PropertiesRef options=nullptr)
 Start (or restart) mixing a track for playback. More...
 
bool Stop (Sint64 fade_out_frames)
 Halt a currently-playing track, possibly fading out over time. More...
 
bool Pause ()
 Pause a currently-playing track. More...
 
bool Resume ()
 Resume a currently-paused track. More...
 
bool Playing ()
 Query if a track is currently playing. More...
 
bool Paused ()
 Query if a track is currently paused. More...
 
void SetGain (float gain)
 Set a track's gain control. More...
 
float GetGain ()
 Get a track's gain control. More...
 
void SetFrequencyRatio (float ratio)
 Change the frequency ratio of a track. More...
 
float GetFrequencyRatio ()
 Query the frequency ratio of a track. More...
 
void SetOutputChannelMap (std::span< const int > chmap)
 Set the current output channel map of a track. More...
 
void SetStereo (const StereoGains &gains)
 Force a track to stereo output, with optionally left/right panning. More...
 
void Set3DPosition (const Point3D &position)
 Set a track's position in 3D space. More...
 
Point3D Get3DPosition ()
 Get a track's current position in 3D space. More...
 
void SetGroup (GroupRef group)
 Assign a track to a mixing group. More...
 
void SetStoppedCallback (TrackStoppedCallback cb, void *userdata)
 Set a callback that fires when a Track is stopped. More...
 
void SetStoppedCallback (TrackStoppedCB cb)
 Set a callback that fires when a Track is stopped. More...
 
void SetRawCallback (TrackMixCallback cb, void *userdata)
 Set a callback that fires when a Track has initial decoded audio. More...
 
void SetRawCallback (TrackMixCB cb)
 Set a callback that fires when a Track has initial decoded audio. More...
 
void SetCookedCallback (TrackMixCallback cb, void *userdata)
 Set a callback that fires when the mixer has transformed a track's audio. More...
 
void SetCookedCallback (TrackMixCB cb)
 Set a callback that fires when the mixer has transformed a track's audio. More...
 

Detailed Description

A Mixer has an arbitrary number of tracks, and each track manages its own unique audio to be mixed together.

Tracks also have other properties: gain, loop points, fading, 3D position, and other attributes that alter the produced sound; many can be altered during playback.

Since
This datatype is available since SDL_mixer 3.0.0.
Category:
Resource

Constructor & Destructor Documentation

◆ Track()

constexpr SDL::Track::Track ( TrackRaw  resource)
inlineexplicitconstexprnoexcept
Parameters
resourcea TrackRaw to be wrapped.

This assumes the ownership, call release() if you need to take back.


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