Horst
February 19th, 2003, 11:06 AM
I have created a program using sockets and multimedia api in c-language.
The problem I've got is:
Sending the data across the network and replaying work fine.
But sending data from two stations and mixing them for replay produces simply noise.
I use a DWORD-array to store the added values of my channel buffers (unsigned short arrays).
Then i divide these values by the number of communication channels and then these data are played back.
As I said: with one channel it work (no big deal its just a division one) but even 2 channels create only static.
The problem is this has to be live data. (It's going to be a kind of radio transmission over network) I have spend all day to find a flaw, but there seems to be not problem with the logic.
Here some code fragment:
QueryPerformanceCounter(&TimeStamp);
ZeroMemory (MixData, sizeof (DWORD) * INBUFFER);
TimeFrame.QuadPart = TimeStamp.QuadPart - (FrequencyMilisec.QuadPart * WAITTIME);
for (i = 0; i < MAX_CHANNELS; i++)
{
if (ChannelData[i].Active)
{
if (ChannelData[i].FirstData)
{
if (ChannelData[i].FirstData->Data->TimeStamp.QuadPart < TimeFrame.QuadPart)
{
ChannelMixCount[i]++;
MixCount++;
Channels.QuadPart |= ChannelData[i].FirstData->Data->Channels.QuadPart;
length = ChannelData[i].FirstData->Data->Header.dwBufferLength;
if (length > maxlength)
{
maxlength = length;
}
memcpy (InBuffer, ChannelData[i].FirstData->Data->Header.lpData, length);
for (j = 0; j < (length / 2); j++)
{
MixData[j] += (DWORD)InBuffer[j];
}
EnterCriticalSection(&PrepareSection);
OldListElem = ChannelData[i].FirstData;
ChannelData[i].FirstData = ChannelData[i].FirstData->next;
GlobalFree(OldListElem->Data);
OldListElem->Data = NULL;
GlobalFree(OldListElem);
OldListElem = NULL;
LeaveCriticalSection(&PrepareSection);
}
else
{
break;
}
}
}
}
if (MixCount > 0)
{
if (MixCount > 1)
{
MixCounter++;
}
for (j = 0; j < (maxlength / 2); j++)
{
OutBuffer[j] = (unsigned short)(MixData[j] / MixCount);
}
Can anybody help me?
Thanks
Horst
The problem I've got is:
Sending the data across the network and replaying work fine.
But sending data from two stations and mixing them for replay produces simply noise.
I use a DWORD-array to store the added values of my channel buffers (unsigned short arrays).
Then i divide these values by the number of communication channels and then these data are played back.
As I said: with one channel it work (no big deal its just a division one) but even 2 channels create only static.
The problem is this has to be live data. (It's going to be a kind of radio transmission over network) I have spend all day to find a flaw, but there seems to be not problem with the logic.
Here some code fragment:
QueryPerformanceCounter(&TimeStamp);
ZeroMemory (MixData, sizeof (DWORD) * INBUFFER);
TimeFrame.QuadPart = TimeStamp.QuadPart - (FrequencyMilisec.QuadPart * WAITTIME);
for (i = 0; i < MAX_CHANNELS; i++)
{
if (ChannelData[i].Active)
{
if (ChannelData[i].FirstData)
{
if (ChannelData[i].FirstData->Data->TimeStamp.QuadPart < TimeFrame.QuadPart)
{
ChannelMixCount[i]++;
MixCount++;
Channels.QuadPart |= ChannelData[i].FirstData->Data->Channels.QuadPart;
length = ChannelData[i].FirstData->Data->Header.dwBufferLength;
if (length > maxlength)
{
maxlength = length;
}
memcpy (InBuffer, ChannelData[i].FirstData->Data->Header.lpData, length);
for (j = 0; j < (length / 2); j++)
{
MixData[j] += (DWORD)InBuffer[j];
}
EnterCriticalSection(&PrepareSection);
OldListElem = ChannelData[i].FirstData;
ChannelData[i].FirstData = ChannelData[i].FirstData->next;
GlobalFree(OldListElem->Data);
OldListElem->Data = NULL;
GlobalFree(OldListElem);
OldListElem = NULL;
LeaveCriticalSection(&PrepareSection);
}
else
{
break;
}
}
}
}
if (MixCount > 0)
{
if (MixCount > 1)
{
MixCounter++;
}
for (j = 0; j < (maxlength / 2); j++)
{
OutBuffer[j] = (unsigned short)(MixData[j] / MixCount);
}
Can anybody help me?
Thanks
Horst