OpenWareLaboratory
AudioBuffer.h
Go to the documentation of this file.
1 #ifndef __AudioBuffer_h__
2 #define __AudioBuffer_h__
3 
4 #include "FloatArray.h"
5 
6 class AudioBuffer {
7 public:
8  virtual ~AudioBuffer();
9  virtual FloatArray getSamples(int channel) = 0;
10  virtual int getChannels() = 0;
11  virtual int getSize() = 0;
12  virtual void clear() = 0;
13  void multiply(float scalar){
14  for(int i=0; i<getChannels(); ++i)
15  getSamples(i).multiply(scalar);
16  }
17  void add(float scalar){
18  for(int i=0; i<getChannels(); ++i)
19  getSamples(i).add(scalar);
20  }
21  void add(AudioBuffer& other){
22  for(int i=0; i<getChannels(); ++i)
23  getSamples(i).add(other.getSamples(i));
24  }
25  void copyFrom(AudioBuffer& other){
26  for(int i=0; i<getChannels(); ++i)
27  getSamples(i).copyFrom(other.getSamples(i));
28  }
29  void copyTo(AudioBuffer& other){
30  for(int i=0; i<getChannels(); ++i)
31  getSamples(i).copyTo(other.getSamples(i));
32  }
33  static AudioBuffer* create(int channels, int samples);
34  static void destroy(AudioBuffer* buffer);
35 };
36 
37 #endif // __AudioBuffer_h__
virtual void clear()=0
virtual ~AudioBuffer()
void multiply(float scalar)
Definition: AudioBuffer.h:13
static AudioBuffer * create(int channels, int samples)
void add(AudioBuffer &other)
Definition: AudioBuffer.h:21
virtual int getChannels()=0
void add(float scalar)
Definition: AudioBuffer.h:17
static void destroy(AudioBuffer *buffer)
void copyTo(AudioBuffer &other)
Definition: AudioBuffer.h:29
void copyFrom(AudioBuffer &other)
Definition: AudioBuffer.h:25
virtual int getSize()=0
virtual FloatArray getSamples(int channel)=0
This class contains useful methods for manipulating arrays of floats.
Definition: FloatArray.h:12
void multiply(FloatArray operand2, FloatArray destination)
Element-wise multiplication between arrays.
Definition: FloatArray.cpp:290
void add(FloatArray operand2, FloatArray destination)
Element-wise sum between arrays.
Definition: FloatArray.cpp:231
void copyFrom(SimpleArray< T > source)
Copies the content of another array into this array.
Definition: SimpleArray.h:86
void copyTo(SimpleArray< T > destination)
Copies the content of this array to another array.
Definition: SimpleArray.h:76