Bläddra i källkod

cmDspFx.c,cmDspPgm.c: Finalized IntToSym.

master
kevin 4 år sedan
förälder
incheckning
b16673bbc0
2 ändrade filer med 17 tillägg och 19 borttagningar
  1. 4
    6
      src/dsp/cmDspFx.c
  2. 13
    13
      src/dsp/cmDspPgm.c

+ 4
- 6
src/dsp/cmDspFx.c Visa fil

@@ -5772,19 +5772,19 @@ cmDspRC_t _cmDspIntToSym_Recv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt
5772 5772
 { 
5773 5773
   cmDspRC_t    rc = kOkDspRC;
5774 5774
   cmDspIntToSym_t* p = (cmDspIntToSym_t*)inst;
5775
-  unsigned idx = cmInvalidIdx;
5776 5775
 
5777 5776
   // if an integer arrived at 'in'
5778 5777
   if( evt->dstVarId == kInItsId )
5779 5778
   {
5779
+    cmDspSetEvent(ctx,inst,evt);
5780
+
5780 5781
     unsigned i;
5781 5782
     int      intVal = cmDspInt(inst,kInItsId);
5782 5783
     
5783 5784
     for(i=0; i<p->symIdCnt; ++i)
5784 5785
       if( intVal == p->intArray[i] )
5785 5786
       {
5786
-        rc = _cmDspIntToSymSendOut( ctx, inst, idx );
5787
-        idx = i;
5787
+        rc = _cmDspIntToSymSendOut( ctx, inst, i );
5788 5788
         break;
5789 5789
       } 
5790 5790
   }
@@ -5802,9 +5802,7 @@ cmDspRC_t _cmDspIntToSym_Recv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt
5802 5802
       {
5803 5803
         cmDspSetEvent(ctx,inst,evt);
5804 5804
 
5805
-        int x = cmDspInt( inst, evt->dstVarId );
5806
-        printf("%i %i\n", x, p->symIdArray[evt->dstVarId - p->baseIntItsId] );
5807
-        p->intArray[ evt->dstVarId - p->baseIntItsId ] = x;
5805
+        p->intArray[ evt->dstVarId - p->baseIntItsId ] = cmDspInt( inst, evt->dstVarId );
5808 5806
       }
5809 5807
   }
5810 5808
 

+ 13
- 13
src/dsp/cmDspPgm.c Visa fil

@@ -2909,32 +2909,32 @@ cmDspRC_t _cmDspSysPgm_IntToSym( cmDspSysH_t h, void** userPtrPtr )
2909 2909
 {
2910 2910
   cmDspRC_t rc = kOkDspRC;
2911 2911
 
2912
-  inst_t* btn0  = button( "Btn0", 0.0 );
2913
-  inst_t* btn1  = button( "Btn1", 1.0 );
2914
-  inst_t* btn2  = button( "Btn2", 2.0 );  
2912
+  inst_t* sel0   = scalar( "Sel0", 0.0, 10.0, 1.0, 1.0 );
2913
+  inst_t* sel1   = scalar( "Sel1", 0.0, 10.0, 1.0, 1.0 );
2914
+  inst_t* sel2   = scalar( "Sel2", 0.0, 10.0, 1.0, 1.0 );
2915
+  inst_t* val    = scalar( "Val",  0.0, 10.0, 1.0, 1.0 );
2915 2916
 
2916
-  inst_t* pts   = inst( "IntToSym", NULL, 1, "one", 2, "two", 3, "three");
2917
+  inst_t* pts   = inst( "IntToSym", NULL, 0, "one", 0, "two", 0, "three");
2917 2918
 
2918
-  inst_t* pr0  = inst( "Printer", NULL,  "btn:" );
2919
+  inst_t* pr0  = inst( "Printer", NULL,  "val:" );
2919 2920
   inst_t* pr1  = inst( "Printer", NULL,  "sym:" );
2920 2921
   inst_t* pr2  = inst( "Printer", NULL,  "out:" );
2921 2922
 
2922 2923
   // check for allocation errors
2923 2924
   if((rc = cmDspSysLastRC(h)) != kOkDspRC )
2924 2925
     goto errLabel;
2925
-  
2926
-  event( btn0, out, pts, one );
2927
-  event( btn1, out, pts, two );
2928
-  event( btn2, out, pts, three );
2929 2926
 
2930
-  event( btn0, out, pr0, in );
2931
-  event( btn1, out, pr0, in );
2932
-  event( btn2, out, pr0, in );
2927
+  event( sel0, val, pts, one-int );
2928
+  event( sel1, val, pts, two-int );
2929
+  event( sel2, val, pts, three-int );
2930
+  
2931
+  event( val, val, pts, in );
2932
+  event( val, val, pr0, in );
2933 2933
 
2934 2934
   event( pts,  one,   pr1, in );
2935 2935
   event( pts,  two,   pr1, in );
2936 2936
   event( pts,  three, pr1, in );
2937
-
2937
+  
2938 2938
   event( pts, out, pr2, in );
2939 2939
   
2940 2940
  errLabel:

Laddar…
Avbryt
Spara