add copied AudioRingBuffer for mixer, comment crashing mouse calls

This commit is contained in:
Stephen Birarda 2013-02-11 17:16:12 -08:00
parent a2a5e8ca05
commit b45286c6e5
3 changed files with 87 additions and 6 deletions

View file

@ -594,14 +594,13 @@ void display(void)
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
//lattice.render(WIDTH, HEIGHT);
// lattice.render(WIDTH, HEIGHT);
// myFinger.render();
Audio::render(WIDTH, HEIGHT);
//drawvec3(100, 100, 0.15, 0, 1.0, 0, myHead.getPos(), 0, 1, 0);
glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, pointer_attenuation_quadratic );
// myFinger.render();
if (mouse_pressed == 1)
{
glPointSize( 10.0f );
@ -853,7 +852,7 @@ void mouseFunc( int button, int state, int x, int y )
mouse_x = x;
mouse_y = y;
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 )
{
@ -886,8 +885,8 @@ void mouseoverFunc( int x, int y)
mouse_y = y;
if (mouse_pressed == 0)
{
lattice.mouseOver((float)x/(float)WIDTH,(float)y/(float)HEIGHT);
myFinger.setTarget(mouse_x, mouse_y);
// lattice.mouseOver((float)x/(float)WIDTH,(float)y/(float)HEIGHT);
// myFinger.setTarget(mouse_x, mouse_y);
}
}

View 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;
}
}

View 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__) */