mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 19:56:44 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
616285f4c7
5 changed files with 44 additions and 29 deletions
|
@ -941,11 +941,13 @@ void Application::idle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update from Mouse
|
// Update from Mouse
|
||||||
QPoint mouse = QCursor::pos();
|
if (_mouseLook->isChecked()) {
|
||||||
_myAvatar.updateFromMouse(_glWidget->mapFromGlobal(mouse).x(),
|
QPoint mouse = QCursor::pos();
|
||||||
_glWidget->mapFromGlobal(mouse).y(),
|
_myAvatar.updateFromMouse(_glWidget->mapFromGlobal(mouse).x(),
|
||||||
_glWidget->width(),
|
_glWidget->mapFromGlobal(mouse).y(),
|
||||||
_glWidget->height());
|
_glWidget->width(),
|
||||||
|
_glWidget->height());
|
||||||
|
}
|
||||||
|
|
||||||
// Read serial port interface devices
|
// Read serial port interface devices
|
||||||
if (_serialPort.active) {
|
if (_serialPort.active) {
|
||||||
|
@ -1198,6 +1200,8 @@ void Application::initMenu() {
|
||||||
optionsMenu->addAction("Noise", this, SLOT(setNoise(bool)), Qt::Key_N)->setCheckable(true);
|
optionsMenu->addAction("Noise", this, SLOT(setNoise(bool)), Qt::Key_N)->setCheckable(true);
|
||||||
(_gyroLook = optionsMenu->addAction("Gyro Look"))->setCheckable(true);
|
(_gyroLook = optionsMenu->addAction("Gyro Look"))->setCheckable(true);
|
||||||
_gyroLook->setChecked(true);
|
_gyroLook->setChecked(true);
|
||||||
|
(_mouseLook = optionsMenu->addAction("Mouse Look"))->setCheckable(true);
|
||||||
|
_mouseLook->setChecked(false);
|
||||||
optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F)->setCheckable(true);
|
optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F)->setCheckable(true);
|
||||||
|
|
||||||
QMenu* renderMenu = menuBar->addMenu("Render");
|
QMenu* renderMenu = menuBar->addMenu("Render");
|
||||||
|
|
|
@ -133,6 +133,7 @@ private:
|
||||||
|
|
||||||
QAction* _lookingInMirror; // Are we currently rendering one's own head as if in mirror?
|
QAction* _lookingInMirror; // Are we currently rendering one's own head as if in mirror?
|
||||||
QAction* _gyroLook; // Whether to allow the gyro data from head to move your view
|
QAction* _gyroLook; // Whether to allow the gyro data from head to move your view
|
||||||
|
QAction* _mouseLook; // Whether the have the mouse near edge of screen move your view
|
||||||
QAction* _renderVoxels; // Whether to render voxels
|
QAction* _renderVoxels; // Whether to render voxels
|
||||||
QAction* _renderVoxelTextures; // Whether to render noise textures on voxels
|
QAction* _renderVoxelTextures; // Whether to render noise textures on voxels
|
||||||
QAction* _renderStarsOn; // Whether to display the stars
|
QAction* _renderStarsOn; // Whether to display the stars
|
||||||
|
|
|
@ -99,12 +99,21 @@ int audioCallback (const void* inputBuffer,
|
||||||
parentAudio->_scope->addSamples(2, outputRight, PACKET_LENGTH_SAMPLES_PER_CHANNEL);
|
parentAudio->_scope->addSamples(2, outputRight, PACKET_LENGTH_SAMPLES_PER_CHANNEL);
|
||||||
|
|
||||||
// if needed, add input/output data to echo analysis buffers
|
// if needed, add input/output data to echo analysis buffers
|
||||||
if (parentAudio->_isGatheringEchoFrames) {
|
if (parentAudio->_echoInputFrameCountdown > 0) {
|
||||||
memcpy(parentAudio->_echoInputSamples, inputLeft,
|
if (--parentAudio->_echoInputFrameCountdown == 0) {
|
||||||
|
memcpy(parentAudio->_echoInputSamples, inputLeft,
|
||||||
PACKET_LENGTH_SAMPLES_PER_CHANNEL * sizeof(int16_t));
|
PACKET_LENGTH_SAMPLES_PER_CHANNEL * sizeof(int16_t));
|
||||||
|
parentAudio->_echoInputFrameCountdown = 0;
|
||||||
|
printLog("got input\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parentAudio->_isGatheringEchoOutputFrames) {
|
||||||
memcpy(parentAudio->_echoOutputSamples, outputLeft,
|
memcpy(parentAudio->_echoOutputSamples, outputLeft,
|
||||||
PACKET_LENGTH_SAMPLES_PER_CHANNEL * sizeof(int16_t));
|
PACKET_LENGTH_SAMPLES_PER_CHANNEL * sizeof(int16_t));
|
||||||
parentAudio->addedPingFrame();
|
parentAudio->_isGatheringEchoOutputFrames = false;
|
||||||
|
parentAudio->_echoInputFrameCountdown = 2;
|
||||||
|
printLog("got output\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputLeft != NULL) {
|
if (inputLeft != NULL) {
|
||||||
|
@ -273,7 +282,10 @@ int audioCallback (const void* inputBuffer,
|
||||||
for (int s = 0; s < PACKET_LENGTH_SAMPLES_PER_CHANNEL; s++) {
|
for (int s = 0; s < PACKET_LENGTH_SAMPLES_PER_CHANNEL; s++) {
|
||||||
outputLeft[s] = outputRight[s] = (int16_t)(sinf((float) s / PING_PITCH) * PING_VOLUME);
|
outputLeft[s] = outputRight[s] = (int16_t)(sinf((float) s / PING_PITCH) * PING_VOLUME);
|
||||||
}
|
}
|
||||||
parentAudio->_isGatheringEchoFrames = true;
|
printLog("Send echo ping\n");
|
||||||
|
parentAudio->_isSendingEchoPing = false;
|
||||||
|
parentAudio->_isGatheringEchoOutputFrames = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
gettimeofday(&parentAudio->_lastCallbackTime, NULL);
|
gettimeofday(&parentAudio->_lastCallbackTime, NULL);
|
||||||
return paContinue;
|
return paContinue;
|
||||||
|
@ -293,6 +305,9 @@ Audio::Audio(Oscilloscope* scope) :
|
||||||
_scope(scope),
|
_scope(scope),
|
||||||
_averagedLatency(0.0),
|
_averagedLatency(0.0),
|
||||||
_measuredJitter(0),
|
_measuredJitter(0),
|
||||||
|
_jitterBufferLengthMsecs(12.0),
|
||||||
|
_jitterBufferSamples(_jitterBufferLengthMsecs *
|
||||||
|
NUM_AUDIO_CHANNELS * (SAMPLE_RATE / 1000.0)),
|
||||||
_wasStarved(0),
|
_wasStarved(0),
|
||||||
_lastInputLoudness(0),
|
_lastInputLoudness(0),
|
||||||
_mixerLoopbackFlag(false),
|
_mixerLoopbackFlag(false),
|
||||||
|
@ -303,8 +318,8 @@ Audio::Audio(Oscilloscope* scope) :
|
||||||
_packetsReceivedThisPlayback(0),
|
_packetsReceivedThisPlayback(0),
|
||||||
_shouldStartEcho(false),
|
_shouldStartEcho(false),
|
||||||
_isSendingEchoPing(false),
|
_isSendingEchoPing(false),
|
||||||
_echoPingFrameCount(0),
|
_echoInputFrameCountdown(0),
|
||||||
_isGatheringEchoFrames(false)
|
_isGatheringEchoOutputFrames(false)
|
||||||
{
|
{
|
||||||
outputPortAudioError(Pa_Initialize());
|
outputPortAudioError(Pa_Initialize());
|
||||||
outputPortAudioError(Pa_OpenDefaultStream(&_stream,
|
outputPortAudioError(Pa_OpenDefaultStream(&_stream,
|
||||||
|
@ -376,20 +391,11 @@ void Audio::addProceduralSounds(int16_t* inputBuffer, int numSamples) {
|
||||||
|
|
||||||
void Audio::startEchoTest() {
|
void Audio::startEchoTest() {
|
||||||
_shouldStartEcho = true;
|
_shouldStartEcho = true;
|
||||||
_echoPingFrameCount = 0;
|
|
||||||
_isSendingEchoPing = true;
|
_isSendingEchoPing = true;
|
||||||
_isGatheringEchoFrames = false;
|
_isGatheringEchoOutputFrames = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::addedPingFrame() {
|
|
||||||
const int ECHO_PING_FRAMES = 1;
|
|
||||||
_echoPingFrameCount++;
|
|
||||||
if (_echoPingFrameCount == ECHO_PING_FRAMES) {
|
|
||||||
_isGatheringEchoFrames = false;
|
|
||||||
_isSendingEchoPing = false;
|
|
||||||
//startEchoTest();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void Audio::analyzeEcho(int16_t* inputBuffer, int16_t* outputBuffer, int numSamples) {
|
void Audio::analyzeEcho(int16_t* inputBuffer, int16_t* outputBuffer, int numSamples) {
|
||||||
// Compare output and input streams, looking for evidence of correlation needing echo cancellation
|
// Compare output and input streams, looking for evidence of correlation needing echo cancellation
|
||||||
//
|
//
|
||||||
|
|
|
@ -38,7 +38,6 @@ public:
|
||||||
void addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBytes);
|
void addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBytes);
|
||||||
|
|
||||||
void startEchoTest();
|
void startEchoTest();
|
||||||
void addedPingFrame();
|
|
||||||
void renderEchoCompare();
|
void renderEchoCompare();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -49,6 +48,8 @@ private:
|
||||||
timeval _lastReceiveTime;
|
timeval _lastReceiveTime;
|
||||||
float _averagedLatency;
|
float _averagedLatency;
|
||||||
float _measuredJitter;
|
float _measuredJitter;
|
||||||
|
float _jitterBufferLengthMsecs;
|
||||||
|
short _jitterBufferSamples;
|
||||||
int _wasStarved;
|
int _wasStarved;
|
||||||
float _lastInputLoudness;
|
float _lastInputLoudness;
|
||||||
bool _mixerLoopbackFlag;
|
bool _mixerLoopbackFlag;
|
||||||
|
@ -57,12 +58,15 @@ private:
|
||||||
int _totalPacketsReceived;
|
int _totalPacketsReceived;
|
||||||
timeval _firstPlaybackTime;
|
timeval _firstPlaybackTime;
|
||||||
int _packetsReceivedThisPlayback;
|
int _packetsReceivedThisPlayback;
|
||||||
|
// Echo Analysis
|
||||||
bool _shouldStartEcho;
|
bool _shouldStartEcho;
|
||||||
bool _isSendingEchoPing;
|
bool _isSendingEchoPing;
|
||||||
int _echoPingFrameCount;
|
|
||||||
int16_t* _echoInputSamples;
|
int16_t* _echoInputSamples;
|
||||||
int16_t* _echoOutputSamples;
|
int16_t* _echoOutputSamples;
|
||||||
bool _isGatheringEchoFrames;
|
int _echoInputFrameCountdown;
|
||||||
|
bool _isGatheringEchoOutputFrames;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// give access to AudioData class from audioCallback
|
// give access to AudioData class from audioCallback
|
||||||
friend int audioCallback (const void*, void*, unsigned long, const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags, void*);
|
friend int audioCallback (const void*, void*, unsigned long, const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags, void*);
|
||||||
|
|
|
@ -188,9 +188,9 @@ bool Avatar::getIsNearInteractingOther() {
|
||||||
|
|
||||||
void Avatar::updateFromMouse(int mouseX, int mouseY, int screenWidth, int screenHeight) {
|
void Avatar::updateFromMouse(int mouseX, int mouseY, int screenWidth, int screenHeight) {
|
||||||
// Update yaw based on mouse behavior
|
// Update yaw based on mouse behavior
|
||||||
const float MOUSE_MOVE_RADIUS = 0.25f;
|
const float MOUSE_MOVE_RADIUS = 0.15f;
|
||||||
const float MOUSE_ROTATE_SPEED = 5.0f;
|
const float MOUSE_ROTATE_SPEED = 3.0f;
|
||||||
const float MOUSE_PITCH_SPEED = 3.0f;
|
const float MOUSE_PITCH_SPEED = 1.5f;
|
||||||
const float MAX_YAW_TO_ADD = 180.f;
|
const float MAX_YAW_TO_ADD = 180.f;
|
||||||
const int TITLE_BAR_HEIGHT = 46;
|
const int TITLE_BAR_HEIGHT = 46;
|
||||||
float mouseLocationX = (float)mouseX / (float)screenWidth - 0.5f;
|
float mouseLocationX = (float)mouseX / (float)screenWidth - 0.5f;
|
||||||
|
@ -1377,4 +1377,4 @@ void Avatar::readAvatarDataFromFile() {
|
||||||
}
|
}
|
||||||
fclose(avatarFile);
|
fclose(avatarFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue