Cafu Engine
SoundStream.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_SOUND_STREAM_HPP_INCLUDED
8 #define CAFU_SOUNDSYS_SOUND_STREAM_HPP_INCLUDED
9 
10 #include <string>
11 
12 
13 /// Represents a 16 Bit encoded mono or stereo raw PCM data stream.
15 {
16  public:
17 
18  /// Creates a new sound stream for the specified resource.
19  /// @param ResName The name of the stream resource. ResName can be a file name or the name of an OpenAL capture device (as obtained from the ALC_CAPTURE_DEVICE_SPECIFIER list).
20  /// @returns the created sound stream instance. Throws an exception of type std::runtime_error on failure.
21  static SoundStreamT* Create(const std::string& ResName);
22 
23  /// Reads an amount of bytes from the stream and writes them into the buffer.
24  /// @param Buffer Buffer to write the data into.
25  /// @param Size Amount of bytes to be read from the stream and write in the buffer.
26  /// @return Number of bytes wrote into the buffer. -1 if an error occured during reading.
27  virtual int Read(unsigned char* Buffer, unsigned int Size)=0;
28 
29  /// Sets the stream back to the beginning.
30  virtual bool Rewind()=0;
31 
32  /// Returns the number of channels in the current stream.
33  /// @return Number of channels in the stream.
34  virtual unsigned int GetChannels()=0;
35 
36  /// Get the sampling rate of this stream.
37  /// @return The sampling rate in Hz.
38  virtual unsigned int GetRate()=0;
39 
40  /// Virtual destructor to make sure the destructor of the derived class is called.
41  virtual ~SoundStreamT() { }
42 };
43 
44 #endif
static SoundStreamT * Create(const std::string &ResName)
Creates a new sound stream for the specified resource.
Definition: SoundStream.cpp:15
virtual int Read(unsigned char *Buffer, unsigned int Size)=0
Reads an amount of bytes from the stream and writes them into the buffer.
virtual unsigned int GetRate()=0
Get the sampling rate of this stream.
virtual bool Rewind()=0
Sets the stream back to the beginning.
Represents a 16 Bit encoded mono or stereo raw PCM data stream.
Definition: SoundStream.hpp:14
virtual unsigned int GetChannels()=0
Returns the number of channels in the current stream.
virtual ~SoundStreamT()
Virtual destructor to make sure the destructor of the derived class is called.
Definition: SoundStream.hpp:41