Gorgon Game Engine
Wave.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 #include <fstream>
5 #include <string>
6 
7 #include "../Types.h"
8 #include "../Audio/Basic.h"
9 #include "../IO/Stream.h"
10 
11 namespace Gorgon {
12  namespace Containers {
13 
17  class Wave {
18  public:
19 
23  class Sample {
24  friend class Wave;
25  public:
26  Sample() { }
27 
28  float &Channel(unsigned channel) {
29 #ifndef NDEBUG
30  if(channel >= channels) {
31  throw std::runtime_error("Index out of bounds");
32  }
33 #endif
34 
35  return current[channel];
36  }
37 
38  float Channel(unsigned channel) const {
39 #ifndef NDEBUG
40  if(channel >= channels) {
41  throw std::runtime_error("Index out of bounds");
42  }
43 #endif
44 
45  return current[channel];
46  }
47 
48  float &operator[](unsigned channel) {
49  return Channel(channel);
50  }
51 
52  float operator[](unsigned channel) const {
53  return Channel(channel);
54  }
55 
56  private:
57  Sample(float *current, unsigned channels) : current(current), channels(channels) { }
58 
59  float *current = nullptr;
60  unsigned channels = 0;
61  };
62 
68  class Iterator {
69  friend class Wave;
70  public:
71 
72  typedef unsigned long difference_type;
73  typedef Sample value_type;
74  typedef Sample& reference;
75  typedef Sample* pointer;
76  typedef std::random_access_iterator_tag iterator_category;
77 
78 
79  Iterator() = default;
80 
81  Iterator& operator=(const Iterator&) = default;
82 
84  current += channels;
85 
86  return *this;
87  }
88 
90  auto temp = *this;
91 
92  current += channels;
93 
94  return temp;
95  }
96 
98  current -= channels;
99 
100  return *this;
101  }
102 
104  auto temp = *this;
105 
106  current -= channels;
107 
108  return temp;
109  }
110 
111  Sample operator*() const {
112  return {current, channels};
113  }
114 
115  bool operator< (const Iterator &r) {
116  return current<r.current;
117  }
118 
119  bool operator> (const Iterator &r) {
120  return current>r.current;
121  }
122 
123  bool operator<=(const Iterator &r) {
124  return current<=r.current;
125  }
126 
127  bool operator>=(const Iterator &r) {
128  return current>=r.current;
129  }
130 
131  bool operator==(const Iterator &r) {
132  return current==r.current;
133  }
134 
135  bool operator!=(const Iterator &r) {
136  return current!=r.current;
137  }
138 
139  Sample operator[](unsigned long pos) const {
140  return {current, channels};
141  }
142 
143  Iterator& operator+=(unsigned long diff) {
144  current+=diff*channels;
145  return *this;
146  }
147 
148  Iterator operator+(unsigned long diff) const {
149  auto temp=*this;
150  temp.current+=diff*channels;
151 
152  return temp;
153  }
154 
155  Iterator& operator-=(unsigned long diff) {
156  current-=diff*channels;
157  return *this;
158  }
159 
160  Iterator operator-(unsigned long diff) const {
161  auto temp=*this;
162  temp.current-=diff*channels;
163 
164  return temp;
165  }
166 
167  unsigned long operator-(const Iterator &r) const {
168  return (unsigned long)((current-r.current)/channels);
169  }
170 
171  private:
172  Iterator(float *current, unsigned channels) : current(current), channels(channels) {}
173 
174  float *current;
175  unsigned channels;
176  };
177 
179  Wave() {
180 
181  }
182 
185  explicit Wave(unsigned long size, unsigned samplerate, std::vector<Audio::Channel> channels = {Audio::Channel::Mono}): size(size), samplerate(samplerate), channels(channels) {
186  data = (float*)malloc(size * channels.size() * sizeof(float));
187  }
188 
190  Wave(const Wave &) = delete;
191 
193  Wave(Wave &&data): Wave() {
194  Swap(data);
195  }
196 
198  Wave &operator=(const Wave &) = delete;
199 
201  Wave &operator=(Wave &&other) {
202  Destroy();
203  Swap(other);
204 
205  return *this;
206  }
207 
209  ~Wave() {
210  Destroy();
211  }
212 
214  Wave Duplicate() const {
215  Wave data;
216  data.Assign(this->data, size, channels);
217 
218  data.samplerate=samplerate;
219 
220  return data;
221  }
222 
225  void Resize(unsigned long size, std::vector<Audio::Channel> channels) {
226 
227  this->channels = std::move(channels);
228 
229  this->size = size;
230 
231  if(data) {
232  free(data);
233  }
234  data = (float*)malloc(size * this->channels.size() * sizeof(float));
235  }
236 
240  void Resize(unsigned long size) {
241 
242  // Check if resize is really necessary
243  if(this->size == size)
244  return;
245 
246  this->size = size;
247 
248  if(data) {
249  free(data);
250  }
251  data = (float*)malloc(size * channels.size() * sizeof(float));
252  }
253 
257  void Assign(float *newdata, unsigned long size) {
258  this->size = size;
259 
260  if(data) {
261  free(data);
262  }
263  if(size > 0) {
264  data = (float*)malloc(size * channels.size() * sizeof(float));
265  memcpy(data, newdata, size * channels.size() * sizeof(float));
266  }
267  else {
268  data = nullptr;
269  }
270  }
271 
274  void Assign(float *newdata, unsigned long size, std::vector<Audio::Channel> channels) {
275  this->size = size;
276 
277  this->channels = std::move(channels);
278 
279  if(data) {
280  free(data);
281  }
282  if(size > 0) {
283  data = (float*)malloc(size * this->channels.size() * sizeof(float));
284  memcpy(data, newdata, size * this->channels.size() * sizeof(float));
285  }
286  else {
287  data = nullptr;
288  }
289  }
290 
294  void Assign(float *newdata) {
295  memcpy(data, newdata, size * channels.size() * sizeof(float));
296  }
297 
299  void Assume(float *newdata, unsigned long size) {
300  this->size = size;
301 
302  if(data && newdata!=data) {
303  free(data);
304  }
305  data = newdata;
306  }
307 
312  void Assume(float *newdata, unsigned long size, std::vector<Audio::Channel> channels) {
313  this->size = size;
314  this->channels = std::move(channels);
315 
316  if(data && newdata!=data) {
317  free(data);
318  }
319  data = newdata;
320  }
321 
322  void Assume(float *newdata) {
323  if(data && newdata!=data) {
324  free(data);
325  }
326 
327  data = newdata;
328  }
329 
331  float *Release() {
332  auto temp = data;
333  data = nullptr;
334  Destroy();
335 
336  return temp;
337  }
338 
340  void Clear() {
341  memset(data, 0, size * channels.size() * sizeof(float));
342  }
343 
346  void Destroy() {
347  if(data) {
348  free(data);
349  data = nullptr;
350  }
351  size = 0;
352  }
353 
355  void Swap(Wave &other) {
356  using std::swap;
357 
358  swap(size, other.size);
359  swap(channels, other.channels);
360  swap(data, other.data);
361  swap(samplerate, other.samplerate);
362  }
363 
365  float *RawData() {
366  return data;
367  }
368 
370  const float *RawData() const {
371  return data;
372  }
373 
375  float &operator()(unsigned long p, unsigned ch) {
376 #ifndef NDEBUG
377  if(p >= size || ch >= channels.size()) {
378  throw std::runtime_error("Index out of bounds");
379  }
380 #endif
381  return data[p*channels.size()+ch];
382  }
383 
385  float operator()(unsigned long p, unsigned ch) const {
386 #ifndef NDEBUG
387  if(p >= size || ch >= channels.size()) {
388  throw std::runtime_error("Index out of bounds");
389  }
390 #endif
391  return data[p*channels.size()+ch];
392  }
393 
395  float Get(unsigned long p, unsigned ch) const {
396 #ifndef NDEBUG
397  if(p >= size || ch >= channels.size()) {
398  throw std::runtime_error("Index out of bounds");
399  }
400 #endif
401  return data[p*channels.size() + ch];
402  }
403 
405  unsigned long GetSize() const {
406  return size;
407  }
408 
410  unsigned long GetBytes() const {
411  return (unsigned int)(size * channels.size() * sizeof(float));
412  }
413 
415  float GetLength() const {
416  return float((double)size/samplerate);
417  }
418 
420  unsigned GetChannelCount() const {
421  return (unsigned int)channels.size();
422  }
423 
425  Audio::Channel GetChannelType(int channel) const {
426  if(channel<0 || channel>=(int)channels.size())
428 
429  return channels[channel];
430  }
431 
434  void SetChannels(std::vector<Audio::Channel> channels) {
435  if(channels.size() != this->channels.size() && size)
436  throw std::runtime_error("Number of channels does not match");
437 
438  this->channels = std::move(channels);
439  }
440 
442  int FindChannel(Audio::Channel channel) const {
443  for(int i=0; i<(int)channels.size(); i++) {
444  if(channels[i] == channel) return i;
445  }
446 
447  return -1;
448  }
449 
451  unsigned GetSampleRate() const {
452  return samplerate;
453  }
454 
456  void SetSampleRate(unsigned rate) {
457  samplerate = rate;
458  }
459 
461  bool ImportWav(const std::string &filename, std::vector<Audio::Channel> channels = {}) {
462  std::ifstream file(filename, std::ios::binary);
463 
464  if(!file.is_open()) return false;
465 
466  return ImportWav(file, std::move(channels));
467  }
468 
469  bool ImportWav(std::istream &file, std::vector<Audio::Channel> channels = {}) {
470 
471  if(IO::ReadString(file, 4) != "RIFF") return false;
472 
473  if(IO::ReadInt32(file) <= 36) return false;
474 
475  if(IO::ReadString(file, 4) != "WAVE") return false;
476 
477  if(IO::ReadString(file, 4) != "fmt ") return false;
478 
479  if(IO::ReadInt32(file) != 16) return false;
480 
481  if(IO::ReadInt16(file) != 1) return false; //must be PCM
482 
483  int channelcnt = IO::ReadInt16(file);
484  samplerate = IO::ReadInt32(file);
485  int byterate = IO::ReadInt32(file);
486  int blocksize = IO::ReadInt16(file);
487  int samplesize = IO::ReadInt16(file);
488 
489  if(samplesize != 8 && samplesize !=16) return false;
490 
491  if(byterate != samplerate*channelcnt*samplesize/8) return false;
492 
493  if(blocksize == 0) blocksize = byterate;
494 
495  if(channels.size() == 0) {
496  channels = Audio::StandardChannels(channelcnt);
497  }
498  else if(channels.size() != channelcnt)
499  return false;
500 
501  if(IO::ReadString(file, 4) != "data") return false;
502 
503  int skip = blocksize - byterate / samplerate;
504 
505  int size = IO::ReadInt32(file);
506 
507  Resize(size / blocksize, channels);
508 
509  auto target = file.tellg() + size;
510 
511  float *ptr = data;
512 
513  if(!file) return false;
514 
515  while(!file.eof() && file.tellg() < target) {
516  for(int c = 0; c<channelcnt; c++) {
517  if(samplesize == 8) {
518  *ptr++ = (IO::ReadUInt8(file) / 255.f) * 2.f - 1.f;
519  }
520  else {
521  *ptr++ = IO::ReadInt16(file) / 32767.f;
522  }
523 
524  if(!file) return false;
525  }
526 
527  if(skip != 0)
528  file.seekg(skip, std::ios::cur);
529  }
530 
531  if((long)file.tellg() != target) return false;
532 
533  this->channels = std::move(channels);
534 
535  return true;
536  }
537 
539  bool ExportWav(const std::string &filename, int bits = 16) {
540  std::ofstream file(filename, std::ios::binary);
541 
542  if(!file.is_open()) return false;
543 
544  return ExportWav(file, bits);
545  }
546 
548  bool ExportWav(std::ostream &file, int bits = 16) {
549  using namespace IO;
550 
551  int hs = 44, ds;
552  if(bits == 8) {
553  ds = GetSize() * GetChannelCount();
554  }
555  else if(bits == 16) {
556  ds = GetSize() * GetChannelCount() * 2;
557  }
558  else {
559  throw std::runtime_error("Invalid number of bits for wav file");
560  }
561 
562  WriteString(file, "RIFF");
563  WriteInt32(file, hs+ds-8);
564 
565  WriteString(file, "WAVEfmt ");
566  WriteInt32(file, 16);
567  WriteInt16(file, 1);
568 
569  WriteInt16(file, GetChannelCount());
570  WriteInt32(file, GetSampleRate());
571  WriteInt32(file, GetSampleRate() * bits * GetChannelCount() / 8);
572  WriteInt16(file, bits * GetChannelCount());
573  WriteInt16(file, bits);
574 
575  WriteString(file, "data");
576  WriteInt32(file, ds);
577 
578  float *ptr = data;
579  float *end = data + GetChannelCount() * GetSize();
580  if(bits == 8) {
581  while(ptr<end) {
582  WriteUInt8(file, (Byte)std::round((((*ptr) + 1) / 2) * 255) );
583 
584  ++ptr;
585  }
586  }
587  else {
588  int16_t multiplier = (1<<(bits-1))-1;
589  while(ptr<end) {
590  WriteInt16(file, (int)std::round((*ptr) * multiplier));
591 
592  ++ptr;
593  }
594  }
595 
596  return true;
597  }
598 
600  return Iterator(data, (unsigned int)channels.size());
601  }
602 
604  return Iterator(data+size*channels.size(), (unsigned int)channels.size());
605  }
606 
607  protected:
609  float *data = nullptr;
610 
612  unsigned long size = 0;
613 
615  std::vector<Audio::Channel> channels;
616 
618  unsigned samplerate = 0;
619  };
620 
622  inline void swap(Wave &l, Wave &r) {
623  l.Swap(r);
624  }
625 
626  }
627 }
Gorgon::Containers::Wave::Iterator::operator[]
Sample operator[](unsigned long pos) const
Definition: Wave.h:139
Gorgon::Containers::Wave::GetBytes
unsigned long GetBytes() const
Returns the size of the wave in bytes.
Definition: Wave.h:410
Gorgon::IO::WriteInt16
void WriteInt16(std::ostream &stream, int value)
Writes a 16-bit integer from the stream.
Definition: Stream.h:211
Gorgon::Containers::Wave::Sample::Channel
float Channel(unsigned channel) const
Definition: Wave.h:38
Gorgon::Containers::Wave::Assume
void Assume(float *newdata)
Definition: Wave.h:322
Gorgon::Containers::Wave::Iterator::operator++
Iterator operator++(int)
Definition: Wave.h:89
Gorgon::Containers::Wave::Release
float * Release()
Returns and disowns the current data buffer. If wave is empty, this method will return a nullptr.
Definition: Wave.h:331
Gorgon::Containers::Wave::Sample
Represents a sample in the Wave data.
Definition: Wave.h:23
Gorgon::Containers::Wave::Wave
Wave(Wave &&data)
Move constructor.
Definition: Wave.h:193
Gorgon::Containers::Wave::ExportWav
bool ExportWav(std::ostream &file, int bits=16)
Exports a PCM based wav file. Bits can be 8 or 16.
Definition: Wave.h:548
Gorgon::Containers::Wave::SetChannels
void SetChannels(std::vector< Audio::Channel > channels)
Sets the channel assignment to this wave data.
Definition: Wave.h:434
Gorgon::Audio::StandardChannels
std::vector< Channel > StandardChannels(int channelcount)
Definition: Basic.h:39
Gorgon::Containers::swap
void swap(Collection< T_ > &l, Collection< T_ > &r)
Swaps two collections.
Definition: Collection.h:707
Gorgon::Containers::swap
void swap(Wave &l, Wave &r)
Swaps two waves. Should be used unqualified for ADL.
Definition: Wave.h:622
Gorgon::Containers::Wave::Iterator::operator-
unsigned long operator-(const Iterator &r) const
Definition: Wave.h:167
Gorgon::IO::WriteInt32
void WriteInt32(std::ostream &stream, long value)
Writes a 32-bit integer to the stream.
Definition: Stream.h:197
Gorgon::Containers::Wave::Assume
void Assume(float *newdata, unsigned long size, std::vector< Audio::Channel > channels)
Assumes the ownership of the given data.
Definition: Wave.h:312
Gorgon::Containers::Wave::RawData
const float * RawData() const
Returns the raw data pointer.
Definition: Wave.h:370
Gorgon::Containers::Wave::Assign
void Assign(float *newdata, unsigned long size, std::vector< Audio::Channel > channels)
Copies the given data assigns the new data to this object, size is the number of samples.
Definition: Wave.h:274
Gorgon::Containers::Wave::Iterator::operator>
bool operator>(const Iterator &r)
Definition: Wave.h:119
Gorgon::Containers::Wave::Sample::operator[]
float operator[](unsigned channel) const
Definition: Wave.h:52
Gorgon::Containers::Wave::data
float * data
Data that stores pixels of the wave.
Definition: Wave.h:609
Gorgon::Containers::Wave::ImportWav
bool ImportWav(std::istream &file, std::vector< Audio::Channel > channels={})
Definition: Wave.h:469
Gorgon::Containers::Wave::Sample::Channel
float & Channel(unsigned channel)
Definition: Wave.h:28
Gorgon::Containers::Wave::FindChannel
int FindChannel(Audio::Channel channel) const
Returns the index of the given channel. If the given channel does not exists, this function returns -...
Definition: Wave.h:442
Gorgon::Containers::Wave::Get
float Get(unsigned long p, unsigned ch) const
Allows access to individual members.
Definition: Wave.h:395
Gorgon::Containers::Wave::Iterator::reference
Sample & reference
Definition: Wave.h:74
Gorgon::Containers::Wave::Destroy
void Destroy()
Destroys this wave by setting its size to 0 and freeing the memory used by its data.
Definition: Wave.h:346
Gorgon::Containers::Wave::GetChannelType
Audio::Channel GetChannelType(int channel) const
Returns the type of the channel at the given index.
Definition: Wave.h:425
Gorgon::Containers::Wave::Iterator::operator--
Iterator operator--(int)
Definition: Wave.h:103
Gorgon::Containers::Wave::Iterator::operator<=
bool operator<=(const Iterator &r)
Definition: Wave.h:123
Gorgon::Containers::Wave::Iterator
Iterates the elements of a Wave.
Definition: Wave.h:68
Gorgon::Containers::Wave::Assume
void Assume(float *newdata, unsigned long size)
Assumes the ownership of the data.
Definition: Wave.h:299
Gorgon::Containers::Wave::Iterator::operator>=
bool operator>=(const Iterator &r)
Definition: Wave.h:127
Gorgon::Containers::Wave::Iterator::operator--
Iterator & operator--()
Definition: Wave.h:97
Gorgon::Containers::Wave::Iterator::operator+
Iterator operator+(unsigned long diff) const
Definition: Wave.h:148
Gorgon::IO::ReadInt32
long ReadInt32(std::istream &stream)
Reads a 32-bit integer from the stream.
Definition: Stream.h:26
Gorgon::Containers::Wave::Clear
void Clear()
Cleans the contents of the buffer by setting every byte it contains to 0.
Definition: Wave.h:340
Gorgon::Containers::Wave::Duplicate
Wave Duplicate() const
Duplicates this wave, essentially performing the work of copy constructor.
Definition: Wave.h:214
Gorgon::Containers::Wave::Assign
void Assign(float *newdata, unsigned long size)
Copies the given data assigns the new data to this object, size is the number of samples.
Definition: Wave.h:257
Gorgon::Containers::Wave::channels
std::vector< Audio::Channel > channels
Number of channels.
Definition: Wave.h:615
Gorgon
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Gorgon::Containers::Wave::Wave
Wave(const Wave &)=delete
Copy constructor is disabled.
Gorgon::Containers::Wave::operator=
Wave & operator=(Wave &&other)
Move assignment.
Definition: Wave.h:201
Gorgon::IO::ReadInt16
int ReadInt16(std::istream &stream)
Reads a 16-bit integer from the stream.
Definition: Stream.h:44
Gorgon::Containers::Wave::Iterator::operator=
Iterator & operator=(const Iterator &)=default
Gorgon::Containers::Wave::SetSampleRate
void SetSampleRate(unsigned rate)
Sets the number samples per second.
Definition: Wave.h:456
Gorgon::Containers::Wave::Wave
Wave()
Constructs an empty wave data.
Definition: Wave.h:179
Gorgon::Containers::Wave::size
unsigned long size
Number of samples in the wave.
Definition: Wave.h:612
Gorgon::Containers::Wave::Iterator::operator==
bool operator==(const Iterator &r)
Definition: Wave.h:131
Gorgon::Containers::Wave::Iterator::operator-=
Iterator & operator-=(unsigned long diff)
Definition: Wave.h:155
Gorgon::IO::WriteUInt8
void WriteUInt8(std::ostream &stream, Byte value)
Writes an 8-bit unsigned integer from the stream.
Definition: Stream.h:231
Gorgon::Containers::Wave::Iterator::operator-
Iterator operator-(unsigned long diff) const
Definition: Wave.h:160
Gorgon::Containers::Wave::begin
Iterator begin()
Definition: Wave.h:599
Gorgon::Containers::Wave::Iterator::difference_type
unsigned long difference_type
Definition: Wave.h:72
Gorgon::Containers::Wave::end
Iterator end()
Definition: Wave.h:603
Gorgon::Containers::Wave::Resize
void Resize(unsigned long size, std::vector< Audio::Channel > channels)
Resizes the wave to the given size and channels.
Definition: Wave.h:225
Gorgon::Containers::Wave::samplerate
unsigned samplerate
Sampling rate of the wave.
Definition: Wave.h:618
Gorgon::Containers::Wave::GetChannelCount
unsigned GetChannelCount() const
Returns the number of channels that this wave data has.
Definition: Wave.h:420
Gorgon::Containers::Wave::Assign
void Assign(float *newdata)
Copies the given data assigns the new data to this object, size is the number of samples.
Definition: Wave.h:294
Gorgon::Containers::Wave::Iterator::operator+=
Iterator & operator+=(unsigned long diff)
Definition: Wave.h:143
Gorgon::Containers::Wave::ImportWav
bool ImportWav(const std::string &filename, std::vector< Audio::Channel > channels={})
Imports a PCM based wav file. Leave channels empty to determine them automatically.
Definition: Wave.h:461
Gorgon::Containers::Wave::Sample::Sample
Sample()
Definition: Wave.h:26
Gorgon::Byte
unsigned char Byte
Represents smallest cell in memory.
Definition: Types.h:9
Gorgon::Audio::Channel
Channel
Names for channels.
Definition: Basic.h:16
Gorgon::Containers::Wave::Iterator::iterator_category
std::random_access_iterator_tag iterator_category
Definition: Wave.h:76
Gorgon::Containers::Wave::Sample::operator[]
float & operator[](unsigned channel)
Definition: Wave.h:48
Gorgon::Containers::Wave::GetLength
float GetLength() const
Returns the length of the wave data in seconds.
Definition: Wave.h:415
Gorgon::Containers::Wave::Iterator::operator<
bool operator<(const Iterator &r)
Definition: Wave.h:115
Gorgon::Containers::Wave::Iterator::pointer
Sample * pointer
Definition: Wave.h:75
Gorgon::Containers::Wave
This class is a container for wave data.
Definition: Wave.h:17
Gorgon::Containers::Wave::operator=
Wave & operator=(const Wave &)=delete
Copy assignment is disabled.
Gorgon::Containers::Wave::Iterator::Iterator
Iterator()=default
Gorgon::Containers::Wave::Iterator::value_type
Sample value_type
Definition: Wave.h:73
Gorgon::Containers::Wave::operator()
float & operator()(unsigned long p, unsigned ch)
Allows access to individual members.
Definition: Wave.h:375
Gorgon::Containers::Wave::RawData
float * RawData()
Returns the raw data pointer.
Definition: Wave.h:365
Gorgon::Containers::Wave::ExportWav
bool ExportWav(const std::string &filename, int bits=16)
Exports a PCM based wav file. Bits can be 8 or 16.
Definition: Wave.h:539
Gorgon::Containers::Wave::GetSize
unsigned long GetSize() const
Returns the size of the wave.
Definition: Wave.h:405
Gorgon::Containers::Wave::Iterator::operator++
Iterator & operator++()
Definition: Wave.h:83
Gorgon::Containers::Wave::GetSampleRate
unsigned GetSampleRate() const
Returns the number of samples per second.
Definition: Wave.h:451
Gorgon::Containers::Wave::operator()
float operator()(unsigned long p, unsigned ch) const
Allows access to individual members.
Definition: Wave.h:385
Gorgon::Containers::Wave::Wave
Wave(unsigned long size, unsigned samplerate, std::vector< Audio::Channel > channels={Audio::Channel::Mono})
Constructs a new wave data with the given number of samples and channels.
Definition: Wave.h:185
Gorgon::Audio::Channel::Unknown
@ Unknown
Gorgon::Containers::Wave::Iterator::operator*
Sample operator*() const
Definition: Wave.h:111
Gorgon::IO::WriteString
void WriteString(std::ostream &stream, const std::string &value)
Writes a string without its size.
Definition: Stream.h:285
Gorgon::IO::ReadUInt8
Byte ReadUInt8(std::istream &stream)
Reads an 8-bit unsigned integer from the stream.
Definition: Stream.h:71
Gorgon::IO::ReadString
std::string ReadString(std::istream &stream)
Reads a string from a given stream.
Definition: Stream.h:135
Gorgon::Containers::Wave::~Wave
~Wave()
Destructor.
Definition: Wave.h:209
Gorgon::Containers::Wave::Resize
void Resize(unsigned long size)
Resizes the wave to the given size.
Definition: Wave.h:240
Gorgon::Containers::Wave::Swap
void Swap(Wave &other)
Swaps this wave with another. This function is used to implement move semantics.
Definition: Wave.h:355
Gorgon::Containers::Wave::Iterator::operator!=
bool operator!=(const Iterator &r)
Definition: Wave.h:135