Doxybook Example
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Engine::Audio::AudioBuffer Class Reference

A simple audio buffer to hold PCM samples More...

#include <AudioBuffer.hpp>

Classes

struct  TypedAudioData
 Use this to populate the buffer. More...
 

Public Types

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. More...
 
template<typename T >
using AudioData = Utils::ArrayView< T >
 
typedef AudioData< uint8_t > AudioData8U
 

Public Member Functions

 AudioBuffer (const std::string &filename)
 Constructor for Audio::AudioBuffer. More...
 
virtual ~AudioBuffer ()=default
 Audio::AudioBuffer destructor. More...
 
void play (AudioManager &manager) const
 Play this buffer. More...
 
void stop (AudioManager &manager) const
 Stop this buffer playing. More...
 
void loop (AudioManager &manager) const
 Loop this buffer forever. More...
 
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. More...
 
void setCallback (Callback callback)
 Set the callback function. More...
 
void setCallback2 (Callback2 callback, void *user)
 Set the callback function. More...
 

Protected Member Functions

float * getData ()
 

Protected Attributes

bool playing {false}
 

Friends

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

Detailed Description

A simple audio buffer to hold PCM samples

Author
Matus Novak
Date
2017-2019
Precondition
First initialize the system.
Test:
Some random test description
Warning
Some random warning
Note
Some random note
Some second random note
Bug:

Some random bug

Some other random bug

Lorem ipsum donor

// Some random code
using namespace Engine;
Audio::AudioBuffer buffer("path/to/file.wav");
buffer.play(audioManager);
This namespace contains all of the necessary engine components.
Definition: Asset.hpp:5

More detailed description!

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

Member Typedef Documentation

◆ AudioData

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

◆ AudioData8U

Member Enumeration Documentation

◆ Type

Different type of audio formats.

Enumerator
UNKNOWN 

Dont use this

INT_8 

8-bit signed integer

INT_16 

16-bit signed integer

INT_24 

24-bit signed integer

INT_32 

32-bit signed integer

FLOAT_32 

32-bit float

Constructor & Destructor Documentation

◆ AudioBuffer()

Engine::Audio::AudioBuffer::AudioBuffer ( const std::string &  filename)
explicit

Constructor for Audio::AudioBuffer.

◆ ~AudioBuffer()

virtual Engine::Audio::AudioBuffer::~AudioBuffer ( )
virtualdefault

Audio::AudioBuffer destructor.

Member Function Documentation

◆ getData()

float* Engine::Audio::AudioBuffer::getData ( )
protected

◆ loop()

void Engine::Audio::AudioBuffer::loop ( AudioManager &  manager) const

Loop this buffer forever.

Parameters
managerWhich manager to loop the sound with
Note
This will loop forever until you call stop
Exceptions
ExceptionIf this buffer is already looping

◆ play()

void Engine::Audio::AudioBuffer::play ( AudioManager &  manager) const

Play this buffer.

Parameters
managerWhich manager to play the sound with
Exceptions
ExceptionIf this buffer is already playing

◆ setCallback()

void Engine::Audio::AudioBuffer::setCallback ( Callback  callback)

Set the callback function.

See also
Audio::Callback
Parameters
callbackThe callback function pointer
Deprecated:
Use the AudioBuffer::setCallback2 instead

◆ setCallback2()

void Engine::Audio::AudioBuffer::setCallback2 ( Callback2  callback,
void *  user 
)

Set the callback function.

See also
Audio::Callback
Parameters
callbackThe callback function pointer

◆ setData() [1/2]

void Engine::Audio::AudioBuffer::setData ( const TypedAudioData &  data)

◆ setData() [2/2]

void Engine::Audio::AudioBuffer::setData ( const TypedAudioData  data[],
size_t  size 
)

Some deprecated function.

Deprecated:
Use the AudioBuffer::setDataMultiple instead

◆ setDataMultiple()

template<size_t Size>
void Engine::Audio::AudioBuffer::setDataMultiple ( const TypedAudioData  data[Size])
inline

◆ stop()

void Engine::Audio::AudioBuffer::stop ( AudioManager &  manager) const

Stop this buffer playing.

Parameters
managerWhich manager to stop the sound with
Exceptions
ExceptionIf this buffer is already stopped

Friends And Related Function Documentation

◆ Audio::doSomething

void Audio::doSomething ( AudioBuffer &  buffer)
friend

◆ AudioManager

friend class AudioManager
friend

Member Data Documentation

◆ playing

bool Engine::Audio::AudioBuffer::playing {false}
protected

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