mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:48:44 +02:00
mix together client samples, don't overwrite
This commit is contained in:
parent
4a0aba9fb6
commit
615d1d5152
1 changed files with 17 additions and 7 deletions
|
@ -43,6 +43,15 @@ const int DOMAINSERVER_PORT = 40102;
|
||||||
|
|
||||||
AgentList agentList(MIXER_LISTEN_PORT);
|
AgentList agentList(MIXER_LISTEN_PORT);
|
||||||
|
|
||||||
|
void plateauAdditionOfSamples(int16_t &mixSample, int16_t sampleToAdd) {
|
||||||
|
long sumSample = sampleToAdd + mixSample;
|
||||||
|
|
||||||
|
long normalizedSample = std::max((long)INT16_MAX, sumSample);
|
||||||
|
normalizedSample = std::min((long)INT16_MIN, sumSample);
|
||||||
|
|
||||||
|
mixSample = normalizedSample;
|
||||||
|
}
|
||||||
|
|
||||||
void *sendBuffer(void *args)
|
void *sendBuffer(void *args)
|
||||||
{
|
{
|
||||||
int sentBytes;
|
int sentBytes;
|
||||||
|
@ -144,20 +153,21 @@ void *sendBuffer(void *args)
|
||||||
? otherAgentBuffer->getBuffer() + RING_BUFFER_SAMPLES - numSamplesDelay
|
? otherAgentBuffer->getBuffer() + RING_BUFFER_SAMPLES - numSamplesDelay
|
||||||
: otherAgentBuffer->getNextOutput() - numSamplesDelay;
|
: otherAgentBuffer->getNextOutput() - numSamplesDelay;
|
||||||
|
|
||||||
|
|
||||||
for (int s = 0; s < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; s++) {
|
for (int s = 0; s < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; s++) {
|
||||||
|
|
||||||
if (s < numSamplesDelay) {
|
if (s < numSamplesDelay) {
|
||||||
// pull the earlier sample for the delayed channel
|
// pull the earlier sample for the delayed channel
|
||||||
|
|
||||||
int earlierSample = delaySamplePointer[s] * distanceCoeffs[lowAgentIndex][highAgentIndex];
|
int earlierSample = delaySamplePointer[s] * distanceCoeffs[lowAgentIndex][highAgentIndex];
|
||||||
delayedChannel[s] = earlierSample;
|
plateauAdditionOfSamples(delayedChannel[s], earlierSample);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t currentSample = (otherAgentBuffer->getNextOutput()[s] * distanceCoeffs[lowAgentIndex][highAgentIndex]);
|
int16_t currentSample = (otherAgentBuffer->getNextOutput()[s] * distanceCoeffs[lowAgentIndex][highAgentIndex]);
|
||||||
goodChannel[s] = currentSample;
|
plateauAdditionOfSamples(goodChannel[s], currentSample);
|
||||||
|
|
||||||
if (s + numSamplesDelay < BUFFER_LENGTH_SAMPLES_PER_CHANNEL) {
|
if (s + numSamplesDelay < BUFFER_LENGTH_SAMPLES_PER_CHANNEL) {
|
||||||
delayedChannel[s + numSamplesDelay] = currentSample;
|
plateauAdditionOfSamples(delayedChannel[s + numSamplesDelay], currentSample);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,10 +238,6 @@ int main(int argc, const char * argv[])
|
||||||
|
|
||||||
agentList.startSilentAgentRemovalThread();
|
agentList.startSilentAgentRemovalThread();
|
||||||
|
|
||||||
// setup the agentSocket to report to domain server
|
|
||||||
pthread_t reportAliveThread;
|
|
||||||
pthread_create(&reportAliveThread, NULL, reportAliveToDS, NULL);
|
|
||||||
|
|
||||||
// Lookup the IP address of things we have hostnames
|
// Lookup the IP address of things we have hostnames
|
||||||
if (atoi(DOMAIN_IP) == 0) {
|
if (atoi(DOMAIN_IP) == 0) {
|
||||||
struct hostent* pHostInfo;
|
struct hostent* pHostInfo;
|
||||||
|
@ -248,6 +254,10 @@ int main(int argc, const char * argv[])
|
||||||
printf("Using static domainserver IP: %s\n", DOMAIN_IP);
|
printf("Using static domainserver IP: %s\n", DOMAIN_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setup the agentSocket to report to domain server
|
||||||
|
pthread_t reportAliveThread;
|
||||||
|
pthread_create(&reportAliveThread, NULL, reportAliveToDS, NULL);
|
||||||
|
|
||||||
unsigned char *packetData = new unsigned char[MAX_PACKET_SIZE];
|
unsigned char *packetData = new unsigned char[MAX_PACKET_SIZE];
|
||||||
|
|
||||||
pthread_t sendBufferThread;
|
pthread_t sendBufferThread;
|
||||||
|
|
Loading…
Reference in a new issue