Cafu Engine
StaticBuffer.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_SOUNDSYS_STATIC_BUFFER_HPP_INCLUDED
8 #define CAFU_SOUNDSYS_STATIC_BUFFER_HPP_INCLUDED
9 
10 #include "Buffer.hpp"
11 
12 
13 /// A StaticBufferT is a BufferT specialization for audio data from a file whose contents fits entirely into memory.
14 /// StaticBufferT instances can be shared and thus independently be used by multiple mixer tracks at the same time.
15 class StaticBufferT : public BufferT
16 {
17  public:
18 
19  /// The constructor. Throws an exception of type std::runtime_error on failure.
20  /// @param FileName The name of the audio file that this buffer is created from.
21  /// @param ForceMono Whether the data from the resource should be reduced to a single channel before use (mono output).
22  StaticBufferT(const std::string& FileName, bool ForceMono);
23 
24  /// The destructor.
26 
27  // BufferT implementation.
28  unsigned int GetChannels() const;
29  bool CanShare() const;
30  void Update();
31  bool AttachToMixerTrack(MixerTrackT* MixerTrack);
32  bool DetachFromMixerTrack(MixerTrackT* MixerTrack);
33 
34 
35  private:
36 
37  ALuint m_Buffer;
38 };
39 
40 #endif
A mixer track represents/encapsulates/abstracs an OpenAL sound source.
Definition: MixerTrack.hpp:22
void Update()
Updates the buffer.
Definition: StaticBuffer.cpp:96
A StaticBufferT is a BufferT specialization for audio data from a file whose contents fits entirely i...
Definition: StaticBuffer.hpp:15
bool CanShare() const
Returns whether this buffer can be attached to multiple mixer tracks (resource sharing).
Definition: StaticBuffer.cpp:90
bool AttachToMixerTrack(MixerTrackT *MixerTrack)
Attaches the buffer to a mixer track, so the mixer track can play this buffer.
Definition: StaticBuffer.cpp:102
unsigned int GetChannels() const
Returns the number of audio channels in this buffer (1 is mono, 2 is stereo).
Definition: StaticBuffer.cpp:81
StaticBufferT(const std::string &FileName, bool ForceMono)
The constructor.
Definition: StaticBuffer.cpp:19
A BufferT encapsulates an audio resource such as a file or a capture device.
Definition: Buffer.hpp:22
~StaticBufferT()
The destructor.
Definition: StaticBuffer.cpp:69
bool DetachFromMixerTrack(MixerTrackT *MixerTrack)
Detaches the buffer from a mixer track.
Definition: StaticBuffer.cpp:113