mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 20:56:25 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
a9bd6718ff
4 changed files with 22 additions and 19 deletions
|
@ -54,7 +54,7 @@
|
||||||
const short JITTER_BUFFER_MSECS = 12;
|
const short JITTER_BUFFER_MSECS = 12;
|
||||||
const short JITTER_BUFFER_SAMPLES = JITTER_BUFFER_MSECS * (SAMPLE_RATE / 1000.0);
|
const short JITTER_BUFFER_SAMPLES = JITTER_BUFFER_MSECS * (SAMPLE_RATE / 1000.0);
|
||||||
|
|
||||||
const unsigned int BUFFER_SEND_INTERVAL_USECS = floorf((BUFFER_LENGTH_SAMPLES_PER_CHANNEL / SAMPLE_RATE) * 1000 * 1000);
|
const unsigned int BUFFER_SEND_INTERVAL_USECS = floorf((BUFFER_LENGTH_SAMPLES_PER_CHANNEL / (float) SAMPLE_RATE) * 1000 * 1000);
|
||||||
|
|
||||||
const int MAX_SAMPLE_VALUE = std::numeric_limits<int16_t>::max();
|
const int MAX_SAMPLE_VALUE = std::numeric_limits<int16_t>::max();
|
||||||
const int MIN_SAMPLE_VALUE = std::numeric_limits<int16_t>::min();
|
const int MIN_SAMPLE_VALUE = std::numeric_limits<int16_t>::min();
|
||||||
|
|
|
@ -4239,7 +4239,8 @@ void* Application::networkReceive(void* args) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case PACKET_TYPE_MIXED_AUDIO:
|
case PACKET_TYPE_MIXED_AUDIO:
|
||||||
app->_audio.addReceivedAudioToBuffer(app->_incomingPacket, bytesReceived);
|
QMetaObject::invokeMethod(&app->_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection,
|
||||||
|
Q_ARG(QByteArray, QByteArray((char*) app->_incomingPacket, bytesReceived)));
|
||||||
break;
|
break;
|
||||||
case PACKET_TYPE_VOXEL_DATA:
|
case PACKET_TYPE_VOXEL_DATA:
|
||||||
case PACKET_TYPE_VOXEL_ERASE:
|
case PACKET_TYPE_VOXEL_ERASE:
|
||||||
|
|
|
@ -31,8 +31,7 @@
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
|
||||||
static const float JITTER_BUFFER_LENGTH_MSECS = 12;
|
static const float JITTER_BUFFER_LENGTH_MSECS = 12;
|
||||||
static const short JITTER_BUFFER_SAMPLES = JITTER_BUFFER_LENGTH_MSECS *
|
static const short JITTER_BUFFER_SAMPLES = JITTER_BUFFER_LENGTH_MSECS * NUM_AUDIO_CHANNELS * (SAMPLE_RATE / 1000.0);
|
||||||
NUM_AUDIO_CHANNELS * (SAMPLE_RATE / 1000.0);
|
|
||||||
|
|
||||||
static const float AUDIO_CALLBACK_MSECS = (float)BUFFER_LENGTH_SAMPLES_PER_CHANNEL / (float)SAMPLE_RATE * 1000.0;
|
static const float AUDIO_CALLBACK_MSECS = (float)BUFFER_LENGTH_SAMPLES_PER_CHANNEL / (float)SAMPLE_RATE * 1000.0;
|
||||||
|
|
||||||
|
@ -240,8 +239,7 @@ void Audio::handleAudioInput() {
|
||||||
// + 12 for 3 floats for position + float for bearing + 1 attenuation byte
|
// + 12 for 3 floats for position + float for bearing + 1 attenuation byte
|
||||||
|
|
||||||
PACKET_TYPE packetType = Menu::getInstance()->isOptionChecked(MenuOption::EchoServerAudio)
|
PACKET_TYPE packetType = Menu::getInstance()->isOptionChecked(MenuOption::EchoServerAudio)
|
||||||
? PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO
|
? PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO : PACKET_TYPE_MICROPHONE_AUDIO_NO_ECHO;
|
||||||
: PACKET_TYPE_MICROPHONE_AUDIO_NO_ECHO;
|
|
||||||
|
|
||||||
char* currentPacketPtr = monoAudioDataPacket + populateTypeAndVersion((unsigned char*) monoAudioDataPacket,
|
char* currentPacketPtr = monoAudioDataPacket + populateTypeAndVersion((unsigned char*) monoAudioDataPacket,
|
||||||
packetType);
|
packetType);
|
||||||
|
@ -279,6 +277,9 @@ void Audio::handleAudioInput() {
|
||||||
nodeList->getNodeSocket().writeDatagram(monoAudioDataPacket, BUFFER_LENGTH_BYTES_PER_CHANNEL + leadingBytes,
|
nodeList->getNodeSocket().writeDatagram(monoAudioDataPacket, BUFFER_LENGTH_BYTES_PER_CHANNEL + leadingBytes,
|
||||||
audioMixer->getActiveSocket()->getAddress(),
|
audioMixer->getActiveSocket()->getAddress(),
|
||||||
audioMixer->getActiveSocket()->getPort());
|
audioMixer->getActiveSocket()->getPort());
|
||||||
|
|
||||||
|
Application::getInstance()->getBandwidthMeter()->outputStream(BandwidthMeter::AUDIO)
|
||||||
|
.updateValue(BUFFER_LENGTH_BYTES_PER_CHANNEL + leadingBytes);
|
||||||
} else {
|
} else {
|
||||||
nodeList->pingPublicAndLocalSocketsForInactiveNode(audioMixer);
|
nodeList->pingPublicAndLocalSocketsForInactiveNode(audioMixer);
|
||||||
}
|
}
|
||||||
|
@ -343,6 +344,7 @@ void Audio::handleAudioInput() {
|
||||||
|
|
||||||
_outputDevice->write(stereoOutputBuffer);
|
_outputDevice->write(stereoOutputBuffer);
|
||||||
|
|
||||||
|
|
||||||
// add output (@speakers) data just written to the scope
|
// add output (@speakers) data just written to the scope
|
||||||
QMetaObject::invokeMethod(_scope, "addStereoSamples", Qt::QueuedConnection,
|
QMetaObject::invokeMethod(_scope, "addStereoSamples", Qt::QueuedConnection,
|
||||||
Q_ARG(QByteArray, stereoOutputBuffer), Q_ARG(bool, false));
|
Q_ARG(QByteArray, stereoOutputBuffer), Q_ARG(bool, false));
|
||||||
|
@ -352,7 +354,7 @@ void Audio::handleAudioInput() {
|
||||||
gettimeofday(&_lastCallbackTime, NULL);
|
gettimeofday(&_lastCallbackTime, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBytes) {
|
void Audio::addReceivedAudioToBuffer(const QByteArray& audioByteArray) {
|
||||||
const int NUM_INITIAL_PACKETS_DISCARD = 3;
|
const int NUM_INITIAL_PACKETS_DISCARD = 3;
|
||||||
const int STANDARD_DEVIATION_SAMPLE_COUNT = 500;
|
const int STANDARD_DEVIATION_SAMPLE_COUNT = 500;
|
||||||
|
|
||||||
|
@ -374,9 +376,7 @@ void Audio::addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBy
|
||||||
const int MAX_JITTER_BUFFER_SAMPLES = RING_BUFFER_LENGTH_SAMPLES / 2;
|
const int MAX_JITTER_BUFFER_SAMPLES = RING_BUFFER_LENGTH_SAMPLES / 2;
|
||||||
const float NUM_STANDARD_DEVIATIONS = 3.f;
|
const float NUM_STANDARD_DEVIATIONS = 3.f;
|
||||||
if (Menu::getInstance()->getAudioJitterBufferSamples() == 0) {
|
if (Menu::getInstance()->getAudioJitterBufferSamples() == 0) {
|
||||||
float newJitterBufferSamples = (NUM_STANDARD_DEVIATIONS * _measuredJitter)
|
float newJitterBufferSamples = (NUM_STANDARD_DEVIATIONS * _measuredJitter) / 1000.f * SAMPLE_RATE;
|
||||||
/ 1000.f
|
|
||||||
* SAMPLE_RATE;
|
|
||||||
setJitterBufferSamples(glm::clamp((int)newJitterBufferSamples, 0, MAX_JITTER_BUFFER_SAMPLES));
|
setJitterBufferSamples(glm::clamp((int)newJitterBufferSamples, 0, MAX_JITTER_BUFFER_SAMPLES));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,10 +393,10 @@ void Audio::addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_ringBuffer.parseData((unsigned char*) receivedData, receivedBytes);
|
_ringBuffer.parseData((unsigned char*) audioByteArray.data(), audioByteArray.size());
|
||||||
|
|
||||||
Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AUDIO)
|
Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AUDIO).updateValue(PACKET_LENGTH_BYTES
|
||||||
.updateValue(PACKET_LENGTH_BYTES + sizeof(PACKET_TYPE));
|
+ sizeof(PACKET_TYPE));
|
||||||
|
|
||||||
_lastReceiveTime = currentReceiveTime;
|
_lastReceiveTime = currentReceiveTime;
|
||||||
}
|
}
|
||||||
|
@ -410,7 +410,7 @@ bool Audio::mousePressEvent(int x, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::render(int screenWidth, int screenHeight) {
|
void Audio::render(int screenWidth, int screenHeight) {
|
||||||
if (true) {
|
if (_audioInput) {
|
||||||
glLineWidth(2.0);
|
glLineWidth(2.0);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glColor3f(1,1,1);
|
glColor3f(1,1,1);
|
||||||
|
@ -566,10 +566,13 @@ void Audio::addProceduralSounds(int16_t* inputBuffer, int16_t* stereoOutput, int
|
||||||
sample = sinf(t * frequency);
|
sample = sinf(t * frequency);
|
||||||
sample += ((randFloat() - 0.5f) * NOISE_MAGNITUDE);
|
sample += ((randFloat() - 0.5f) * NOISE_MAGNITUDE);
|
||||||
sample *= _drumSoundVolume * MAX_VOLUME;
|
sample *= _drumSoundVolume * MAX_VOLUME;
|
||||||
inputBuffer[i] += sample;
|
|
||||||
|
int16_t collisionSample = (int16_t) sample;
|
||||||
|
|
||||||
|
inputBuffer[i] += collisionSample;
|
||||||
|
|
||||||
for (int j = (i * 4); j < (i * 4) + 4; j++) {
|
for (int j = (i * 4); j < (i * 4) + 4; j++) {
|
||||||
stereoOutput[j] += sample;
|
stereoOutput[j] += collisionSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
_drumSoundVolume *= (1.f - _drumSoundDecay);
|
_drumSoundVolume *= (1.f - _drumSoundDecay);
|
||||||
|
|
|
@ -42,8 +42,6 @@ public:
|
||||||
|
|
||||||
void render(int screenWidth, int screenHeight);
|
void render(int screenWidth, int screenHeight);
|
||||||
|
|
||||||
void addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBytes);
|
|
||||||
|
|
||||||
float getLastInputLoudness() const { return _lastInputLoudness; }
|
float getLastInputLoudness() const { return _lastInputLoudness; }
|
||||||
|
|
||||||
void setLastAcceleration(const glm::vec3 lastAcceleration) { _lastAcceleration = lastAcceleration; }
|
void setLastAcceleration(const glm::vec3 lastAcceleration) { _lastAcceleration = lastAcceleration; }
|
||||||
|
@ -64,8 +62,9 @@ public:
|
||||||
void init(QGLWidget *parent = 0);
|
void init(QGLWidget *parent = 0);
|
||||||
bool mousePressEvent(int x, int y);
|
bool mousePressEvent(int x, int y);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void start();
|
void start();
|
||||||
|
void addReceivedAudioToBuffer(const QByteArray& audioByteArray);
|
||||||
void handleAudioInput();
|
void handleAudioInput();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue