mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
allow client to request loopback from mixer
This commit is contained in:
parent
39e8179473
commit
5535b8a4f5
6 changed files with 49 additions and 6 deletions
|
@ -39,6 +39,8 @@ const short JITTER_BUFFER_SAMPLES = JITTER_BUFFER_LENGTH_MSECS * (SAMPLE_RATE /
|
|||
const short NUM_AUDIO_SOURCES = 2;
|
||||
const short ECHO_SERVER_TEST = 1;
|
||||
|
||||
const int AGENT_LOOPBACK_MODIFIER = 307;
|
||||
|
||||
const char LOCALHOST_MIXER[] = "0.0.0.0";
|
||||
const char WORKCLUB_MIXER[] = "192.168.1.19";
|
||||
const char EC2_WEST_MIXER[] = "54.241.92.53";
|
||||
|
@ -116,6 +118,10 @@ int audioCallback (const void *inputBuffer,
|
|||
correctedYaw += 360;
|
||||
}
|
||||
|
||||
if (data->mixerLoopbackFlag) {
|
||||
correctedYaw = correctedYaw > 0 ? correctedYaw + AGENT_LOOPBACK_MODIFIER : correctedYaw - AGENT_LOOPBACK_MODIFIER;
|
||||
}
|
||||
|
||||
memcpy(currentPacketPtr, &correctedYaw, sizeof(float));
|
||||
currentPacketPtr += sizeof(float);
|
||||
|
||||
|
@ -261,6 +267,14 @@ void *receiveAudioViaUDP(void *args) {
|
|||
pthread_exit(0);
|
||||
}
|
||||
|
||||
void Audio::setMixerLoopbackFlag(bool newMixerLoopbackFlag) {
|
||||
audioData->mixerLoopbackFlag = newMixerLoopbackFlag;
|
||||
}
|
||||
|
||||
bool Audio::getMixerLoopbackFlag() {
|
||||
return audioData->mixerLoopbackFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize portaudio and start an audio stream.
|
||||
* Should be called at the beginning of program exection.
|
||||
|
|
|
@ -23,6 +23,9 @@ public:
|
|||
void render();
|
||||
void render(int screenWidth, int screenHeight);
|
||||
|
||||
bool getMixerLoopbackFlag();
|
||||
void setMixerLoopbackFlag(bool newMixerLoopbackFlag);
|
||||
|
||||
void getInputLoudness(float * lastLoudness, float * averageLoudness);
|
||||
void updateMixerParams(in_addr_t mixerAddress, in_port_t mixerPort);
|
||||
|
||||
|
@ -30,6 +33,7 @@ public:
|
|||
bool terminate();
|
||||
private:
|
||||
bool initialized;
|
||||
|
||||
AudioData *audioData;
|
||||
|
||||
// protects constructor so that public init method is used
|
||||
|
|
|
@ -17,6 +17,8 @@ AudioData::AudioData() {
|
|||
wasStarved = 0;
|
||||
measuredJitter = 0;
|
||||
jitterBuffer = 0;
|
||||
|
||||
mixerLoopbackFlag = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@ class AudioData {
|
|||
|
||||
float lastInputLoudness;
|
||||
float averagedInputLoudness;
|
||||
|
||||
bool mixerLoopbackFlag;
|
||||
};
|
||||
|
||||
#endif /* defined(__interface__AudioData__) */
|
||||
|
|
|
@ -720,7 +720,12 @@ void key(unsigned char k, int x, int y)
|
|||
}
|
||||
|
||||
}
|
||||
if (k == 'h') display_head = !display_head;
|
||||
|
||||
if (k == 'h') {
|
||||
display_head = !display_head;
|
||||
audio.setMixerLoopbackFlag(display_head);
|
||||
}
|
||||
|
||||
if (k == 'm') head_mirror = !head_mirror;
|
||||
|
||||
if (k == 'f') display_field = !display_field;
|
||||
|
|
|
@ -37,6 +37,8 @@ const long MIN_SAMPLE_VALUE = std::numeric_limits<int16_t>::min();
|
|||
const float DISTANCE_RATIO = 3.0/4.2;
|
||||
const int PHASE_DELAY_AT_90 = 20;
|
||||
|
||||
const int AGENT_LOOPBACK_MODIFIER = 307;
|
||||
|
||||
char DOMAIN_HOSTNAME[] = "highfidelity.below92.com";
|
||||
char DOMAIN_IP[100] = ""; // IP Address will be re-set by lookup on startup
|
||||
const int DOMAINSERVER_PORT = 40102;
|
||||
|
@ -89,11 +91,23 @@ void *sendBuffer(void *args)
|
|||
for (int i = 0; i < agentList.getAgents().size(); i++) {
|
||||
Agent *agent = &agentList.getAgents()[i];
|
||||
|
||||
AudioRingBuffer *agentRingBuffer = (AudioRingBuffer *) agent->getLinkedData();
|
||||
float agentBearing = agentRingBuffer->getBearing();
|
||||
bool agentWantsLoopback = false;
|
||||
|
||||
if (agentBearing > 180 || agentBearing < -180) {
|
||||
// we were passed an invalid bearing because this agent wants loopback (pressed the H key)
|
||||
agentWantsLoopback = true;
|
||||
|
||||
// correct the bearing
|
||||
agentBearing = agentBearing > 0 ? agentBearing - AGENT_LOOPBACK_MODIFIER : agentBearing + AGENT_LOOPBACK_MODIFIER;
|
||||
}
|
||||
|
||||
int16_t clientMix[BUFFER_LENGTH_SAMPLES_PER_CHANNEL * 2] = {};
|
||||
|
||||
|
||||
for (int j = 0; j < agentList.getAgents().size(); j++) {
|
||||
if (i != j) {
|
||||
AudioRingBuffer *agentRingBuffer = (AudioRingBuffer *) agent->getLinkedData();
|
||||
if (i != j || ( i == j && agentWantsLoopback)) {
|
||||
AudioRingBuffer *otherAgentBuffer = (AudioRingBuffer *)agentList.getAgents()[j].getLinkedData();
|
||||
|
||||
float *agentPosition = agentRingBuffer->getPosition();
|
||||
|
@ -118,7 +132,9 @@ void *sendBuffer(void *args)
|
|||
float triangleAngle = atan2f(fabsf(agentPosition[2] - otherAgentPosition[2]), fabsf(agentPosition[0] - otherAgentPosition[0])) * (180 / M_PI);
|
||||
float angleToSource;
|
||||
|
||||
float agentBearing = agentRingBuffer->getBearing();
|
||||
if (agentWantsLoopback) {
|
||||
|
||||
}
|
||||
|
||||
// find the angle we need for calculation based on the orientation of the triangle
|
||||
if (otherAgentPosition[0] > agentPosition[0]) {
|
||||
|
@ -210,8 +226,8 @@ void *reportAliveToDS(void *args) {
|
|||
gettimeofday(&lastSend, NULL);
|
||||
|
||||
*output = 'M';
|
||||
packSocket(output + 1, 895283510, htons(MIXER_LISTEN_PORT));
|
||||
// packSocket(output + 1, 788637888, htons(MIXER_LISTEN_PORT));
|
||||
// packSocket(output + 1, 895283510, htons(MIXER_LISTEN_PORT));
|
||||
packSocket(output + 1, 788637888, htons(MIXER_LISTEN_PORT));
|
||||
agentList.getAgentSocket().send(DOMAIN_IP, DOMAINSERVER_PORT, output, 7);
|
||||
|
||||
double usecToSleep = 1000000 - (usecTimestampNow() - usecTimestamp(&lastSend));
|
||||
|
|
Loading…
Reference in a new issue