Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SoundBuffer.h
Go to the documentation of this file.
1 //
2 // C++ Interface: Audio::SoundBuffer
3 //
4 
5 #ifndef __AUDIO__SOUND_BUFFER__INCLUDED__
6 #define __AUDIO__SOUND_BUFFER__INCLUDED__
7 
8 #include "Exceptions.h"
9 #include "Format.h"
10 
11 namespace Audio {
12 
27  {
28  private:
29  void *buffer;
30  unsigned int byteCapacity;
31  unsigned int bytesUsed;
32 
33  Format format;
34 
35  public:
37  SoundBuffer() throw();
38 
40  SoundBuffer(unsigned int capacity, const Format &format) throw(OutOfMemoryException);
41 
45  SoundBuffer(const SoundBuffer &other) throw(OutOfMemoryException);
46 
51  void reserve(unsigned int capacity) throw(OutOfMemoryException);
52 
58  void reserve(unsigned int capacity, const Format &format) throw(OutOfMemoryException);
59 
61  unsigned int getByteCapacity() const throw() { return byteCapacity; }
62 
66  unsigned int getSampleCapacity() const throw() { return byteCapacity / format.frameSize(); }
67 
69  unsigned int getUsedBytes() const throw() { return bytesUsed; }
70 
72  void* getBuffer() throw() { return buffer; }
73 
75  const void* getBuffer() const throw() { return buffer; }
76 
78  const Format& getFormat() const { return format; }
79 
81  void setFormat(const Format &newFormat) throw() { format = newFormat; bytesUsed = 0; }
82 
84  void setUsedBytes(unsigned int used) throw() { bytesUsed = used; }
85 
87  unsigned int getSampleCount() const throw() { return bytesUsed / format.frameSize(); }
88 
97  void reformat(const Format &newFormat) throw(Exception);
98 
101 
105  void swap(SoundBuffer &other) throw();
106 
108  void optimize() throw();
109  void clear();
110  };
111 
112 };
113 
114 #endif//__AUDIO__SOUND_BUFFER__INCLUDED__