Engine::Audio::AudioBuffer

Engine::Audio::AudioBuffer

Module: An example game engine / Audio buffers and devices

A simple audio buffer to hold PCM samples More…

#include <AudioBuffer.hpp>

Public Classes

Name
struct TypedAudioData Use this to populate the buffer.

Public Types

Name
enum class Type { UNKNOWN = 0, INT_8 = 1 « 1, INT_16 = 1 « 2, INT_24 = 1 « 3, INT_32 = 1 « 4, FLOAT_32 = 1 « 5}Different type of audio formats.
template <typename T > using Utils::ArrayView< T > AudioData
typedef AudioData< uint8_t > AudioData8U

Public Functions

Name
AudioBuffer(const std::string & filename)Constructor for Audio::AudioBuffer.
virtual ~AudioBuffer() =defaultAudio::AudioBuffer destructor.
void play(AudioManager & manager) constPlay this buffer.
void stop(AudioManager & manager) constStop this buffer playing.
void loop(AudioManager & manager) constLoop this buffer forever.
void setData(const TypedAudioData & data)
template <size_t Size> void setDataMultiple(const TypedAudioData data[Size])
void setData(const TypedAudioData data[], size_t size)Some deprecated function.
void setCallback(Callback callback)Set the callback function.
void setCallback2(Callback2 callback, void * user)Set the callback function.

Protected Functions

Name
float * getData()

Protected Attributes

Name
bool playing

Friends

Name
class AudioManager
void Audio::doSomething(AudioBuffer & buffer)

Detailed Description

class Engine::Audio::AudioBuffer;

A simple audio buffer to hold PCM samples

Author: Matus Novak

Date: 2017-2019

Note:

  • Some random note
  • Some second random note

Bug: Some random bug

Some other random bug

Test: Some random test description

Todo: Some random todo

Warning: Some random warning

Precondition: First initialize the system.

Lorem ipsum donor

// Some random code
using namespace Engine;

Audio::AudioBuffer buffer("path/to/file.wav");
buffer.play(audioManager);

More detailed description!

// Another code sample
#include <iostream>
using namespace Engine;
Audio::AudioBuffer buffer("path/to/file.wav");
std::cout << buffer.play(...) << std::endl;

Public Types Documentation

enum Type

Enumerator Value Description
UNKNOWN 0 Dont use this
INT_8 1 « 1 8-bit signed integer
INT_16 1 « 2 16-bit signed integer
INT_24 1 « 3 24-bit signed integer
INT_32 1 « 4 32-bit signed integer
FLOAT_32 1 « 5 32-bit float

Different type of audio formats.

using AudioData

template <typename T >
using Engine::Audio::AudioBuffer::AudioData =  Utils::ArrayView<T>;

typedef AudioData8U

typedef AudioData<uint8_t> Engine::Audio::AudioBuffer::AudioData8U;

Public Functions Documentation

function AudioBuffer

explicit AudioBuffer(
    const std::string & filename
)

Constructor for Audio::AudioBuffer.

function ~AudioBuffer

virtual ~AudioBuffer() =default

Audio::AudioBuffer destructor.

function play

void play(
    AudioManager & manager
) const

Play this buffer.

Parameters:

  • manager Which manager to play the sound with

Exceptions:

  • Exception If this buffer is already playing

function stop

void stop(
    AudioManager & manager
) const

Stop this buffer playing.

Parameters:

  • manager Which manager to stop the sound with

Exceptions:

  • Exception If this buffer is already stopped

function loop

void loop(
    AudioManager & manager
) const

Loop this buffer forever.

Parameters:

  • manager Which manager to loop the sound with

Exceptions:

  • Exception If this buffer is already looping

Note: This will loop forever until you call stop

function setData

void setData(
    const TypedAudioData & data
)

function setDataMultiple

template <size_t Size>
inline void setDataMultiple(
    const TypedAudioData data[Size]
)

function setData

void setData(
    const TypedAudioData data[],
    size_t size
)

Some deprecated function.

Deprecated:

Use the AudioBuffer::setDataMultiple instead

function setCallback

void setCallback(
    Callback callback
)

Set the callback function.

Parameters:

  • callback The callback function pointer

Deprecated:

Use the AudioBuffer::setCallback2 instead

See: Audio::Callback

function setCallback2

void setCallback2(
    Callback2 callback,
    void * user
)

Set the callback function.

Parameters:

  • callback The callback function pointer

See: Audio::Callback

Protected Functions Documentation

function getData

float * getData()

Protected Attributes Documentation

variable playing

bool playing {false};

Friends

friend AudioManager

friend class AudioManager;

friend Audio::doSomething

friend void Audio::doSomething(
    AudioBuffer & buffer
);

Updated on 2022-10-19 at 22:22:03 +0000