Audio Player

namespace tnt
class AudioPlayer
#include <AudioPlayer.hpp>

The class used to handle audio playing.

Public Functions

AudioPlayer(int frequency, unsigned short format, int channels, int chunksize) noexcept

Creates a new AudioPlayer for a certain audio format.

Parameters
  • frequency: The frequency the audio should be played.

  • format: The format of the audio.

  • channels: The number of the channels.

  • chunksize: The size of the chunk.

~AudioPlayer() noexcept

Close the audio player.

void PlayMusic(std::string_view filename, int loops)

Plays the music of filename loops many times. If loops is -1, it plays the music ~65000 times.

Parameters
  • filename: The name of the file to play.

  • loops: The number of times the music should be played.

void PauseMusic()

Pauses the player if a music being played.

void ResumeMusic()

Resumes the player if it was paused.

void PlaySFX(std::string_view filename, int channel, int loops)

Play a .sfx file on the given channel loops many times. If loops is -1, it plays the music ~65000 times.

Parameters
  • filename: The name of the sfx file.

  • channel: The id of the channel where the music should be played.

  • loops: The number of times the sfx should be played.