create a FreeVerb object for each other agent per agent

This commit is contained in:
Stephen Birarda 2013-05-31 15:47:54 -07:00
parent 3984a80bf7
commit 2d7c397138
12 changed files with 63 additions and 26 deletions

View file

@ -162,11 +162,10 @@ int main(int argc, const char* argv[]) {
int numSamplesDelay = 0;
float weakChannelAmplitudeRatio = 1.f;
// setup the FreeVerb object for this client and source
stk::FreeVerb freeVerb;
freeVerb.setEffectMix(0.0f);
stk::FreeVerb* otherAgentFreeVerb = NULL;
if (otherAgent != agent) {
glm::vec3 agentPosition = agentRingBuffer->getPosition();
glm::vec3 otherAgentPosition = otherAgentBuffer->getPosition();
@ -243,19 +242,28 @@ int main(int argc, const char* argv[]) {
* otherAgentBuffer->getAttenuationRatio()
* offAxisCoefficient;
// setup the freeVerb effect for this source for this client
freeVerb.setDamping(DISTANCE_REVERB_DAMPING);
freeVerb.setRoomSize(DISTANCE_REVERB_ROOM_SIZE);
freeVerb.setWidth(DISTANCE_REVERB_WIDTH);
printf("EM set to %f\n", audioFactors[lowAgentIndex][highAgentIndex].effectMix);
freeVerb.setEffectMix(audioFactors[lowAgentIndex][highAgentIndex].effectMix);
bearingRelativeAngleToSource *= (M_PI / 180);
float sinRatio = fabsf(sinf(bearingRelativeAngleToSource));
numSamplesDelay = PHASE_DELAY_AT_90 * sinRatio;
weakChannelAmplitudeRatio = 1 - (PHASE_AMPLITUDE_RATIO_AT_90 * sinRatio);
std::map<uint16_t, stk::FreeVerb*>& agentFreeVerbs = agentRingBuffer->getFreeVerbs();
if (agentFreeVerbs.count(otherAgent->getAgentID()) == 0) {
// setup the freeVerb effect for this source for this client
otherAgentFreeVerb = agentFreeVerbs[otherAgent->getAgentID()] = new stk::FreeVerb;
otherAgentFreeVerb->setDamping(DISTANCE_REVERB_DAMPING);
otherAgentFreeVerb->setRoomSize(DISTANCE_REVERB_ROOM_SIZE);
otherAgentFreeVerb->setWidth(DISTANCE_REVERB_WIDTH);
} else {
otherAgentFreeVerb = agentFreeVerbs[otherAgent->getAgentID()];
}
otherAgentFreeVerb->setEffectMix(audioFactors[lowAgentIndex][highAgentIndex].effectMix);
}
int16_t* goodChannel = bearingRelativeAngleToSource > 0.0f
@ -278,7 +286,9 @@ int main(int argc, const char* argv[]) {
* weakChannelAmplitudeRatio;
// apply the STK FreeVerb effect
earlierSample = freeVerb.tick(earlierSample);
if (otherAgentFreeVerb) {
earlierSample = otherAgentFreeVerb->tick(earlierSample);
}
plateauAdditionOfSamples(delayedChannel[s], earlierSample);
}
@ -286,7 +296,9 @@ int main(int argc, const char* argv[]) {
int16_t currentSample = (otherAgentBuffer->getNextOutput()[s] * attenuationCoefficient);
// apply the STK FreeVerb effect
currentSample = freeVerb.tick(currentSample);
if (otherAgentFreeVerb) {
currentSample = otherAgentFreeVerb->tick(currentSample);
}
plateauAdditionOfSamples(goodChannel[s], currentSample);

View file

@ -19,4 +19,10 @@ include_glm(${TARGET_NAME} ${ROOT_DIR})
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR})
link_hifi_library(audio ${TARGET_NAME} ${ROOT_DIR})
link_hifi_library(avatars ${TARGET_NAME} ${ROOT_DIR})
link_hifi_library(avatars ${TARGET_NAME} ${ROOT_DIR})
# link the stk library
set(STK_ROOT_DIR ${ROOT_DIR}/externals/stk)
find_package(STK REQUIRED)
target_link_libraries(${TARGET_NAME} ${STK_LIBRARIES})
include_directories(${STK_INCLUDE_DIRS})

View file

@ -146,6 +146,12 @@ else (WIN32)
include_directories(${PORTAUDIO_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} ${PORTAUDIO_LIBRARIES})
# link the stk library
set(STK_ROOT_DIR ${ROOT_DIR}/externals/stk)
find_package(STK REQUIRED)
target_link_libraries(${TARGET_NAME} ${STK_LIBRARIES})
include_directories(${STK_INCLUDE_DIRS})
# link required libraries on UNIX
if (UNIX AND NOT APPLE)
find_package(Threads REQUIRED)

View file

@ -380,7 +380,7 @@ void Application::resizeGL(int width, int height) {
if (OculusManager::isConnected()) {
// more magic numbers; see Oculus SDK docs, p. 32
camera.setAspectRatio(aspectRatio *= 0.5);
camera.setFieldOfView(fov = 2 * atan((0.0468 * _oculusDistortionScale) / 0.041) * (180 / PI));
camera.setFieldOfView(fov = 2 * atan((0.0468 * _oculusDistortionScale) / 0.041) * (180 / PIf));
// resize the render texture
if (_oculusTextureID != 0) {

View file

@ -792,7 +792,7 @@ void Avatar::render(bool lookingInMirror, glm::vec3 cameraPosition) {
glTranslatef(_joint[AVATAR_JOINT_HEAD_BASE].springyPosition.x,
_joint[AVATAR_JOINT_HEAD_BASE].springyPosition.y + chatMessageHeight,
_joint[AVATAR_JOINT_HEAD_BASE].springyPosition.z);
glRotatef(atan2(-modelview[2], -modelview[10]) * 180 / PI, 0, 1, 0);
glRotatef(atan2(-modelview[2], -modelview[10]) * 180 / PIf, 0, 1, 0);
glColor3f(0, 0.8, 0);
glRotatef(180, 0, 0, 1);
@ -1274,7 +1274,7 @@ void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
// the rectangles that comprise the sides of the cone section are
// referenced by "a" and "b" in one dimension, and "1", and "2" in the other dimension.
anglea = angleb;
angleb = ((float)(i+1) / (float)NUM_BODY_CONE_SIDES) * PI * 2.0f;
angleb = ((float)(i+1) / (float)NUM_BODY_CONE_SIDES) * PIf * 2.0f;
float sa = sinf(anglea);
float sb = sinf(angleb);

View file

@ -250,9 +250,9 @@ void Head::createMohawk() {
for (int i = 1; i < MOHAWK_TRIANGLES; i++) {
_mohawkTriangleFan[i] = glm::vec3((randFloat() - 0.5f) * variance,
height * cosf(i * RAD_PER_TRIANGLE - PI / 2.f)
height * cosf(i * RAD_PER_TRIANGLE - PIf / 2.f)
+ (randFloat() - 0.5f) * variance,
height * sinf(i * RAD_PER_TRIANGLE - PI / 2.f)
height * sinf(i * RAD_PER_TRIANGLE - PIf / 2.f)
+ (randFloat() - 0.5f) * variance);
_mohawkColors[i] = randFloat() * basicColor;

View file

@ -51,6 +51,8 @@ void Transmitter::processIncomingData(unsigned char* packetData, int numBytes) {
// Update estimated absolute position from rotation rates
_estimatedRotation += _lastRotationRate * DELTA_TIME;
printf("The accel %f, %f, %f\n", _lastAcceleration.x, _lastAcceleration.y, _lastAcceleration.z);
// Sensor Fusion! Slowly adjust estimated rotation to be relative to gravity (average acceleration)
const float GRAVITY_FOLLOW_RATE = 1.f;

View file

@ -68,7 +68,7 @@ float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float
// Helper function returns the positive angle in degrees between two 3D vectors
float angleBetween(const glm::vec3& v1, const glm::vec3& v2) {
return acos((glm::dot(v1, v2)) / (glm::length(v1) * glm::length(v2))) * 180.f / PI;
return acos((glm::dot(v1, v2)) / (glm::length(v1) * glm::length(v2))) * 180.f / PIf;
}
// Draw a 3D vector floating in space
@ -275,7 +275,7 @@ void renderDiskShadow(glm::vec3 position, glm::vec3 upDirection, float radius, f
for (int i=1; i<num+1; i++) {
x1 = x2;
z1 = z2;
float r = ((float)i / (float)num) * PI * 2.0;
float r = ((float)i / (float)num) * PIf * 2.0;
x2 = radius * sin(r);
z2 = radius * cos(r);
@ -296,7 +296,7 @@ void renderSphereOutline(glm::vec3 position, float radius, int numSides, glm::ve
glBegin(GL_LINE_STRIP);
for (int i=0; i<numSides+1; i++) {
float r = ((float)i / (float)numSides) * PI * 2.0;
float r = ((float)i / (float)numSides) * PIf * 2.0;
float s = radius * sin(r);
float c = radius * cos(r);
@ -319,7 +319,7 @@ void renderCircle(glm::vec3 position, float radius, glm::vec3 surfaceNormal, int
glBegin(GL_LINE_STRIP);
for (int i=0; i<numSides+1; i++) {
float r = ((float)i / (float)numSides) * PI * 2.0;
float r = ((float)i / (float)numSides) * PIf * 2.0;
float s = radius * sin(r);
float c = radius * cos(r);
glVertex3f

View file

@ -13,7 +13,6 @@
const float WORLD_SIZE = 10.0;
#define PI 3.14159265
#define PIf 3.14159265f
#define GRAVITY_EARTH 9.80665f;

View file

@ -19,4 +19,10 @@ link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR})
# link the threads library
find_package(Threads REQUIRED)
target_link_libraries(${TARGET_NAME} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${TARGET_NAME} ${CMAKE_THREAD_LIBS_INIT})
# link the stk library
set(STK_ROOT_DIR ${ROOT_DIR}/externals/stk)
find_package(STK REQUIRED)
target_link_libraries(${TARGET_NAME} ${STK_LIBRARIES})
include_directories(${STK_INCLUDE_DIRS})

View file

@ -10,8 +10,11 @@
#define __interface__AudioRingBuffer__
#include <stdint.h>
#include <map>
#include <glm/glm.hpp>
#include <Stk.h>
#include <FreeVerb.h>
#include "AgentData.h"
@ -32,6 +35,8 @@ public:
int16_t* getBuffer() const { return _buffer; }
std::map<uint16_t, stk::FreeVerb*>& getFreeVerbs() { return _freeVerbs; }
bool isStarted() const { return _started; }
void setStarted(bool started) { _started = started; }
@ -62,6 +67,7 @@ private:
bool _shouldBeAddedToMix;
bool _shouldLoopbackForAgent;
unsigned char _streamIdentifier[STREAM_IDENTIFIER_NUM_BYTES];
std::map<uint16_t, stk::FreeVerb*> _freeVerbs;
};
#endif /* defined(__interface__AudioRingBuffer__) */

View file

@ -30,7 +30,7 @@ const char SOLO_AGENT_TYPES[3] = {
};
char DOMAIN_HOSTNAME[] = "highfidelity.below92.com";
char DOMAIN_IP[100] = ""; // IP Address will be re-set by lookup on startup
char DOMAIN_IP[100] = "192.168.1.47"; // IP Address will be re-set by lookup on startup
const int DOMAINSERVER_PORT = 40102;
bool silentAgentThreadStopFlag = false;