mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
Made oscilloscope 2 channel, turned on by default (need to fix injecting the last audio buffer tho).
This commit is contained in:
parent
53a3d1f8c9
commit
4ed1971276
4 changed files with 32 additions and 13 deletions
|
@ -104,7 +104,7 @@ int audioCallback (const void *inputBuffer,
|
|||
//
|
||||
if (scope->getState()) {
|
||||
for (int i = 0; i < BUFFER_LENGTH_SAMPLES; i++) {
|
||||
scope->addData((float)inputLeft[i]/32767.0, i);
|
||||
scope->addData((float)inputLeft[i]/32767.0, 1, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,14 @@ int audioCallback (const void *inputBuffer,
|
|||
memset(outputLeft, 0, BUFFER_LENGTH_BYTES);
|
||||
memset(outputRight, 0, BUFFER_LENGTH_BYTES);
|
||||
|
||||
// Copy output data to oscilloscope
|
||||
if (scope->getState()) {
|
||||
for (int i = 0; i < BUFFER_LENGTH_SAMPLES; i++) {
|
||||
scope->addData((float)outputRight[i]/32767.0, 2, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ECHO_SERVER_TEST) {
|
||||
AudioRingBuffer *ringBuffer = data->ringBuffer;
|
||||
|
||||
|
|
|
@ -12,23 +12,34 @@ Oscilloscope::Oscilloscope(int w,
|
|||
int h, bool isOn) {
|
||||
width = w;
|
||||
height = h;
|
||||
data = new float[width];
|
||||
data1 = new float[width];
|
||||
data2 = new float[width];
|
||||
for (int i = 0; i < width; i++) {
|
||||
data[i] = 0.0;
|
||||
data1[i] = 0.0;
|
||||
data2[i] = 0.0;
|
||||
}
|
||||
state = isOn;
|
||||
current_sample = 0;
|
||||
}
|
||||
|
||||
void Oscilloscope::addData(float d, int position) {
|
||||
data[position] = d;
|
||||
void Oscilloscope::addData(float d, int channel, int position) {
|
||||
if (channel == 1) data1[position] = d;
|
||||
else data2[position] = d;
|
||||
}
|
||||
|
||||
void Oscilloscope::render(float r, float g, float b) {
|
||||
glColor3f(r,g,b);
|
||||
void Oscilloscope::render() {
|
||||
glColor3f(1,1,1);
|
||||
glBegin(GL_LINES);
|
||||
for (int i = 0; i < width; i++) {
|
||||
glVertex2f((float)i, height/2 + data[i]*(float)height);
|
||||
glVertex2f((float)i, height/2 + data1[i]*(float)height);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glColor3f(0,1,1);
|
||||
glBegin(GL_LINES);
|
||||
for (int i = 0; i < width; i++) {
|
||||
glVertex2f((float)i, height/2 + data2[i]*(float)height);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
}
|
|
@ -19,14 +19,14 @@ class Oscilloscope {
|
|||
public:
|
||||
Oscilloscope(int width,
|
||||
int height, bool isOn);
|
||||
void addData(float d, int position);
|
||||
void render(float r, float g, float b);
|
||||
void addData(float d, int channel, int position);
|
||||
void render();
|
||||
void setState(bool s) {state = s;};
|
||||
bool getState() {return state;};
|
||||
private:
|
||||
int width;
|
||||
int height;
|
||||
float * data;
|
||||
float *data1, *data2;
|
||||
int current_sample;
|
||||
bool state;
|
||||
};
|
||||
|
|
|
@ -79,7 +79,7 @@ int WIDTH = 1200;
|
|||
int HEIGHT = 800;
|
||||
int fullscreen = 0;
|
||||
|
||||
Oscilloscope audioScope(512,200,false);
|
||||
Oscilloscope audioScope(512,200,true);
|
||||
|
||||
#define HAND_RADIUS 0.25 // Radius of in-world 'hand' of you
|
||||
Head myHead; // The rendered head of oneself
|
||||
|
@ -621,7 +621,7 @@ void display(void)
|
|||
// lattice.render(WIDTH, HEIGHT);
|
||||
// myFinger.render();
|
||||
Audio::render(WIDTH, HEIGHT);
|
||||
if (audioScope.getState()) audioScope.render(0,1,0);
|
||||
if (audioScope.getState()) audioScope.render();
|
||||
|
||||
|
||||
//drawvec3(100, 100, 0.15, 0, 1.0, 0, myHead.getPos(), 0, 1, 0);
|
||||
|
|
Loading…
Reference in a new issue