mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 13:15:10 +02:00
add copied AudioRingBuffer for mixer, comment crashing mouse calls
This commit is contained in:
parent
a2a5e8ca05
commit
b45286c6e5
3 changed files with 87 additions and 6 deletions
|
@ -594,14 +594,13 @@ void display(void)
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
|
|
||||||
//lattice.render(WIDTH, HEIGHT);
|
// lattice.render(WIDTH, HEIGHT);
|
||||||
|
// myFinger.render();
|
||||||
Audio::render(WIDTH, HEIGHT);
|
Audio::render(WIDTH, HEIGHT);
|
||||||
|
|
||||||
//drawvec3(100, 100, 0.15, 0, 1.0, 0, myHead.getPos(), 0, 1, 0);
|
//drawvec3(100, 100, 0.15, 0, 1.0, 0, myHead.getPos(), 0, 1, 0);
|
||||||
glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, pointer_attenuation_quadratic );
|
glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, pointer_attenuation_quadratic );
|
||||||
|
|
||||||
// myFinger.render();
|
|
||||||
|
|
||||||
if (mouse_pressed == 1)
|
if (mouse_pressed == 1)
|
||||||
{
|
{
|
||||||
glPointSize( 10.0f );
|
glPointSize( 10.0f );
|
||||||
|
@ -853,7 +852,7 @@ void mouseFunc( int button, int state, int x, int y )
|
||||||
mouse_x = x;
|
mouse_x = x;
|
||||||
mouse_y = y;
|
mouse_y = y;
|
||||||
mouse_pressed = 1;
|
mouse_pressed = 1;
|
||||||
// lattice.mouseClick((float)x/(float)WIDTH,(float)y/(float)HEIGHT);
|
lattice.mouseClick((float)x/(float)WIDTH,(float)y/(float)HEIGHT);
|
||||||
}
|
}
|
||||||
if( button == GLUT_LEFT_BUTTON && state == GLUT_UP )
|
if( button == GLUT_LEFT_BUTTON && state == GLUT_UP )
|
||||||
{
|
{
|
||||||
|
@ -886,8 +885,8 @@ void mouseoverFunc( int x, int y)
|
||||||
mouse_y = y;
|
mouse_y = y;
|
||||||
if (mouse_pressed == 0)
|
if (mouse_pressed == 0)
|
||||||
{
|
{
|
||||||
lattice.mouseOver((float)x/(float)WIDTH,(float)y/(float)HEIGHT);
|
// lattice.mouseOver((float)x/(float)WIDTH,(float)y/(float)HEIGHT);
|
||||||
myFinger.setTarget(mouse_x, mouse_y);
|
// myFinger.setTarget(mouse_x, mouse_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
51
mixer/src/AudioRingBuffer.cpp
Normal file
51
mixer/src/AudioRingBuffer.cpp
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
//
|
||||||
|
// AudioRingBuffer.cpp
|
||||||
|
// interface
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 2/1/13.
|
||||||
|
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "AudioRingBuffer.h"
|
||||||
|
|
||||||
|
AudioRingBuffer::AudioRingBuffer(short ringBufferSamples) {
|
||||||
|
ringBufferLengthSamples = ringBufferSamples;
|
||||||
|
|
||||||
|
started = false;
|
||||||
|
transmitted = false;
|
||||||
|
|
||||||
|
endOfLastWrite = NULL;
|
||||||
|
|
||||||
|
buffer = new int16_t[ringBufferLengthSamples];
|
||||||
|
nextOutput = buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
AudioRingBuffer::~AudioRingBuffer() {
|
||||||
|
delete[] buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
short AudioRingBuffer::diffLastWriteNextOutput()
|
||||||
|
{
|
||||||
|
if (endOfLastWrite == NULL) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
short sampleDifference = endOfLastWrite - nextOutput;
|
||||||
|
|
||||||
|
if (sampleDifference < 0) {
|
||||||
|
sampleDifference += ringBufferLengthSamples;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sampleDifference;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
short AudioRingBuffer::bufferOverlap(int16_t *pointer, short addedDistance)
|
||||||
|
{
|
||||||
|
short samplesLeft = (buffer + ringBufferLengthSamples) - pointer;
|
||||||
|
|
||||||
|
if (samplesLeft < addedDistance) {
|
||||||
|
return addedDistance - samplesLeft;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
31
mixer/src/AudioRingBuffer.h
Normal file
31
mixer/src/AudioRingBuffer.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
//
|
||||||
|
// AudioRingBuffer.h
|
||||||
|
// interface
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 2/1/13.
|
||||||
|
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef __interface__AudioRingBuffer__
|
||||||
|
#define __interface__AudioRingBuffer__
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
class AudioRingBuffer {
|
||||||
|
public:
|
||||||
|
int16_t *nextOutput;
|
||||||
|
int16_t *endOfLastWrite;
|
||||||
|
int16_t *buffer;
|
||||||
|
short ringBufferLengthSamples;
|
||||||
|
bool started;
|
||||||
|
bool transmitted;
|
||||||
|
|
||||||
|
short diffLastWriteNextOutput();
|
||||||
|
short bufferOverlap(int16_t *pointer, short addedDistance);
|
||||||
|
|
||||||
|
AudioRingBuffer(short ringBufferSamples);
|
||||||
|
~AudioRingBuffer();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* defined(__interface__AudioRingBuffer__) */
|
Loading…
Reference in a new issue