Browse Source

cmProc5.h/c : Many changes and additions to cmPhat. (still needs IFFT update to be fully implemented)

master
kevin 9 years ago
parent
commit
7fd6ee2cc0
2 changed files with 84 additions and 76 deletions
  1. 82
    75
      cmProc5.c
  2. 2
    1
      cmProc5.h

+ 82
- 75
cmProc5.c View File

343
 
343
 
344
 
344
 
345
 //=======================================================================================================================
345
 //=======================================================================================================================
346
-cmPhat_t*   cmPhatAlloc(  cmCtx* ctx, cmPhat_t* p, unsigned chN, unsigned hN, float alpha, unsigned mult, unsigned flags )
346
+cmPhat_t*   cmPhatAlloc(  cmCtx* ctx, cmPhat_t* ap, unsigned chN, unsigned hN, float alpha, unsigned mult, unsigned flags )
347
 {
347
 {
348
-  cmPhat_t* op = cmObjAlloc(cmPhat_t,ctx,p);
348
+  cmPhat_t* p = cmObjAlloc(cmPhat_t,ctx,ap);
349
 
349
 
350
   // The FFT buffer and the delay line is at least twice the size of the 
350
   // The FFT buffer and the delay line is at least twice the size of the 
351
   // id signal. This will guarantee that at least one complete id signal
351
   // id signal. This will guarantee that at least one complete id signal
352
   // is inside the buffer.  In practice it means that it is possible
352
   // is inside the buffer.  In practice it means that it is possible
353
   // that there will be two id's in the buffer therefore if there are
353
   // that there will be two id's in the buffer therefore if there are
354
   // two correlation spikes it is important that we take the second.
354
   // two correlation spikes it is important that we take the second.
355
-  p->fhN = cmNextPowerOfTwo(mult*hN);
355
+  unsigned fhN = cmNextPowerOfTwo(mult*hN);
356
 
356
 
357
   // allocate the FFT object
357
   // allocate the FFT object
358
-  cmFftAllocSR(ctx,&p->fft,NULL,p->fhN,kToPolarFftFl);
358
+  cmFftAllocSR(ctx,&p->fft,NULL,fhN,kToPolarFftFl);
359
+  cmIFftAllocRS(ctx,&p->ifft,fhN/2 + 1 );
359
   
360
   
360
   if( chN != 0 )  
361
   if( chN != 0 )  
361
-    if( cmPhatInit(op,chN,hN,alpha,mult,flags) != cmOkRC )
362
-      cmPhatFree(&op);
362
+    if( cmPhatInit(p,chN,hN,alpha,mult,flags) != cmOkRC )
363
+      cmPhatFree(&p);
363
 
364
 
364
-  return op;
365
+  return p;
365
 
366
 
366
 }
367
 }
367
 
368
 
384
   cmMemFree(p->mhM);
385
   cmMemFree(p->mhM);
385
   cmMemFree(p->wndV);
386
   cmMemFree(p->wndV);
386
   cmObjFreeStatic(cmFftFreeSR, cmFftSR, p->fft);
387
   cmObjFreeStatic(cmFftFreeSR, cmFftSR, p->fft);
388
+  cmObjFreeStatic(cmIFftFreeRS, cmIFftRS, p->ifft);
387
   cmVectArrayFree(&p->ftVa);
389
   cmVectArrayFree(&p->ftVa);
388
   cmObjFree(pp);
390
   cmObjFree(pp);
389
 
391
 
403
   if((cmFftInitSR(&p->fft, NULL, p->fhN, kToPolarFftFl)) != cmOkRC )
405
   if((cmFftInitSR(&p->fft, NULL, p->fhN, kToPolarFftFl)) != cmOkRC )
404
     return rc;
406
     return rc;
405
 
407
 
408
+  if((cmFftInitRS(&p->ifft, NULL, p->fft->binCnt )) != cmOkRC )
409
+    return rc;
410
+
406
   p->alpha = alpha;
411
   p->alpha = alpha;
407
   p->flags = flags;
412
   p->flags = flags;
408
 
413
 
463
   // Zero pad hV[hN] to p->fhN;
468
   // Zero pad hV[hN] to p->fhN;
464
   assert( hN <= p->fhN );
469
   assert( hN <= p->fhN );
465
   cmVOS_Zero(p->xV,p->fhN);
470
   cmVOS_Zero(p->xV,p->fhN);
466
-  cmVOS_Copy(p->xV,hV,hN);
471
+  cmVOS_Copy(p->xV,hN,hV);
467
 
472
 
468
   // Apply the window function to the id signal
473
   // Apply the window function to the id signal
469
-  if(atIsFlag(p->flags,kHannAtPhatFl) )
470
-    cmVOS_MultVVV(p->xV,hV,wndV,hN);
474
+  if(cmIsFlag(p->flags,kHannAtPhatFl) )
475
+    cmVOS_MultVVV(p->xV,hN,hV,wndV);
471
 
476
 
472
   // take FFT of id signal. The result is in fft->complexV and fft->magV,phsV
477
   // take FFT of id signal. The result is in fft->complexV and fft->magV,phsV
473
-  cmFftExecSR(p->fft, p->xV, p->fhN );
478
+  cmFftExecSR(&p->fft, p->xV, p->fhN );
474
 
479
 
475
   // Store the magnitude of the id signal
480
   // Store the magnitude of the id signal
476
   //atFftComplexAbs(p->mhM + (chIdx*p->binN), yV,     p->binN);
481
   //atFftComplexAbs(p->mhM + (chIdx*p->binN), yV,     p->binN);
477
-  cmVOR_Copy(p->mhM + (chIdx*p->binN), p->fft->magV, p->binN );
482
+  cmVOF_CopyR(p->mhM + (chIdx*p->binN), p->binN, p->fft.magV );
478
 
483
 
479
   // Scale the magnitude
484
   // Scale the magnitude
480
   cmVOS_MultVS(   p->mhM + (chIdx*p->binN), p->binN, p->alpha);
485
   cmVOS_MultVS(   p->mhM + (chIdx*p->binN), p->binN, p->alpha);
482
   // store the complex conjugate of the FFT result in yV[]
487
   // store the complex conjugate of the FFT result in yV[]
483
   //atFftComplexConj(yV,p->binN);
488
   //atFftComplexConj(yV,p->binN);
484
   for(i=0; i<p->binN; ++i)
489
   for(i=0; i<p->binN; ++i)
485
-    yV[i].i = -(p->fft->complexV[i].i);
490
+    yV[i] = cmCconjR(p->fft.complexV[i]);
486
 
491
 
487
   cmMemFree(wndV);
492
   cmMemFree(wndV);
488
 
493
 
489
-  return kOkAtRC;
494
+  return cmOkRC;
490
 }
495
 }
491
 
496
 
492
 cmSample_t* _cmPhatReadVector( cmCtx* ctx, cmPhat_t* p, const char* fn, unsigned* vnRef )
497
 cmSample_t* _cmPhatReadVector( cmCtx* ctx, cmPhat_t* p, const char* fn, unsigned* vnRef )
493
 {
498
 {
494
   cmVectArray_t* vap = NULL;
499
   cmVectArray_t* vap = NULL;
495
   cmSample_t*    v   = NULL;
500
   cmSample_t*    v   = NULL;
501
+  cmRC_t         rc  = cmOkRC;
496
   
502
   
497
   // instantiate a VectArray from a file
503
   // instantiate a VectArray from a file
498
-  if( cmVectArrayAllocFromFile(ctx, &vap, fn ) != kOkAtRC )
504
+  if( (vap = cmVectArrayAllocFromFile(ctx, fn )) == NULL )
499
   {
505
   {
500
-    atErrMsg(&p->obj.err,kFileReadFailAtRC,"Id component vector file read failed '%s'.",fn);
506
+    rc = cmCtxRtCondition(&p->obj,cmSubSysFailRC,"Id component vector file read failed '%s'.",fn);
501
     goto errLabel;
507
     goto errLabel;
502
   }
508
   }
503
 
509
 
505
   *vnRef = cmVectArrayEleCount(vap);
511
   *vnRef = cmVectArrayEleCount(vap);
506
 
512
 
507
   // allocate memory to hold the vector
513
   // allocate memory to hold the vector
508
-  v = cmMemAlloc(&p->obj.err,cmSample_t,*vnRef);
514
+  v = cmMemAlloc(cmSample_t,*vnRef);
509
 
515
 
510
   // copy the vector from the vector array object into v[]
516
   // copy the vector from the vector array object into v[]
511
-  if( cmVectArrayGetF(vap,v,vnRef) != kOkAtRC )
517
+  if((rc = cmVectArrayGetF(vap,v,vnRef)) != cmOkRC )
512
   {
518
   {
513
     cmMemFree(v);
519
     cmMemFree(v);
514
     v = NULL;
520
     v = NULL;
515
-    atErrMsg(&p->obj.err,kFileReadFailAtRC,"Id component vector copy out failed '%s'.",fn);
521
+    rc = cmCtxRtCondition(&p->obj,cmSubSysFailRC,"Id component vector copy out failed '%s'.",fn);
516
     goto errLabel;
522
     goto errLabel;
517
   }
523
   }
518
 
524
 
528
 
534
 
529
 cmRC_t   cmPhatExec(   cmPhat_t* p, const cmSample_t* xV, unsigned xN )
535
 cmRC_t   cmPhatExec(   cmPhat_t* p, const cmSample_t* xV, unsigned xN )
530
 {
536
 {
531
-  unsigned n = atMin(xN,p->fhN-p->di);
537
+  unsigned n = cmMin(xN,p->fhN-p->di);
532
 
538
 
533
   // update the delay line
539
   // update the delay line
534
-  cmVOS_Copy(p->dV+p->di,xV,n);
540
+  cmVOS_Copy(p->dV+p->di,n,xV);
535
 
541
 
536
   if( n < xN )
542
   if( n < xN )
537
-    cmVOS_Copy(p->dV,xV+n,xN-n);
543
+    cmVOS_Copy(p->dV,xN-n,xV+n);
538
 
544
 
539
-  p->di      = atModIncr(p->di,xN,p->fhN);
545
+  p->di      = cmModIncr(p->di,xN,p->fhN);
540
 
546
 
541
   // p->absIdx is the absolute sample index associated with di
547
   // p->absIdx is the absolute sample index associated with di
542
   p->absIdx += xN;  
548
   p->absIdx += xN;  
543
 
549
 
544
-  return kOkAtRC;
550
+  return cmOkRC;
545
 }
551
 }
546
 
552
 
547
 
553
 
556
   unsigned n1 = p->fhN - n0;
562
   unsigned n1 = p->fhN - n0;
557
 
563
 
558
   // Linearize the delay line into xV[]
564
   // Linearize the delay line into xV[]
559
-  cmVOS_Copy(p->xV,    p->dV + p->di, n0 );
560
-  cmVOS_Copy(p->xV+n0, p->dV,         n1 );
565
+  cmVOS_Copy(p->xV,    n0, p->dV + p->di );
566
+  cmVOS_Copy(p->xV+n0, n1, p->dV         );
561
 
567
 
562
-  if( atIsFlag(p->flags,kDebugAtPhatFl)) 
568
+  if( cmIsFlag(p->flags,kDebugAtPhatFl)) 
563
     cmVectArrayAppendS(p->ftVa, p->xV, p->fhN );
569
     cmVectArrayAppendS(p->ftVa, p->xV, p->fhN );
564
 
570
 
565
   // apply a window function to the incoming signal
571
   // apply a window function to the incoming signal
566
-  if( atIsFlag(p->flags,kHannAtPhatFl) )
572
+  if( cmIsFlag(p->flags,kHannAtPhatFl) )
567
     cmVOS_MultVV(p->xV,p->fhN,p->wndV);
573
     cmVOS_MultVV(p->xV,p->fhN,p->wndV);
568
   
574
   
569
   // Take the FFT of the delay line.
575
   // Take the FFT of the delay line.
570
   // p->t0V[p->binN] = fft(p->xV)
576
   // p->t0V[p->binN] = fft(p->xV)
571
   //atFftRealForward(p->fftH, p->xV, p->fhN, p->t0V, p->binN );
577
   //atFftRealForward(p->fftH, p->xV, p->fhN, p->t0V, p->binN );
572
-  cmFftExecSR(p->fft, p->xV, p->fhN );
578
+  cmFftExecSR(&p->fft, p->xV, p->fhN );
573
  
579
  
574
   // Calc. the Cross Power Spectrum (aka cross spectral density) of the
580
   // Calc. the Cross Power Spectrum (aka cross spectral density) of the
575
   // input signal with the id signal.
581
   // input signal with the id signal.
577
   // cross-correlation of the two signals.
583
   // cross-correlation of the two signals.
578
   // t0V[] *= p->fhM[:,chIdx]
584
   // t0V[] *= p->fhM[:,chIdx]
579
   //atFftComplexMult( p->t0V, p->fhM + (chIdx * p->fhN), p->binN );
585
   //atFftComplexMult( p->t0V, p->fhM + (chIdx * p->fhN), p->binN );
580
-  cmVOCR_MultVVV( p->t0V, p->fft->complexV, p->fhM + (chIdx * p->fhN), p->binN)
586
+  cmVOCR_MultVVV( p->t0V, p->fft.complexV, p->fhM + (chIdx * p->fhN), p->binN);
581
   
587
   
582
   // Calculate the magnitude of the CPS.
588
   // Calculate the magnitude of the CPS.
583
   // xV[] = | t0V[] |
589
   // xV[] = | t0V[] |
588
   //  id signal contains energy)
594
   //  id signal contains energy)
589
   // t0V[] *= p->mhM[:,chIdx]
595
   // t0V[] *= p->mhM[:,chIdx]
590
   if( p->alpha > 0 )
596
   if( p->alpha > 0 )
591
-    cmVOCR_MultR_VV( p->t0V, p->mhM + (chIdx*p->binN), p->binN);
597
+    cmVOCR_MultVFV( p->t0V, p->mhM + (chIdx*p->binN), p->binN);
592
 
598
 
593
   // Divide through by the magnitude of the CPS
599
   // Divide through by the magnitude of the CPS
594
   // This has the effect of whitening the spectram and thereby
600
   // This has the effect of whitening the spectram and thereby
596
   // while maximimizing the effect of the phase correlation.
602
   // while maximimizing the effect of the phase correlation.
597
   // 
603
   // 
598
   // t0V[] /= xV[]
604
   // t0V[] /= xV[]
599
-  cmVOCR_DivR_VV( p->t0V, p->xV, p->binN );
605
+  cmVOCR_DivVFV( p->t0V, p->xV, p->binN );
600
   
606
   
601
   // Take the IFFT of the weighted CPS to recover the cross correlation.
607
   // Take the IFFT of the weighted CPS to recover the cross correlation.
602
   // xV[] = IFFT(t0V[])
608
   // xV[] = IFFT(t0V[])
603
-
609
+  cmIFftExecRS( p->ifft,  );
604
 
610
 
605
   //// ***** atFftRealInverse( p->fftH, p->t0V, p->xV, p->fhN );
611
   //// ***** atFftRealInverse( p->fftH, p->t0V, p->xV, p->fhN );
606
   
612
   
610
   // normalize by the length of the correlation
616
   // normalize by the length of the correlation
611
   cmVOS_DivVS(p->xV,p->fhN,p->fhN);
617
   cmVOS_DivVS(p->xV,p->fhN,p->fhN);
612
 
618
 
613
-  if( atIsFlag(p->flags,kDebugAtPhatFl))
619
+  if( cmIsFlag(p->flags,kDebugAtPhatFl))
614
   {
620
   {
615
     cmVectArrayAppendS(p->ftVa, p->xV, p->fhN );
621
     cmVectArrayAppendS(p->ftVa, p->xV, p->fhN );
616
 
622
 
622
 
628
 
623
 cmRC_t cmPhatWrite( cmPhat_t* p, const char* dirStr )
629
 cmRC_t cmPhatWrite( cmPhat_t* p, const char* dirStr )
624
 {
630
 {
625
-  cmRC_t rc = kOkAtRC;
631
+  cmRC_t rc = cmOkRC;
626
   
632
   
627
-  if( atIsFlag(p->flags, kDebugAtPhatFl)) 
633
+  if( cmIsFlag(p->flags, kDebugAtPhatFl)) 
628
   {
634
   {
629
-    char* path = NULL;
635
+    const char* path = NULL;
630
 
636
 
631
     if( p->ftVa != NULL )
637
     if( p->ftVa != NULL )
632
-      if((rc = cmVectArrayWrite(p->ftVa, path = atMakePath(&p->obj.err,path,"cmPhatFT","va",dirStr,NULL) )) != kOkAtRC )
633
-        rc = atErrMsg(&p->obj.err,rc,"PHAT debug file write failed.");
638
+      if((rc = cmVectArrayWrite(p->ftVa, path = cmFsMakeFn(path,"cmPhatFT","va",dirStr,NULL) )) != cmOkRC )
639
+        rc = cmCtxRtCondition(&p->obj,cmSubSysFailRC,"PHAT debug file write failed.");
634
     
640
     
635
-    cmMemFree(path);
641
+    cmFsFreeFn(path);
636
   }
642
   }
637
   
643
   
638
   return rc;
644
   return rc;
639
 }
645
 }
640
 
646
 
641
-
647
+#ifdef NOTDEF
642
 cmRC_t cmPhatTest1( cmCtx* ctx, const char* dirStr )
648
 cmRC_t cmPhatTest1( cmCtx* ctx, const char* dirStr )
643
 {
649
 {
644
-  cmRC_t         rc             = kOkAtRC;
645
-  atSignalArg_t  sa;
646
-  atSignal_t*    s              = NULL;
650
+  cmRC_t         rc             = cmOkRC;
651
+  cmGoldSigArg_t sa;
652
+  cmGoldSig_t*   s              = NULL;
647
   cmPhat_t*      p              = NULL;
653
   cmPhat_t*      p              = NULL;
648
   char*          path           = NULL;
654
   char*          path           = NULL;
649
   unsigned       dspFrmCnt      = 256;
655
   unsigned       dspFrmCnt      = 256;
677
   sa.envMs           =    50.0;
683
   sa.envMs           =    50.0;
678
   
684
   
679
   // allocate the the id signals
685
   // allocate the the id signals
680
-  if( atSignalAlloc( ctx, &s, &sa ) != kOkAtRC )
681
-    return atErrMsg(&ctx->err, kTestFailAtRC, "Signal allocate failed.");
686
+  if( (s = cmGoldSigAlloc( ctx, NULL, &sa ) == NULL )
687
+    return cmErrMsg(&ctx->err, cmSubSysFailRC, "Signal allocate failed.");
682
 
688
 
683
   // set the post signal listen delay to half the signal length
689
   // set the post signal listen delay to half the signal length
684
   listenDelaySmp = s->sigN/2; 
690
   listenDelaySmp = s->sigN/2; 
685
 
691
 
686
   // allocate a PHAT detector
692
   // allocate a PHAT detector
687
-  if( cmPhatAlloc(ctx,&p,sa.chN,s->sigN, phatAlpha, phatMult, kDebugAtPhatFl ) != kOkAtRC )
693
+    if( (p = cmPhatAlloc(ctx,NULL,sa.chN,s->sigN, phatAlpha, phatMult, kDebugAtPhatFl ) == NULL )
688
   {
694
   {
689
-    rc = atErrMsg(&ctx->err, kTestFailAtRC, "PHAT allocate failed.");
695
+    rc = cmErrMsg(&ctx->err, cmSubSysFailRC, "PHAT allocate failed.");
690
     goto errLabel;
696
     goto errLabel;
691
   }
697
   }
692
 
698
 
693
   // register an id signal with the PHAT detector
699
   // register an id signal with the PHAT detector
694
-  if( cmPhatSetId(p, chIdx, s->ch[chIdx].mdV, s->sigN ) != kOkAtRC )
700
+  if( cmPhatSetId(p, chIdx, s->ch[chIdx].mdV, s->sigN ) != cmOkRC )
695
   {
701
   {
696
-    rc = atErrMsg(&ctx->err, kTestFailAtRC, "PHAT setId failed.");
702
+    rc = cmErrMsg(&ctx->err, cmSubSysFailRC, "PHAT setId failed.");
697
     goto errLabel;
703
     goto errLabel;
698
   }
704
   }
699
 
705
 
700
   // generate an input test signal containing bsiN id signals
706
   // generate an input test signal containing bsiN id signals
701
-  if( atSignalGen(s,chIdx,p->fhN,s->sigN,bsiV,bsiN,noiseGain,&yV,&yN) != kOkAtRC )
707
+  if( atSignalGen(s,chIdx,p->fhN,s->sigN,bsiV,bsiN,noiseGain,&yV,&yN) != cmOkRC )
702
   {
708
   {
703
-    rc = atErrMsg(&ctx->err,kTestFailAtRC,"Signal generation failed.");
709
+    rc = cmErrMsg(&ctx->err,cmSubSysFailRC,"Signal generation failed.");
704
     goto errLabel;
710
     goto errLabel;
705
   }
711
   }
706
 
712
 
714
   atVOU_Zero(dsiV,bsiN);
720
   atVOU_Zero(dsiV,bsiN);
715
 
721
 
716
   // allocate a vector array to record the PHAT input signals
722
   // allocate a vector array to record the PHAT input signals
717
-  if( cmVectArrayAlloc(ctx,&inVA,kSampleVaFl) != kOkAtRC )
723
+  if( cmVectArrayAlloc(ctx,&inVA,kSampleVaFl) != cmOkRC )
718
   {
724
   {
719
-    rc = atErrMsg(&ctx->err, kTestFailAtRC, "vectArray inVA alloc failed.");
725
+    rc = cmErrMsg(&ctx->err, cmSubSysFailRC, "vectArray inVA alloc failed.");
720
     goto errLabel;
726
     goto errLabel;
721
   }
727
   }
722
 
728
 
723
   // allocate a vector array to record the PHAT correlation output signals
729
   // allocate a vector array to record the PHAT correlation output signals
724
-  if( cmVectArrayAlloc(ctx,&outVA,kSampleVaFl) != kOkAtRC )
730
+  if( cmVectArrayAlloc(ctx,&outVA,kSampleVaFl) != cmOkRC )
725
   {
731
   {
726
-    rc = atErrMsg(&ctx->err, kTestFailAtRC, "vectArray outVA alloc failed.");
732
+    rc = cmErrMsg(&ctx->err, cmSubSysFailRC, "vectArray outVA alloc failed.");
727
     goto errLabel;
733
     goto errLabel;
728
   }
734
   }
729
 
735
 
730
   // allocate a vector array to record the PHAT status
736
   // allocate a vector array to record the PHAT status
731
-  if( cmVectArrayAlloc(ctx,&statusVA,kSampleVaFl) != kOkAtRC )
737
+  if( cmVectArrayAlloc(ctx,&statusVA,kSampleVaFl) != cmOkRC )
732
   {
738
   {
733
-    rc = atErrMsg(&ctx->err, kTestFailAtRC, "vectArray statusVA alloc failed.");
739
+    rc = cmErrMsg(&ctx->err, cmSubSysFailRC, "vectArray statusVA alloc failed.");
734
     goto errLabel;
740
     goto errLabel;
735
   }
741
   }
736
 
742
 
775
   }
781
   }
776
 
782
 
777
   // write inVA
783
   // write inVA
778
-  if( cmVectArrayWrite(inVA,path = atMakePath(&ctx->err,path,"phatIn","va",dirStr,NULL)) != kOkAtRC )
784
+  if( cmVectArrayWrite(inVA,path = atMakePath(&ctx->err,path,"phatIn","va",dirStr,NULL)) != cmOkRC )
779
   {
785
   {
780
-    rc = atErrMsg(&ctx->err, kTestFailAtRC, "vectArray outVA write failed.");
786
+    rc = cmErrMsg(&ctx->err, cmSubSysFailRC, "vectArray outVA write failed.");
781
     goto errLabel;
787
     goto errLabel;
782
   }
788
   }
783
 
789
 
784
   // write outVA
790
   // write outVA
785
-  if( cmVectArrayWrite(outVA,path = atMakePath(&ctx->err,path,"phatOut","va",dirStr,NULL)) != kOkAtRC )
791
+  if( cmVectArrayWrite(outVA,path = atMakePath(&ctx->err,path,"phatOut","va",dirStr,NULL)) != cmOkRC )
786
   {
792
   {
787
-    rc = atErrMsg(&ctx->err, kTestFailAtRC, "vectArray outVA write failed.");
793
+    rc = cmErrMsg(&ctx->err, cmSubSysFailRC, "vectArray outVA write failed.");
788
     goto errLabel;
794
     goto errLabel;
789
   }
795
   }
790
 
796
 
791
   // write statusVA
797
   // write statusVA
792
-  if( cmVectArrayWrite(statusVA,path = atMakePath(&ctx->err,path,"phatStatus","va",dirStr,NULL)) != kOkAtRC )
798
+  if( cmVectArrayWrite(statusVA,path = atMakePath(&ctx->err,path,"phatStatus","va",dirStr,NULL)) != cmOkRC )
793
   {
799
   {
794
-    rc = atErrMsg(&ctx->err, kTestFailAtRC, "vectArray statusVA write failed.");
800
+    rc = cmErrMsg(&ctx->err, cmSubSysFailRC, "vectArray statusVA write failed.");
795
     goto errLabel;
801
     goto errLabel;
796
   }
802
   }
797
 
803
 
799
   cmVectArrayFree(&outVA);
805
   cmVectArrayFree(&outVA);
800
   cmVectArrayFree(&inVA);
806
   cmVectArrayFree(&inVA);
801
 
807
 
802
-  if( cmPhatFree(&p) != kOkAtRC )
803
-    atErrMsg(&ctx->err,kTestFailAtRC,"PHAT free failed.");
808
+  if( cmPhatFree(&p) != cmOkRC )
809
+    cmErrMsg(&ctx->err,cmSubSysFailRC,"PHAT free failed.");
804
 
810
 
805
-  if( atSignalFree(&s) != kOkAtRC )
806
-    atErrMsg(&ctx->err,kTestFailAtRC,"Signal free failed.");
811
+  if( atSignalFree(&s) != cmOkRC )
812
+    cmErrMsg(&ctx->err,cmSubSysFailRC,"Signal free failed.");
807
 
813
 
808
   return rc;
814
   return rc;
809
 }
815
 }
810
 
816
 
811
 cmRC_t cmPhatTest2( cmCtx* ctx )
817
 cmRC_t cmPhatTest2( cmCtx* ctx )
812
 {
818
 {
813
-  cmRC_t    rc    = kOkAtRC;
819
+  cmRC_t    rc    = cmOkRC;
814
   cmPhat_t* p     = NULL;
820
   cmPhat_t* p     = NULL;
815
   unsigned  hN    = 16;
821
   unsigned  hN    = 16;
816
   float     alpha = 1.0;
822
   float     alpha = 1.0;
826
   unsigned    chN  = sizeof(xV)/sizeof(xV[0]);
832
   unsigned    chN  = sizeof(xV)/sizeof(xV[0]);
827
   unsigned    i;
833
   unsigned    i;
828
   
834
   
829
-  if(cmPhatAlloc(ctx,&p,chN,hN,alpha,mult,kNoFlagsAtPhatFl) != kOkAtRC )
835
+  if(cmPhatAlloc(ctx,&p,chN,hN,alpha,mult,kNoFlagsAtPhatFl) != cmOkRC )
830
   {
836
   {
831
-    rc = atErrMsg(&ctx->err,kTestFailAtRC,"cmPhatAlloc() failed.");
837
+    rc = cmErrMsg(&ctx->err,cmSubSysFailRC,"cmPhatAlloc() failed.");
832
     goto errLabel;
838
     goto errLabel;
833
   }
839
   }
834
 
840
 
835
   for(i=0; i<chN; ++i)
841
   for(i=0; i<chN; ++i)
836
-    if( cmPhatSetId(p,i,hV,hN) != kOkAtRC )
837
-      rc = atErrMsg(&ctx->err,kTestFailAtRC,"cmPhatSetId() failed.");
842
+    if( cmPhatSetId(p,i,hV,hN) != cmOkRC )
843
+      rc = cmErrMsg(&ctx->err,cmSubSysFailRC,"cmPhatSetId() failed.");
838
   
844
   
839
   
845
   
840
   for(i=0; i<chN; ++i)
846
   for(i=0; i<chN; ++i)
841
   {
847
   {
842
     cmPhatReset(p);
848
     cmPhatReset(p);
843
     
849
     
844
-    if( cmPhatExec(p,xV[i],hN) != kOkAtRC )
850
+    if( cmPhatExec(p,xV[i],hN) != cmOkRC )
845
     {
851
     {
846
-      rc = atErrMsg(&ctx->err,kTestFailAtRC,"cmPhatExec() failed.");
852
+      rc = cmErrMsg(&ctx->err,cmSubSysFailRC,"cmPhatExec() failed.");
847
       goto errLabel;
853
       goto errLabel;
848
     }
854
     }
849
 
855
 
859
     
865
     
860
   return rc;
866
   return rc;
861
 }
867
 }
868
+#endif

+ 2
- 1
cmProc5.h View File

125
   {
125
   {
126
     cmObj            obj;
126
     cmObj            obj;
127
     cmFftSR          fft;
127
     cmFftSR          fft;
128
+    cmIFftRS         ifft;
128
     
129
     
129
     float            alpha;
130
     float            alpha;
130
     unsigned         flags;
131
     unsigned         flags;
159
   // id signal contains energy.
160
   // id signal contains energy.
160
   // 'mult' * 'hN' is the correlation length (fhN)
161
   // 'mult' * 'hN' is the correlation length (fhN)
161
   // 'flags' See kDebugAtPhatFl and kWndAtPhatFl.
162
   // 'flags' See kDebugAtPhatFl and kWndAtPhatFl.
162
-  cmPhat_t* cmPhatAlloc(  cmCtx* ctx, cmPhat_t* pp, unsigned chN, unsigned hN, float alpha, unsigned mult, unsigned flags );
163
+  cmPhat_t* cmPhatAlloc(  cmCtx* ctx, cmPhat_t* p, unsigned chN, unsigned hN, float alpha, unsigned mult, unsigned flags );
163
   cmRC_t    cmPhatFree(   cmPhat_t** pp );
164
   cmRC_t    cmPhatFree(   cmPhat_t** pp );
164
 
165
 
165
   cmRC_t   cmPhatInit(  cmPhat_t* p, unsigned chN, unsigned hN, float alpha, unsigned mult, unsigned flags );  
166
   cmRC_t   cmPhatInit(  cmPhat_t* p, unsigned chN, unsigned hN, float alpha, unsigned mult, unsigned flags );  

Loading…
Cancel
Save