13 #ifndef _MpBridgeAlgLinear_h_ 14 #define _MpBridgeAlgLinear_h_ 19 #include <os/OsSysLog.h> 22 #define TEST_PRINT_MIXING 23 #undef TEST_PRINT_MIXING 25 #define TEST_PRINT_MIXING_BINARY 26 #undef TEST_PRINT_MIXING_BINARY 28 #define TEST_PRINT_MIXING_CONTRIBUTORS 29 #undef TEST_PRINT_MIXING_CONTRIBUTORS 144 for (output=0; output<input; output++)
146 *pTmpInputsMapPtr = input;
150 *pTmpInputsMapPtr = -1;
154 *pTmpInputsMapPtr = input;
182 if (extendedInput >= 0)
186 OsSysLog::add(FAC_MP, PRI_DEBUG,
187 "ExtendedInputs::setGain(in=%d, out=%d, gain=%d) mRefCounter: %d",
198 assert(extendedInput >= 0);
226 int lastEmptySlot=-1;
261 assert(lastEmptySlot>=0);
269 return lastEmptySlot;
371 #ifdef TEST_PRINT_MIXING // [ 372 #ifdef TEST_PRINT_MIXING_BINARY // [ 373 # define PRINT_DATA_SET(printString, offset) \ 374 for (int i=0; i<mMixDataInfoStackStep; i++) \ 376 printString.appendFormat(" %d", mpMixDataInfoStack[mMixDataInfoStackStep*offset + i]); \ 378 # define PRINT_DATA_SET_TOP(printString) \ 379 for (int i=0; i<mMixDataInfoStackStep; i++) \ 381 printString.appendFormat(" %d", mpMixDataInfoStackTop[i]); \ 383 #else // TEST_PRINT_MIXING_BINARY ][ 384 # define PRINT_DATA_SET(printString, offset) \ 385 for (int i=0; i<mMixDataInfoStackStep; i++) \ 387 if (mpMixDataInfoStack[mMixDataInfoStackStep*offset + i] > 0) \ 389 printString.appendFormat(" %d", i); \ 392 # define PRINT_DATA_SET_TOP(printString) \ 393 for (int i=0; i<mMixDataInfoStackStep; i++) \ 395 if (mpMixDataInfoStackTop[i] > 0) \ 397 printString.appendFormat(" %d", i); \ 400 #endif //TEST_PRINT_MIXING_BINARY ] 401 # define PRINT_TOP_MIX_DATA() \ 403 UtlString printString; \ 404 printString.appendFormat("pushed data %2d: [", mMixDataInfoProcessedStackTop); \ 405 PRINT_DATA_SET_TOP(printString) \ 406 OsSysLog::add(FAC_MP, PRI_DEBUG, "%s]\n", printString.data()); \ 408 #else // TEST_PRINT_MIXING ][ 409 # define PRINT_TOP_MIX_DATA() 410 #endif // TEST_PRINT_MIXING ] 414 mMixActionsStackTop = 0;
419 assert(mMixActionsStackTop<mMixActionsStackLength);
424 mMixActionsStackTop++;
429 #ifdef TEST_PRINT_MIXING // [ 430 UtlString printString;
431 printString.appendFormat(
"COPY_TO_OUTPUT: %2d -> %2d [", src, dst);
432 PRINT_DATA_SET(printString, src);
433 printString.append(
"]\n");
434 OsSysLog::add(FAC_MP, PRI_DEBUG,
"MpBridgeAlgLinear::pushMixActionCopyToOutput\n%s", printString.data());
435 #endif // TEST_PRINT_MIXING ] 441 #ifdef TEST_PRINT_MIXING // [ 442 UtlString printString;
443 printString.appendFormat(
"COPY_FROM_INPUT: %2d <- %2d [", dst, src);
444 PRINT_DATA_SET(printString, dst);
445 printString.append(
"]\n");
446 OsSysLog::add(FAC_MP, PRI_DEBUG,
"MpBridgeAlgLinear::pushMixActionCopyFromInput\n%s", printString.data());
447 #endif // TEST_PRINT_MIXING ] 455 #ifdef TEST_PRINT_MIXING // [ 456 UtlString printString;
457 printString.appendFormat(
"DO_MIX: %2d + %2d -> %2d [", src1, src2, dst);
458 PRINT_DATA_SET(printString, src1);
459 printString.append(
"] + [");
460 PRINT_DATA_SET(printString, src2);
461 printString.append(
"] -> [");
462 PRINT_DATA_SET(printString, dst);
463 printString.append(
"]\n");
464 OsSysLog::add(FAC_MP, PRI_DEBUG,
"MpBridgeAlgLinear::pushMixActionMix\n%s", printString.data());
465 #endif // TEST_PRINT_MIXING ] 472 int action = mpMixDataInfoProcessedStack[dst];
473 #ifdef TEST_PRINT_MIXING // [ 474 OsSysLog::add(FAC_MP, PRI_DEBUG,
475 "MpBridgeAlgLinear::moveTopMixActionMix\npull: %2d + %2d -> %2d\n",
476 mpMixActionsStack[action].mSrc1,
477 mpMixActionsStack[action].mSrc2,
478 mpMixActionsStack[action].mDst);
479 #endif // TEST_PRINT_MIXING ] 482 mpMixActionsStack[action].mSrc1,
483 mpMixActionsStack[action].mSrc2,
484 mpMixActionsStack[action].mDst);
491 mMixDataInfoStackStep = step;
492 mMixDataInfoProcessedStackTop = 0;
501 int *pStartDataInfoStackPtr,
502 int startDataInfoStackPos,
503 int *&pFoundDataInfoStackPtr,
504 int &foundDataInfoStackPos)
508 int foundCommonDataBitCounter = 0;
509 int foundFirstDataDiffBitCounter = 0;
510 int foundSecondDataDiffBitCounter = 0;
512 pFoundDataInfoStackPtr = pStartDataInfoStackPtr;
513 foundDataInfoStackPos = startDataInfoStackPos;
514 for (pTmpPtr = pStartDataInfoStackPtr, tmpPos=startDataInfoStackPos;
520 if (mpMixDataInfoProcessedStack[tmpPos]<0 &&
521 (pDataInfoStackPtr != pTmpPtr))
523 int commonDataBitCounter = 0;
524 int firstDataDiffBitCounter = 0;
525 int secondDataDiffBitCounter = 0;
530 commonDataBitCounter += pDataInfoStackPtr[i] & pTmpPtr[i];
531 firstDataDiffBitCounter += pDataInfoStackPtr[i] & !pTmpPtr[i];
532 secondDataDiffBitCounter += !pDataInfoStackPtr[i] & pTmpPtr[i];
536 if (commonDataBitCounter > foundCommonDataBitCounter &&
537 firstDataDiffBitCounter < commonDataBitCounter &&
538 secondDataDiffBitCounter < commonDataBitCounter)
540 pFoundDataInfoStackPtr = pTmpPtr;
541 foundDataInfoStackPos = tmpPos;
542 foundCommonDataBitCounter = commonDataBitCounter;
543 foundFirstDataDiffBitCounter = firstDataDiffBitCounter;
544 foundSecondDataDiffBitCounter = secondDataDiffBitCounter;
547 if ((foundFirstDataDiffBitCounter < 2) &&
548 (foundSecondDataDiffBitCounter < 2))
556 return (foundCommonDataBitCounter > 0);
560 int &foundDataInfoStackPos)
565 for (pTmpPtr = mpMixDataInfoStack, tmpPos=0;
570 while (input<mMixDataInfoStackStep &&
571 pDataInfoStackPtr[input] == pTmpPtr[input])
575 if (input == mMixDataInfoStackStep)
577 foundDataInfoStackPos = tmpPos;
584 int &foundDataInfoStackPos,
585 int ignoreDataInfoStackLevel)
590 for (pTmpPtr = mpMixDataInfoStack, tmpPos=0;
594 if (mpMixDataInfoProcessedStack[tmpPos] < 0 ||
595 tmpPos < ignoreDataInfoStackLevel)
600 while (input<mMixDataInfoStackStep &&
601 pDataInfoStackPtr[input] == pTmpPtr[input])
605 if (input == mMixDataInfoStackStep)
608 foundDataInfoStackPos = tmpPos;
616 int &foundDataInfoStackPos)
621 for (pTmpPtr = mpMixDataInfoStack, tmpPos=0;
626 while (input<mMixDataInfoStackStep &&
627 pDataInfoStackPtr[input] == pTmpPtr[input])
631 if (input == mMixDataInfoStackStep)
633 foundDataInfoStackPos = tmpPos;
641 inline void moveDataUp(
int startDataInfoStackPos,
int dataInfoStackPos)
643 if (mpMixDataInfoProcessedStack[dataInfoStackPos] >= 0 &&
644 dataInfoStackPos >= startDataInfoStackPos)
662 #endif // _MpBridgeAlgLinear_h_ void initMixDataInfoStack(int step)
Definition: MpBridgeAlgLinear.h:488
void initMixActions()
Definition: MpBridgeAlgLinear.h:412
void pushMixActionMix(int src1, int src2, int dst)
Definition: MpBridgeAlgLinear.h:453
void setGainMatrixRow(int row, int numValues, const MpBridgeGain val[])
Set selected gain row to the given value.
Definition: MpBridgeAlgLinear.cpp:813
Definition: MpBridgeAlgLinear.h:343
Type mType
Definition: MpBridgeAlgLinear.h:348
int mSrc2
Definition: MpBridgeAlgLinear.h:350
int mMixDataInfoStackStep
Definition: MpBridgeAlgLinear.h:363
int mMixActionsStackTop
Definition: MpBridgeAlgLinear.h:355
bool searchData(int *pDataInfoStackPtr, int &foundDataInfoStackPos)
Definition: MpBridgeAlgLinear.h:615
int * mpMixDataInfoProcessedStack
Definition: MpBridgeAlgLinear.h:369
int mMixDataInfoStackLength
Definition: MpBridgeAlgLinear.h:364
void dumpOutputMix(UtlString &dumpString)
Dump the mix matrix to log.
Definition: MpBridgeAlgLinear.cpp:853
~MpBridgeAlgLinear()
Destructor.
Definition: MpBridgeAlgLinear.cpp:95
int mDst
Definition: MpBridgeAlgLinear.h:351
Definition: MpBridgeAlgLinear.h:342
ExtendedInputs mExtendedInputs
Storage for all extended inputs data.
Definition: MpBridgeAlgLinear.h:320
void pushMixAction(MixAction::Type type, int src1, int src2, int dst)
Definition: MpBridgeAlgLinear.h:417
float MpBridgeAccum
Definition: MpBridgeAlgBase.h:48
void pushMixActionCopyFromInput(int src, int dst)
Definition: MpBridgeAlgLinear.h:439
#define MP_BRIDGE_GAIN_PASSTHROUGH
Definition: MpBridgeAlgBase.h:37
MpBridgeAccum * mpMixDataStackTop
Definition: MpBridgeAlgLinear.h:359
void moveTopMixActionMix(int dst)
Definition: MpBridgeAlgLinear.h:470
void pushMixActionCopyToOutput(int src, int dst)
Definition: MpBridgeAlgLinear.h:427
int mMixActionsStackLength
Definition: MpBridgeAlgLinear.h:354
bool searchClosestUnprocessedData(int *pDataInfoStackPtr, int *pStartDataInfoStackPtr, int startDataInfoStackPos, int *&pFoundDataInfoStackPtr, int &foundDataInfoStackPos)
Definition: MpBridgeAlgLinear.h:500
UtlBoolean doMix(MpBufPtr inBufs[], int inBufsSize, MpBufPtr outBufs[], int outBufsSize, int samplesPerFrame)
Mix together inputs onto outputs according to mpGainMatrix matrix.
Definition: MpBridgeAlgLinear.cpp:108
MpBridgeAlgLinear(int inputs, int outputs, UtlBoolean mixSilence, int samplesPerFrame)
Constructor.
Definition: MpBridgeAlgLinear.cpp:44
void moveDataUp(int startDataInfoStackPos, int dataInfoStackPos)
Definition: MpBridgeAlgLinear.h:641
MpBridgeAccum * mpMixDataStack
Definition: MpBridgeAlgLinear.h:360
MpSpeechType
Type of audio data.
Definition: MpTypes.h:65
void searchExistingData(int *pDataInfoStackPtr, int &foundDataInfoStackPos)
Definition: MpBridgeAlgLinear.h:559
int * mpMixDataInfoStackTop
Definition: MpBridgeAlgLinear.h:365
MixAction * mpMixActionsStack
Definition: MpBridgeAlgLinear.h:356
int * mpActiveInputsList
inputs. Used in doMix() only.
Definition: MpBridgeAlgLinear.h:329
Type
Definition: MpBridgeAlgLinear.h:340
Brief description.
Definition: MpBridgeAlgLinear.h:44
MpBridgeAccum * mpMixDataAmplitude
Amplitude of data frames in mpMixDataStack.
Definition: MpBridgeAlgLinear.h:362
Definition: MpBridgeAlgLinear.h:344
int mMixDataInfoProcessedStackTop
Definition: MpBridgeAlgLinear.h:368
int mSrc1
Definition: MpBridgeAlgLinear.h:349
Definition: MpBridgeAlgLinear.h:338
int mMixDataStackLength
Definition: MpBridgeAlgLinear.h:358
void searchExistingUnprocessedData(int *pDataInfoStackPtr, int &foundDataInfoStackPos, int ignoreDataInfoStackLevel)
Definition: MpBridgeAlgLinear.h:583
void setGainMatrixColumn(int column, int numValues, const MpBridgeGain val[])
Set selected gain column to the given value.
Definition: MpBridgeAlgLinear.cpp:833
Smart pointer to MpBuf.
Definition: MpBuf.h:160
#define MP_BRIDGE_GAIN_MUTED
Definition: MpBridgeAlgBase.h:36
MpSpeechType * mpMixDataSpeechType
Speech type of data frames in mpMixDataStack.
Definition: MpBridgeAlgLinear.h:361
float MpBridgeGain
Definition: MpBridgeAlgBase.h:54
Base class for the Bridge mixing algorithms.
Definition: MpBridgeAlgBase.h:62
void setGainMatrixValue(int column, int row, MpBridgeGain val)
Set selected gain to the given value.
Definition: MpBridgeAlgLinear.cpp:808
Definition: MpBridgeAlgLinear.h:345
int * mpMixDataInfoStack
Definition: MpBridgeAlgLinear.h:366
void initMixDataStack()
Definition: MpBridgeAlgLinear.h:495
int mMixDataInfoProcessedStackLength
Definition: MpBridgeAlgLinear.h:367
int mMixDataStackStep
Definition: MpBridgeAlgLinear.h:357
int mActiveInputsListSize
Length of mpActiveInputsList array.
Definition: MpBridgeAlgLinear.h:328