2013-05-20 00:57:12 +02:00
|
|
|
|
|
|
|
#ifndef LUPPP_AUDIOBUFFER_H
|
|
|
|
#define LUPPP_AUDIOBUFFER_H
|
|
|
|
|
|
|
|
#include <vector>
|
2013-08-13 18:03:33 +02:00
|
|
|
#include <iostream>
|
2013-05-20 00:57:12 +02:00
|
|
|
|
2013-08-06 23:20:37 +02:00
|
|
|
/// AudioBuffer stores float samples in a big vector.
|
2013-05-20 00:57:12 +02:00
|
|
|
class AudioBuffer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AudioBuffer()
|
|
|
|
{
|
2013-08-22 02:29:55 +02:00
|
|
|
ID = privateID++;
|
|
|
|
numBeats = 0;
|
2013-08-06 23:10:27 +02:00
|
|
|
}
|
|
|
|
AudioBuffer(unsigned long size)
|
|
|
|
{
|
2013-08-22 02:35:43 +02:00
|
|
|
/// no ID assigned: it *takes* the one from the previous buffer!
|
2013-08-22 02:29:55 +02:00
|
|
|
numBeats = 0;
|
2013-08-06 23:10:27 +02:00
|
|
|
buffer.resize(size);
|
2013-05-20 00:57:12 +02:00
|
|
|
}
|
2013-08-07 01:16:27 +02:00
|
|
|
|
2013-08-22 02:35:43 +02:00
|
|
|
/// this function is used for "resizing" an exisiting buffer, and should
|
|
|
|
/// not be called for any other reason.
|
|
|
|
void setID(int id)
|
|
|
|
{
|
|
|
|
ID = id;
|
|
|
|
}
|
2013-08-22 02:29:55 +02:00
|
|
|
|
2013-05-20 00:57:12 +02:00
|
|
|
int getID()
|
|
|
|
{
|
|
|
|
return ID;
|
|
|
|
}
|
2013-08-22 02:29:55 +02:00
|
|
|
|
2013-05-20 00:57:12 +02:00
|
|
|
int getBeats()
|
|
|
|
{
|
|
|
|
return numBeats;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setBeats(int b)
|
|
|
|
{
|
2013-08-13 18:03:33 +02:00
|
|
|
printf("AudioBuffer now has %i beats\n", b );
|
2013-05-20 00:57:12 +02:00
|
|
|
numBeats = b;
|
|
|
|
}
|
|
|
|
|
2013-07-27 18:50:10 +02:00
|
|
|
std::vector<float>& getData()
|
2013-05-20 00:57:12 +02:00
|
|
|
{
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nonRtSetSample(std::vector<float>& sample)
|
|
|
|
{
|
|
|
|
buffer.swap(sample);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2013-08-22 02:29:55 +02:00
|
|
|
static int privateID;
|
|
|
|
int ID;
|
2013-05-20 00:57:12 +02:00
|
|
|
|
|
|
|
int numBeats;
|
|
|
|
|
|
|
|
std::vector<float> buffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|