libSDL2pp
C++ bindings/wrapper for SDL2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SDL2pp::Chunk Class Reference

Fragment of audio data. More...

#include <SDL2pp/Chunk.hh>

Public Member Functions

 Chunk (Mix_Chunk *chunk)
 Construct from existing Mix_Chunk structure.
 
 Chunk (const std::string &file)
 Load file for use as a sample.
 
 Chunk (RWops &rwops)
 Load sample using RWops.
 
 ~Chunk ()
 Destructor.
 
 Chunk (Chunk &&other) noexcept
 Move constructor.
 
Chunkoperator= (Chunk &&other) noexcept
 Move assignment operator.
 
 Chunk (const Chunk &other)=delete
 Deleted copy constructor.
 
Chunkoperator= (const Chunk &other)=delete
 Deleted assignment operator.
 
Mix_Chunk * Get () const
 Get pointer to managed Mix_Chunk structure.
 
int SetVolume (int volume)
 Set volume of a chunk.
 
int GetVolume () const
 Get volume of a chunk.
 

Detailed Description

Fragment of audio data.

Constructor & Destructor Documentation

◆ Chunk() [1/5]

SDL2pp::Chunk::Chunk ( Mix_Chunk *  chunk)
explicit

Construct from existing Mix_Chunk structure.

Parameters
[in]chunkExisting Mix_Chunk to manage

◆ Chunk() [2/5]

SDL2pp::Chunk::Chunk ( const std::string &  file)
explicit

Load file for use as a sample.

Parameters
[in]fileFile name to load sample from
Exceptions
SDL2pp::Exception
See also
https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC19

◆ Chunk() [3/5]

SDL2pp::Chunk::Chunk ( RWops rwops)
explicit

Load sample using RWops.

Parameters
[in]rwopsSDL2pp::RWops used to access sample data
Exceptions
SDL2pp::Exception
See also
https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC20

◆ ~Chunk()

SDL2pp::Chunk::~Chunk ( )

Destructor.

See also
https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC24
Note
Despite what Mix_FreeChunk() documentation (and even comment in function implementation) says, right after the named comment there's a code which stops playback of any channel which plays the chunk being freed. Thus, it is safe to destroy Chunk before destroying Mixer, even if it still plays the chunk.

◆ Chunk() [4/5]

SDL2pp::Chunk::Chunk ( Chunk &&  other)
noexcept

Move constructor.

Parameters
[in]otherSDL2pp::Chunk object to move data from

◆ Chunk() [5/5]

SDL2pp::Chunk::Chunk ( const Chunk other)
delete

Deleted copy constructor.

This class is not copyable

Member Function Documentation

◆ Get()

Mix_Chunk * SDL2pp::Chunk::Get ( ) const

Get pointer to managed Mix_Chunk structure.

Returns
Pointer to managed Mix_Chunk structure

◆ GetVolume()

int SDL2pp::Chunk::GetVolume ( ) const

Get volume of a chunk.

Returns
Current volume setting
See also
https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC23

◆ operator=() [1/2]

Chunk & SDL2pp::Chunk::operator= ( Chunk &&  other)
noexcept

Move assignment operator.

Parameters
[in]otherSDL2pp::Chunk object to move data from
Returns
Reference to self

◆ operator=() [2/2]

Chunk & SDL2pp::Chunk::operator= ( const Chunk other)
delete

Deleted assignment operator.

This class is not copyable

◆ SetVolume()

int SDL2pp::Chunk::SetVolume ( int  volume)

Set volume of a chunk.

Parameters
[in]volumeThe volume to use from 0 to MIX_MAX_VOLUME(128)
Returns
Previous volume setting
See also
https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC23

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