Pārlūkot izejas kodu

Updates to support sample-rate conversion in cmApBuf.h/cpp.

master
kevin.larke 4 gadus atpakaļ
vecāks
revīzija
0aee816083
14 mainītis faili ar 421 papildinājumiem un 177 dzēšanām
  1. 263
    59
      cmApBuf.c
  2. 3
    3
      cmApBuf.h
  3. 1
    0
      cmAudDsp.c
  4. 3
    2
      cmAudioAggDev.c
  5. 6
    3
      cmAudioPort.c
  6. 10
    2
      cmAudioSys.c
  7. 1
    0
      cmAudioSys.h
  8. 2
    2
      cmRtSys.c
  9. 1
    0
      cmRtSys.h
  10. 1
    1
      dsp/cmDspClass.c
  11. 95
    89
      dsp/cmDspKr.c
  12. 32
    15
      dsp/cmDspPgm.c
  13. 2
    0
      dsp/cmDspPgmKrTimeLineLite.c
  14. 1
    1
      dsp/cmDspSys.c

+ 263
- 59
cmApBuf.c Parādīt failu

@@ -40,10 +40,7 @@
40 40
   output ch:  client   audio  both
41 41
   
42 42
   The fn variable however is not thread-safe and therefore care must be taken as
43
-  to how it is read and updated.
44
-  
45
-  
46
-  
43
+  to how it is read and updated.  
47 44
  */
48 45
 
49 46
 enum { kInApIdx=0, kOutApIdx=1, kIoApCnt=2 };
@@ -61,21 +58,25 @@ typedef struct
61 58
   cmApSample_t* m;    // m[mn] meter sample sum  
62 59
   unsigned      mn;   // length of m[]
63 60
   unsigned      mi;   // next ele of m[] to rcv sum
61
+  cmApSample_t  s0;   // buffered sample used for srate conversion
64 62
 } cmApCh;
65 63
 
66 64
 typedef struct
67 65
 {
68
-  unsigned     chCnt;
69
-  cmApCh*      chArray;
66
+  unsigned     chCnt;      // Count of channels
67
+  cmApCh*      chArray;    // chArray[chCnt] channel record array
70 68
 
71
-  unsigned     n;     // length of b[] (multiple of dspFrameCnt)  bufCnt*framesPerCycle
72
-  double       srate; // device sample rate;
69
+  unsigned     n;          // Length of b[] (multiple of dspFrameCnt)  bufCnt*framesPerCycle
70
+  double       srate;      // Device sample rate;
71
+  int          srateMult;  // Internal sample rate multiplier (negative values for dividing). This srateMult*srate is the sample rate of
72
+                           // signals held in the chApCh[] input and output buffers. Sample rate conversion to/from this rate
73
+                           // occurs in cmApBufUpdate() as signals go from/to the audio device.
73 74
 
74
-  unsigned     faultCnt;
75
-  unsigned     framesPerCycle;
76
-  unsigned     dspFrameCnt;
77
-  cmTimeSpec_t timeStamp;    // base (starting) time stamp for this device
78
-  unsigned     ioFrameCnt;   // count of frames input or output for this device
75
+  unsigned     faultCnt;       // error count since start
76
+  unsigned     framesPerCycle; // expected count of frames per channel to/from the audio device on each call to cmApBufUpdate()
77
+  unsigned     dspFrameCnt;    // number of frames per channel in buffers returned by cmApBufGet().
78
+  cmTimeSpec_t timeStamp;      // base (starting) time stamp for this device
79
+  unsigned     ioFrameCnt;     // count of frames input or output for this device
79 80
 
80 81
 } cmApIO;
81 82
 
@@ -93,11 +94,145 @@ typedef struct
93 94
 
94 95
   cmApSample_t* zeroBuf;    // buffer of zeros 
95 96
   unsigned      zeroBufCnt; // max of all dspFrameCnt for all devices.
97
+
98
+
99
+  unsigned     abufIdx;
100
+  cmApSample_t abuf[ 16384 ];
96 101
 } cmApBuf;
97 102
 
98 103
 cmApBuf _cmApBuf;
99 104
 
100 105
 
106
+// Copy the source channel (srcChIdx) to the destination buffer and apply up-sampling.
107
+// 'src' is an interleaved buffer with 'srcN' samples per channel and 'srcChN' channels (total size in samples = srcN*srcChN)
108
+// 'dst' is a non-interleaved (single channel) circular buffer of length 'dstN' where 'dstIdx' is the index of the first dst slot to receive a sample..
109
+// Return the index into dst[] of the next location to receive an incoming sample.
110
+unsigned  _cmApCopyInUpSample( const cmApSample_t* src, unsigned srcN, unsigned srcChN, unsigned srcChIdx, cmApSample_t* dst, unsigned dstN, unsigned dstIdx, unsigned mult, double gain, cmApSample_t* s0_Ref )
111
+{
112
+  cmApSample_t s0 = *s0_Ref;
113
+  unsigned si,k,di=dstIdx;
114
+  
115
+  for(si=0; si<srcN; ++si)
116
+  {
117
+    cmApSample_t s1 = src[si*srcChN+srcChIdx];
118
+    
119
+    for(k=1; k<mult; ++k)
120
+    {
121
+      dst[di] = gain * (s0 + (s1 - s0) * k / mult );
122
+      di = (di+1) % dstN;
123
+    }
124
+
125
+    dst[di] = gain * s1;
126
+    di      = (di+1) % dstN;
127
+    s0     = s1;    
128
+  }
129
+  
130
+  *s0_Ref = s0;
131
+  
132
+  return di;
133
+}
134
+
135
+// Copy the source channel (srcChIdx) to the destination buffer and apply down-sampling.
136
+// 'src' is an interleaved linear buffer with 'srcN' samples per channel and 'srcChN' channels,
137
+// 'dst' is a non-interleaved circular buffer of length 'dstN' where 'dstIdx' is the index of the first dst slot to receive a sample..
138
+// Return the index into dst[] of the next location to receive an incoming sample.
139
+unsigned  _cmApCopyInDnSample( const cmApSample_t* src, unsigned srcN, unsigned srcChN, unsigned srcChIdx, cmApSample_t* dst, unsigned dstN, unsigned dstIdx, unsigned div, double gain )
140
+{
141
+  unsigned si,di=dstIdx;
142
+  
143
+  for(si=0; si<srcN; si+=div)
144
+  {
145
+    dst[di] = gain * src[si*srcChN+srcChIdx];
146
+    di      = (di+1) % dstN;
147
+  }
148
+  return di;
149
+}
150
+
151
+
152
+// Copy samples from an interleaved src buffer to a non-interleaved dst buffer with sample rate conversion
153
+unsigned  _cmApCopyInSamples( const cmApSample_t* src, unsigned srcN, unsigned srcChN, unsigned srcChIdx, cmApSample_t* dst, unsigned dstN, unsigned dstIdx, int srateMult, double gain, cmApSample_t* s0_Ref )
154
+{
155
+  if( srateMult < 1 )
156
+    return _cmApCopyInDnSample( src, srcN, srcChN, srcChIdx, dst, dstN, dstIdx, -srateMult, gain );
157
+
158
+  return _cmApCopyInUpSample( src, srcN, srcChN, srcChIdx, dst, dstN, dstIdx, srateMult, gain, s0_Ref );
159
+}
160
+
161
+void printBuf( const cmApSample_t* src, unsigned srcN, unsigned bi, unsigned n )
162
+{
163
+  unsigned i,j;
164
+  for(i=bi,j=0; j<n; ++i,++j)
165
+  {
166
+    i = i % srcN;
167
+    printf("(%i,%i,%f),\n",j,i,src[i]);
168
+  }
169
+  printf("-----\n");
170
+}
171
+
172
+
173
+// Copy 
174
+// 'src' is a non-interleaved circular buf of total length 'srcN', with the first sample coming at 'srcIdx'.
175
+// 'dst' is an interleaved buffer of length 'dstN' with 'dstChN' channels
176
+// Return the index of the next src sample.
177
+unsigned _cmApCopyOutUpSample( const cmApSample_t* src, unsigned srcN, unsigned srcIdx, cmApSample_t* dst, unsigned dstN, unsigned dstChN, unsigned dstChIdx, int mult, double gain, cmApSample_t* s0_Ref )
178
+{
179
+  unsigned di,si=srcIdx;
180
+  cmApSample_t s0 = *s0_Ref;
181
+  
182
+  for(di=0; di<dstN; ++di)
183
+  {
184
+    cmApSample_t s1 = src[si];
185
+    unsigned     k;
186
+    for(k=1; k<mult && di<dstN; ++di,++k)
187
+    {
188
+      dst[di*dstChN+dstChIdx] = gain * (s0 + (s1 - s0) * k / mult );      
189
+    }
190
+
191
+    if( di < dstN )
192
+    {
193
+      dst[di*dstChN+dstChIdx] = gain * s1;
194
+      ++di;
195
+    }
196
+
197
+    si = (si + 1) % srcN;
198
+    
199
+    s0 = s1;
200
+  }
201
+
202
+  *s0_Ref = s0;
203
+  return si;
204
+}
205
+
206
+// 'src' is a non-interleaved (single channel) circular buf of total length 'srcN', with the first sample coming at 'srcIdx'.
207
+// 'dst' is an interleaved buffer of length 'dstN' with 'dstChN' channels
208
+// Return the index of the next src sample.
209
+unsigned _cmApCopyOutDnSample( const cmApSample_t* src, unsigned srcN, unsigned srcIdx, cmApSample_t* dst, unsigned dstN, unsigned dstChN, unsigned dstChIdx, int div, double gain )
210
+{
211
+  unsigned di,si;
212
+
213
+  // The total count of output samples is determined by 'dstN'
214
+  // Downsampling is acheived by advancing the src index by 'div' samples.
215
+  
216
+  for(di=0,si=srcIdx; di<dstN; ++di)
217
+  {
218
+    dst[di*dstChN+dstChIdx] = gain * src[si];
219
+    si = (si + div) % srcN;
220
+  }
221
+  
222
+  return si;  
223
+}
224
+
225
+
226
+// Copy samples from a non-interleaved src buffer to an interleaved dst buffer with sample rate conversion
227
+unsigned   _cmApCopyOutSamples( const cmApSample_t* src, unsigned srcN, unsigned srcIdx, cmApSample_t* dst, unsigned dstN, unsigned dstChN, unsigned dstChIdx, int srateMult, double gain, cmApSample_t* s0_Ref )
228
+{
229
+  if( srateMult > 0  )
230
+    return _cmApCopyOutDnSample(src, srcN, srcIdx, dst, dstN, dstChN, dstChIdx, srateMult, gain );
231
+
232
+  return _cmApCopyOutUpSample( src, srcN, srcIdx, dst, dstN, dstChN, dstChIdx, -srateMult, gain, s0_Ref );
233
+}
234
+
235
+
101 236
 cmApSample_t _cmApMeterValue( const cmApCh* cp )
102 237
 {
103 238
   double sum = 0;
@@ -108,7 +243,7 @@ cmApSample_t _cmApMeterValue( const cmApCh* cp )
108 243
   return cp->mn==0 ? 0 : (cmApSample_t)sqrt(sum/cp->mn);
109 244
 }
110 245
 
111
-void _cmApSine( cmApCh* cp, cmApSample_t* b0, unsigned n0, cmApSample_t* b1, unsigned n1, unsigned stride, float srate )
246
+void _cmApSine0( cmApCh* cp, cmApSample_t* b0, unsigned n0, cmApSample_t* b1, unsigned n1, unsigned stride, float srate )
112 247
 {
113 248
   unsigned i;
114 249
 
@@ -119,6 +254,23 @@ void _cmApSine( cmApCh* cp, cmApSample_t* b0, unsigned n0, cmApSample_t* b1, uns
119 254
     b1[i*stride] = (float)(cp->gain * sin( 2.0 * M_PI * cp->hz * cp->phs / srate ));
120 255
 }
121 256
 
257
+// Synthesize a sine signal of length sigN*srateMult starting at dst[dstidx]
258
+// Assume dst[dstN] is a circular buffer
259
+unsigned  _cmApSine( cmApCh* cp, cmApSample_t* dst, unsigned dstN, unsigned dstIdx,  unsigned dstChCnt, unsigned sigN, unsigned srateMult, float srate, double gain )
260
+{
261
+  unsigned i,di;
262
+  
263
+  sigN = srateMult < 0 ? sigN/abs(srateMult) : sigN * srateMult;
264
+  for(i=0, di=dstIdx; i<sigN; ++i,++cp->phs)
265
+  {
266
+    dst[di] = (cmApSample_t)(gain * sin( 2.0 * M_PI * cp->hz * cp->phs / srate ));
267
+    di = (di+dstChCnt) % dstN;
268
+  }
269
+
270
+  return sigN;
271
+}
272
+
273
+
122 274
 cmApSample_t _cmApMeter( const cmApSample_t* b, unsigned bn, unsigned stride )
123 275
 {
124 276
   const cmApSample_t* ep  = b + bn;
@@ -151,6 +303,7 @@ void _cmApChInitialize( cmApCh* chPtr, unsigned n, unsigned mn )
151 303
   chPtr->mn   = mn;
152 304
   chPtr->m    = cmMemAllocZ(cmApSample_t,mn);
153 305
   chPtr->mi   = 0;
306
+
154 307
 }
155 308
 
156 309
 void _cmApIoFinalize( cmApIO* ioPtr )
@@ -164,27 +317,31 @@ void _cmApIoFinalize( cmApIO* ioPtr )
164 317
   ioPtr->n     = 0;
165 318
 }
166 319
 
167
-void _cmApIoInitialize( cmApIO* ioPtr, double srate, unsigned framesPerCycle, unsigned chCnt, unsigned n, unsigned meterBufN, unsigned dspFrameCnt )
320
+void _cmApIoInitialize( cmApIO* ioPtr, double srate, unsigned framesPerCycle, unsigned chCnt, unsigned n, unsigned meterBufN, unsigned dspFrameCnt, int srateMult )
168 321
 {
169 322
   unsigned i;
170 323
 
324
+  if( srateMult == 0 )
325
+    srateMult = 1;
326
+
171 327
   _cmApIoFinalize(ioPtr);
172 328
 
173 329
   n += (n % dspFrameCnt); // force buffer size to be a multiple of dspFrameCnt
174 330
   
175 331
   ioPtr->chArray           = chCnt==0 ? NULL : cmMemAllocZ( cmApCh, chCnt );
176 332
   ioPtr->chCnt             = chCnt;
177
-  ioPtr->n                 = n;
333
+  ioPtr->n                 = srateMult<0 ?  n : n*srateMult;
178 334
   ioPtr->faultCnt          = 0;
179 335
   ioPtr->framesPerCycle    = framesPerCycle;
180 336
   ioPtr->srate             = srate;
337
+  ioPtr->srateMult         = srateMult;
181 338
   ioPtr->dspFrameCnt       = dspFrameCnt;
182 339
   ioPtr->timeStamp.tv_sec  = 0;
183 340
   ioPtr->timeStamp.tv_nsec = 0;
184 341
   ioPtr->ioFrameCnt        = 0;
185 342
 
186 343
   for(i=0; i<chCnt; ++i )
187
-    _cmApChInitialize( ioPtr->chArray + i, n, meterBufN );
344
+    _cmApChInitialize( ioPtr->chArray + i, ioPtr->n, meterBufN );
188 345
 
189 346
 }
190 347
 
@@ -195,7 +352,7 @@ void _cmApDevFinalize( cmApDev* dp )
195 352
     _cmApIoFinalize( dp->ioArray+i);
196 353
 }
197 354
 
198
-void _cmApDevInitialize( cmApDev* dp, double srate, unsigned iFpC, unsigned iChCnt, unsigned iBufN, unsigned oFpC, unsigned oChCnt, unsigned oBufN, unsigned meterBufN, unsigned dspFrameCnt )
355
+void _cmApDevInitialize( cmApDev* dp, double srate, unsigned iFpC, unsigned iChCnt, unsigned iBufN, unsigned oFpC, unsigned oChCnt, unsigned oBufN, unsigned meterBufN, unsigned dspFrameCnt, int srateMult )
199 356
 {
200 357
   unsigned i;
201 358
 
@@ -203,10 +360,10 @@ void _cmApDevInitialize( cmApDev* dp, double srate, unsigned iFpC, unsigned iChC
203 360
 
204 361
   for(i=0; i<kIoApCnt; ++i)
205 362
   {
206
-    unsigned chCnt = i==kInApIdx ? iChCnt : oChCnt;
207
-    unsigned bufN  = i==kInApIdx ? iBufN  : oBufN;
208
-    unsigned fpc   = i==kInApIdx ? iFpC   : oFpC;
209
-    _cmApIoInitialize( dp->ioArray+i, srate, fpc, chCnt, bufN, meterBufN, dspFrameCnt );
363
+    unsigned chCnt = i==kInApIdx ? iChCnt     : oChCnt;
364
+    unsigned bufN  = i==kInApIdx ? iBufN      : oBufN;
365
+    unsigned fpc   = i==kInApIdx ? iFpC       : oFpC;
366
+    _cmApIoInitialize( dp->ioArray+i, srate, fpc, chCnt, bufN, meterBufN, dspFrameCnt, srateMult );
210 367
 
211 368
   }
212 369
       
@@ -222,6 +379,7 @@ cmAbRC_t cmApBufInitialize( unsigned devCnt, unsigned meterMs )
222 379
   _cmApBuf.devArray        = cmMemAllocZ( cmApDev, devCnt );
223 380
   _cmApBuf.devCnt          = devCnt;
224 381
   cmApBufSetMeterMs(meterMs);
382
+
225 383
   return kOkAbRC;
226 384
 }
227 385
 
@@ -236,6 +394,22 @@ cmAbRC_t cmApBufFinalize()
236 394
   
237 395
   _cmApBuf.devCnt          = 0;
238 396
 
397
+  FILE* fp;
398
+  if(_cmApBuf.abufIdx>0 )
399
+  {
400
+    if((fp = fopen("/home/kevin/temp/temp.csv","wt")) != NULL )
401
+    {
402
+      int i;
403
+      for(i=0; i<_cmApBuf.abufIdx; ++i)
404
+      {
405
+        fprintf(fp,"%f,\n",_cmApBuf.abuf[i]);
406
+      }
407
+      fclose(fp);
408
+    }
409
+  }
410
+  
411
+
412
+  
239 413
   return kOkAbRC;
240 414
 }
241 415
 
@@ -247,14 +421,15 @@ cmAbRC_t cmApBufSetup(
247 421
   unsigned inChCnt, 
248 422
   unsigned inFramesPerCycle,
249 423
   unsigned outChCnt, 
250
-  unsigned outFramesPerCycle)
424
+  unsigned outFramesPerCycle,
425
+  int      srateMult)
251 426
 {
252 427
   cmApDev* devPtr    = _cmApBuf.devArray + devIdx;
253 428
   unsigned iBufN     = bufCnt * inFramesPerCycle;
254 429
   unsigned oBufN     = bufCnt * outFramesPerCycle;
255 430
   unsigned meterBufN = cmMax(1,floor(srate * _cmApBuf.meterMs / (1000.0 * outFramesPerCycle)));
256 431
 
257
-  _cmApDevInitialize( devPtr, srate, inFramesPerCycle, inChCnt, iBufN, outFramesPerCycle, outChCnt, oBufN, meterBufN, dspFrameCnt );
432
+  _cmApDevInitialize( devPtr, srate, inFramesPerCycle, inChCnt, iBufN, outFramesPerCycle, outChCnt, oBufN, meterBufN, dspFrameCnt, srateMult );
258 433
 
259 434
   if( inFramesPerCycle > _cmApBuf.zeroBufCnt || outFramesPerCycle > _cmApBuf.zeroBufCnt )
260 435
   {
@@ -325,8 +500,6 @@ cmAbRC_t cmApBufUpdate(
325 500
       for(j=0; j<pp->chCnt; ++j)
326 501
       {
327 502
         cmApCh*  cp = ip->chArray + pp->begChIdx +j; // dest ch
328
-        unsigned n0 = ip->n - cp->ii;                // first dest segment
329
-        unsigned n1 = 0;                             // second dest segment
330 503
 
331 504
         assert(pp->begChIdx + j < ip->chCnt );
332 505
 
@@ -339,16 +512,12 @@ cmAbRC_t cmApBufUpdate(
339 512
 
340 513
         // if the incoming samples would go off the end of the buffer then 
341 514
         // copy in the samples in two segments (one at the end and another at begin of dest channel)
342
-        if( n0 < pp->audioFramesCnt )
343
-          n1 = pp->audioFramesCnt-n0;
344
-        else
345
-          n0 = pp->audioFramesCnt;
346
-
515
+        
347 516
         bool                enaFl = cmIsFlag(cp->fl,kChApFl) && cmIsFlag(cp->fl,kMuteApFl)==false;
348 517
         const cmApSample_t* sp    = enaFl ? ((cmApSample_t*)pp->audioBytesPtr) + j : _cmApBuf.zeroBuf;
349
-        unsigned            ssn   = enaFl ? pp->chCnt : 1;  // stride (packet samples are interleaved)
350
-        cmApSample_t*       dp    = cp->b + cp->ii;
351
-        const cmApSample_t* ep    = dp    + n0;
518
+        //unsigned            ssn   = enaFl ? pp->chCnt : 1;  // stride (packet samples are interleaved)
519
+        //cmApSample_t*       dp    = cp->b + cp->ii;
520
+        //const cmApSample_t* ep    = dp    + n0;
352 521
 
353 522
 
354 523
         // update the meter
@@ -358,33 +527,41 @@ cmAbRC_t cmApBufUpdate(
358 527
           cp->mi = (cp->mi + 1) % cp->mn;
359 528
         }
360 529
 
530
+        unsigned incrSmpN = 0;
531
+
361 532
         // if the test tone is enabled on this input channel
362 533
         if( enaFl && cmIsFlag(cp->fl,kToneApFl) )
363 534
         {
364
-          _cmApSine(cp, dp, n0, cp->b, n1, 1, ip->srate );
535
+          //_cmApSine(cp, dp, n0, cp->b, n1, 1, ip->srate );
536
+          incrSmpN =  _cmApSine( cp, cp->b, ip->n, cp->ii,  1, pp->audioFramesCnt, ip->srateMult, ip->srate, cp->gain );
537
+
538
+          
365 539
         }
366 540
         else // otherwise copy samples from the packet to the buffer
367 541
         {
368
-          // copy the first segment
369
-          for(; dp < ep; sp += ssn )
370
-            *dp++ = cp->gain * *sp;
371 542
 
372
-          // if there is a second segment
373
-          if( n1 > 0 )
374
-          {
375
-            // copy the second segment
376
-            dp = cp->b;
377
-            ep = dp + n1;
378
-            for(; dp<ep; sp += ssn )
379
-              *dp++ = cp->gain * *sp;
380
-          }
543
+          unsigned pi = cp->ii;
544
+          
545
+          cp->ii =  _cmApCopyInSamples( (cmApSample_t*)pp->audioBytesPtr, pp->audioFramesCnt, pp->chCnt, j, cp->b, ip->n, cp->ii, ip->srateMult, cp->gain, &cp->s0 );
546
+
547
+          if( false )
548
+            if( j == 2 && _cmApBuf.abufIdx < 16384 )
549
+            {
550
+              int ii;
551
+              for(ii=pi; ii!=cp->ii && _cmApBuf.abufIdx<16384; _cmApBuf.abufIdx++)
552
+              {
553
+                _cmApBuf.abuf[ _cmApBuf.abufIdx ] = cp->b[ii];
554
+                ii = (ii + 1) % ip->n;
555
+              }
556
+
557
+            }
558
+
559
+
560
+          incrSmpN = cp->ii > pi ? cp->ii-pi : (ip->n-pi) + cp->ii;
561
+                    
381 562
         }
382 563
 
383
-        
384
-        // advance the input channel buffer
385
-        cp->ii  = n1>0 ? n1 : cp->ii + n0;
386
-        //cp->fn += pp->audioFramesCnt;
387
-        cmThUIntIncr(&cp->fn,pp->audioFramesCnt);
564
+        cmThUIntIncr(&cp->fn,incrSmpN);
388 565
       }
389 566
     }
390 567
   }
@@ -423,7 +600,6 @@ cmAbRC_t cmApBufUpdate(
423 600
 
424 601
           // ... otherwise decrease the count of returned samples
425 602
           pp->audioFramesCnt = fn;
426
-
427 603
         }
428 604
 
429 605
         // if the outgong segments would go off the end of the buffer then 
@@ -433,19 +609,42 @@ cmAbRC_t cmApBufUpdate(
433 609
         else
434 610
           n0 = pp->audioFramesCnt;
435 611
 
436
-        cmApSample_t* dp    = ((cmApSample_t*)pp->audioBytesPtr) + j;
612
+        cmApSample_t* bpp   = ((cmApSample_t*)pp->audioBytesPtr) + j;
613
+        cmApSample_t* dp    = bpp;
437 614
         bool          enaFl = cmIsFlag(cp->fl,kChApFl) && cmIsFlag(cp->fl,kMuteApFl)==false;
438 615
 
616
+        unsigned decrSmpN = 0;
617
+        
439 618
         // if the tone is enabled on this channel
440 619
         if( enaFl && cmIsFlag(cp->fl,kToneApFl) )
441 620
         {
442
-          _cmApSine(cp, dp, n0, dp + n0*pp->chCnt, n1, pp->chCnt, op->srate );
621
+          //_cmApSine(cp, dp, n0, dp + n0*pp->chCnt, n1, pp->chCnt, op->srate );
622
+          decrSmpN =  _cmApSine( cp, (cmApSample_t*)pp->audioBytesPtr, pp->audioFramesCnt, 0,  pp->chCnt, pp->audioFramesCnt, op->srateMult, op->srate, cp->gain );
623
+
443 624
         }
444 625
         else                    // otherwise copy samples from the output buffer to the packet
445 626
         {
446 627
           const cmApSample_t* sp = enaFl ? cp->b + cp->oi : _cmApBuf.zeroBuf;
447 628
           const cmApSample_t* ep = sp + n0;
448 629
 
630
+          unsigned pi = cp->oi;
631
+          cp->oi = _cmApCopyOutSamples( enaFl ? cp->b : _cmApBuf.zeroBuf, op->n, cp->oi, (cmApSample_t*)pp->audioBytesPtr, pp->audioFramesCnt, pp->chCnt, j, op->srateMult, cp->gain, &cp->s0 );
632
+
633
+          decrSmpN = cp->oi>pi ? cp->oi-pi : (op->n-pi) + cp->oi;
634
+
635
+          if( true )
636
+            if( j == 2 && _cmApBuf.abufIdx < 16384 )
637
+            {
638
+              int ii;
639
+              for(ii=pi; ii!=cp->oi && _cmApBuf.abufIdx<16384; _cmApBuf.abufIdx++)
640
+              {
641
+                _cmApBuf.abuf[ _cmApBuf.abufIdx ] = cp->b[ii];
642
+                ii = (ii + 1) % op->n;
643
+              }
644
+
645
+            }
646
+          
647
+          /*
449 648
           // copy the first segment
450 649
           for(; sp < ep; dp += pp->chCnt )
451 650
             *dp = cp->gain * *sp++;
@@ -460,6 +659,7 @@ cmAbRC_t cmApBufUpdate(
460 659
               *dp = cp->gain * *sp++;
461 660
 
462 661
           }
662
+          */
463 663
         }
464 664
 
465 665
         // update the meter
@@ -470,9 +670,13 @@ cmAbRC_t cmApBufUpdate(
470 670
         }
471 671
 
472 672
         // advance the output channel buffer
673
+        /*
473 674
         cp->oi  = n1>0 ? n1 : cp->oi + n0;
474
-        //cp->fn -= pp->audioFramesCnt;
475 675
         cmThUIntDecr(&cp->fn,pp->audioFramesCnt);
676
+        */
677
+        
678
+        //cp->fn -= pp->audioFramesCnt;
679
+        cmThUIntDecr(&cp->fn,decrSmpN);
476 680
       }
477 681
     }    
478 682
   }
@@ -657,7 +861,6 @@ void cmApBufGet( unsigned devIdx, unsigned flags, cmApSample_t* bufArray[], unsi
657 861
   unsigned      idx   = flags & kInApFl ? kInApIdx : kOutApIdx;
658 862
   const cmApIO* ioPtr = _cmApBuf.devArray[devIdx].ioArray + idx;
659 863
   unsigned      n     = bufChCnt < ioPtr->chCnt ? bufChCnt : ioPtr->chCnt;
660
-  //unsigned      offs  = flags & kInApFl ? ioPtr->oi : ioPtr->ii; 
661 864
   cmApCh*       cp    = ioPtr->chArray;
662 865
 
663 866
   for(i=0; i<n; ++i,++cp)
@@ -881,7 +1084,8 @@ void cmApBufTest( cmRpt_t* rpt )
881 1084
   unsigned sigN           = cycleCnt*framesPerCycle*inChCnt;
882 1085
   double   srate          = 44100.0;
883 1086
   unsigned meterMs        = 50;
884
-
1087
+  int      srateMult      = 1;
1088
+  
885 1089
   unsigned          bufChCnt= inChCnt;
886 1090
   cmApSample_t*     inBufArray[ bufChCnt ];
887 1091
   cmApSample_t*     outBufArray[ bufChCnt ];
@@ -910,7 +1114,7 @@ void cmApBufTest( cmRpt_t* rpt )
910 1114
   cmApBufInitialize(devCnt,meterMs);
911 1115
 
912 1116
   // setup the buffer with the specific parameters to by used by the host audio ports
913
-  cmApBufSetup(devIdx,srate,dspFrameCnt,cycleCnt,inChCnt,framesPerCycle,outChCnt,framesPerCycle);
1117
+  cmApBufSetup(devIdx,srate,dspFrameCnt,cycleCnt,inChCnt,framesPerCycle,outChCnt,framesPerCycle, srateMult);
914 1118
 
915 1119
   // simulate cylcing through sigN buffer transactions
916 1120
   for(i=0; i<sigN; i+=framesPerCycle*inChCnt)

+ 3
- 3
cmApBuf.h Parādīt failu

@@ -56,13 +56,13 @@ extern "C" {
56 56
   cmAbRC_t cmApBufSetup( 
57 57
     unsigned devIdx,              //< device to setup
58 58
     double   srate,               //< device sample rate (only required for synthesizing the correct test-tone frequency)
59
-    unsigned dspFrameCnt,         // dspFrameCnt - count of samples in channel buffers returned via cmApBufGet() 
59
+    unsigned dspFrameCnt,         //< dspFrameCnt - count of samples in channel buffers returned via cmApBufGet() 
60 60
     unsigned cycleCnt,            //< number of audio port cycles to store 
61 61
     unsigned inChCnt,             //< input channel count on this device
62 62
     unsigned inFramesPerCycle,    //< maximum number of incoming sample frames on an audio port cycle
63 63
     unsigned outChCnt,            //< output channel count on this device
64
-    unsigned outFramesPerCycle    //< maximum number of outgoing sample frames in an audio port cycle
65
-                         );
64
+    unsigned outFramesPerCycle,   //< maximum number of outgoing sample frames in an audio port cycle
65
+    int      srateMult );         //< sample rate cvt (positive for upsample, negative for downsample)
66 66
 
67 67
   // Prime the buffer with 'audioCycleCnt' * outFramesPerCycle samples ready to be played
68 68
   cmAbRC_t cmApBufPrimeOutput( unsigned devIdx, unsigned audioCycleCnt );

+ 1
- 0
cmAudDsp.c Parādīt failu

@@ -364,6 +364,7 @@ cmAdRC_t _cmAdParseSysJsonTree( cmAd_t* p )
364 364
           "dspFramesPerCycle",  kIntTId,  &asap->dspFramesPerCycle,
365 365
           "audioBufCnt",        kIntTId,  &asap->audioBufCnt,
366 366
           "srate",              kRealTId, &asap->srate,
367
+            "srateMult",        kIntTId,  &asap->srateMult,
367 368
             NULL )) != kOkJsRC )
368 369
       {
369 370
         rc = _cmAdParseMemberErr(p, jsRC, errLabelPtr, cmStringNullGuard(p->asCfgArray[i].label));

+ 3
- 2
cmAudioAggDev.c Parādīt failu

@@ -738,6 +738,7 @@ int cmApAggTest( bool runFl, cmCtx_t* ctx, int argc, const char* argv[] )
738 738
   cmApAggPortTestRecd r;
739 739
   unsigned         i;
740 740
   cmRpt_t* rpt = &ctx->rpt;
741
+  int  srateMult = 1;
741 742
 
742 743
   if( _cmApAggGetOpt(argc,argv,"-h",0,true) )
743 744
     _cmApAggPrintUsage(rpt);
@@ -839,11 +840,11 @@ int cmApAggTest( bool runFl, cmCtx_t* ctx, int argc, const char* argv[] )
839 840
     cmApBufInitialize( cmApDeviceCount(), r.meterMs );
840 841
 
841 842
     // setup the buffer for the output device
842
-    cmApBufSetup( r.outDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.outDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.outDevIdx,false), r.framesPerCycle );
843
+    cmApBufSetup( r.outDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.outDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.outDevIdx,false), r.framesPerCycle, srateMult );
843 844
 
844 845
     // setup the buffer for the input device
845 846
     if( r.inDevIdx != r.outDevIdx )
846
-      cmApBufSetup( r.inDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.inDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.inDevIdx,false), r.framesPerCycle ); 
847
+      cmApBufSetup( r.inDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.inDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.inDevIdx,false), r.framesPerCycle, srateMult ); 
847 848
 
848 849
     // setup an input device
849 850
     if( cmApDeviceSetup(r.inDevIdx,r.srate,r.framesPerCycle,_cmApAggPortCb2,&r) != kOkApRC )

+ 6
- 3
cmAudioPort.c Parādīt failu

@@ -663,7 +663,8 @@ int cmApPortTest( bool runFl, cmRpt_t* rpt, int argc, const char* argv[] )
663 663
 {
664 664
   cmApPortTestRecd r;
665 665
   unsigned         i;
666
-  int              result = 0;
666
+  int              result    = 0;
667
+  int              srateMult = 1;
667 668
 
668 669
   if( _cmApGetOpt(argc,argv,"-h",0,true) )
669 670
     _cmApPrintUsage(rpt);
@@ -698,6 +699,8 @@ int cmApPortTest( bool runFl, cmRpt_t* rpt, int argc, const char* argv[] )
698 699
   r.ilog       = ilog;
699 700
   r.cbCnt      = 0;
700 701
 
702
+
703
+
701 704
   cmRptPrintf(rpt,"%s in:%i out:%i chidx:%i chs:%i bufs=%i frm=%i rate=%f\n",runFl?"exec":"rpt",r.inDevIdx,r.outDevIdx,r.chIdx,r.chCnt,r.bufCnt,r.framesPerCycle,r.srate);
702 705
 
703 706
   if( cmApFileAllocate(rpt) != kOkApRC )
@@ -737,11 +740,11 @@ int cmApPortTest( bool runFl, cmRpt_t* rpt, int argc, const char* argv[] )
737 740
     cmApBufInitialize( cmApDeviceCount(), r.meterMs );
738 741
 
739 742
     // setup the buffer for the output device
740
-    cmApBufSetup( r.outDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.outDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.outDevIdx,false), r.framesPerCycle );
743
+    cmApBufSetup( r.outDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.outDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.outDevIdx,false), r.framesPerCycle, srateMult );
741 744
     
742 745
     // setup the buffer for the input device
743 746
     if( r.inDevIdx != r.outDevIdx )
744
-      cmApBufSetup( r.inDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.inDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.inDevIdx,false), r.framesPerCycle ); 
747
+      cmApBufSetup( r.inDevIdx, r.srate, r.framesPerCycle, r.bufCnt, cmApDeviceChannelCount(r.inDevIdx,true), r.framesPerCycle, cmApDeviceChannelCount(r.inDevIdx,false), r.framesPerCycle, srateMult ); 
745 748
 
746 749
     cmApBufEnableMeter(  r.inDevIdx, -1, kEnableApFl );
747 750
 

+ 10
- 2
cmAudioSys.c Parādīt failu

@@ -514,6 +514,14 @@ void _cmAudioSysSerialPortCallback( void* cbArg, const void* byteA, unsigned byt
514 514
   //_cmAsCfg_t* p (_cmAsCfg_t*)cbArg;
515 515
   
516 516
   // TODO: handle serial receive
517
+  /*
518
+  int i;
519
+  for(i=0; i<byteN; ++i)
520
+  {
521
+    printf("%02x ",((const uint8_t*)byteA)[i]);
522
+    fflush(stdout);
523
+  }
524
+  */
517 525
 }
518 526
 
519 527
 cmAsRC_t cmAudioSysAllocate( cmAudioSysH_t* hp, cmRpt_t* rpt, const cmAudioSysCfg_t* cfg )
@@ -800,7 +808,7 @@ cmAsRC_t cmAudioSysInitialize( cmAudioSysH_t h, const cmAudioSysCfg_t* cfg )
800 808
 
801 809
     // setup the input device buffer
802 810
     if( ss->args.inDevIdx != cmInvalidIdx )
803
-      if((rc = cmApBufSetup( ss->args.inDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.inDevIdx, true),  ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.inDevIdx, false), ss->args.devFramesPerCycle )) != kOkAsRC )
811
+      if((rc = cmApBufSetup( ss->args.inDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.inDevIdx, true),  ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.inDevIdx, false), ss->args.devFramesPerCycle, ss->args.srateMult )) != kOkAsRC )
804 812
       {
805 813
         rc = _cmAsError(p,kAudioBufSetupErrAsRC,"Audio buffer input  setup failed.");
806 814
         goto errLabel;
@@ -815,7 +823,7 @@ cmAsRC_t cmAudioSysInitialize( cmAudioSysH_t h, const cmAudioSysCfg_t* cfg )
815 823
 
816 824
     // setup the output device buffer
817 825
     if( ss->args.outDevIdx != ss->args.inDevIdx )
818
-      if((rc = cmApBufSetup( ss->args.outDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.outDevIdx, true), ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.outDevIdx, false), ss->args.devFramesPerCycle )) != kOkAsRC )
826
+      if((rc = cmApBufSetup( ss->args.outDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.outDevIdx, true), ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.outDevIdx, false), ss->args.devFramesPerCycle, ss->args.srateMult )) != kOkAsRC )
819 827
         return _cmAsError(p,kAudioBufSetupErrAsRC,"Audio buffer ouput device setup failed.");
820 828
 
821 829
     // setup the output audio buffer ptr array - used to recv output audio from the DSP system in _cmAsDspExecCallback()

+ 1
- 0
cmAudioSys.h Parādīt failu

@@ -139,6 +139,7 @@ extern "C" {
139 139
     unsigned       dspFramesPerCycle; // (64)  Audio samples per channel per DSP cycle.
140 140
     unsigned       audioBufCnt;       // (3)   Audio device buffers.
141 141
     double         srate;             // Audio sample rate.
142
+    int            srateMult;         // Sample rate multiplication factor (negative for divide)
142 143
   } cmAudioSysArgs_t;
143 144
 
144 145
   // Audio sub-system configuration record.

+ 2
- 2
cmRtSys.c Parādīt failu

@@ -887,7 +887,7 @@ cmRtRC_t cmRtSysCfg( cmRtSysH_t h, const cmRtSysSubSys_t* ss, unsigned rtSubIdx
887 887
 
888 888
   // setup the input device buffer
889 889
   if( ss->args.inDevIdx != cmInvalidIdx )
890
-    if((rc = cmApBufSetup( ss->args.inDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.inDevIdx, true),  ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.inDevIdx, false), ss->args.devFramesPerCycle )) != kOkRtRC )
890
+    if((rc = cmApBufSetup( ss->args.inDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.inDevIdx, true),  ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.inDevIdx, false), ss->args.devFramesPerCycle, ss->args.srateMult )) != kOkRtRC )
891 891
     {
892 892
       rc = _cmRtError(p,kAudioBufSetupErrRtRC,"Audio buffer input  setup failed.");
893 893
       goto errLabel;
@@ -902,7 +902,7 @@ cmRtRC_t cmRtSysCfg( cmRtSysH_t h, const cmRtSysSubSys_t* ss, unsigned rtSubIdx
902 902
 
903 903
   // setup the output device buffer
904 904
   if( ss->args.outDevIdx != ss->args.inDevIdx )
905
-    if((rc = cmApBufSetup( ss->args.outDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.outDevIdx, true), ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.outDevIdx, false), ss->args.devFramesPerCycle )) != kOkRtRC )
905
+    if((rc = cmApBufSetup( ss->args.outDevIdx, ss->args.srate, ss->args.dspFramesPerCycle, ss->args.audioBufCnt, cmApDeviceChannelCount(ss->args.outDevIdx, true), ss->args.devFramesPerCycle, cmApDeviceChannelCount(ss->args.outDevIdx, false), ss->args.devFramesPerCycle, ss->args.srateMult )) != kOkRtRC )
906 906
       return _cmRtError(p,kAudioBufSetupErrRtRC,"Audio buffer ouput device setup failed.");
907 907
 
908 908
   // setup the output audio buffer ptr array - used to recv output audio from the DSP system in _cmRtDspExecCallback()

+ 1
- 0
cmRtSys.h Parādīt failu

@@ -153,6 +153,7 @@ extern "C" {
153 153
     unsigned        dspFramesPerCycle; // (64)  Audio samples per channel per DSP cycle.
154 154
     unsigned        audioBufCnt;       // (3)   Audio device buffers.
155 155
     double          srate;             // Audio sample rate.
156
+    int             srateMult;
156 157
   } cmRtSysArgs_t;
157 158
 
158 159
   // Audio sub-system configuration record.

+ 1
- 1
dsp/cmDspClass.c Parādīt failu

@@ -667,7 +667,7 @@ cmDspRC_t   cmDspVarPresetRdWr(     cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned
667 667
 }
668 668
 
669 669
 double      cmDspSampleRate(      cmDspCtx_t* ctx )
670
-{ return ctx->ctx->ss->args.srate; }
670
+{ return ctx->ctx->ss->args.srate * ctx->ctx->ss->args.srateMult; }
671 671
 
672 672
 unsigned    cmDspSamplesPerCycle( cmDspCtx_t * ctx )
673 673
 { return ctx->ctx->ss->args.dspFramesPerCycle; }

+ 95
- 89
dsp/cmDspKr.c Parādīt failu

@@ -2812,6 +2812,7 @@ enum
2812 2812
   kStatusPcId,
2813 2813
   kD0PcId,
2814 2814
   kD1PcId,
2815
+  kAllOffPcId
2815 2816
 };
2816 2817
 
2817 2818
 cmDspClass_t _cmPicadaeDC;
@@ -2933,95 +2934,95 @@ typedef struct
2933 2934
 
2934 2935
 cmDspPicadaeDuty_t cmDspPicadaeDutyMap[] =
2935 2936
 {
2936
- 21, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2937
- 22, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2938
- 23, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2939
- 24, {{ 0, 75 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2940
- 25, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2941
- 26, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2942
- 27, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2943
- 28, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2944
- 29, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2945
- 30, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2946
- 31, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2947
- 32, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2948
- 33, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2949
- 34, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2950
- 35, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2951
- 36, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2952
- 37, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2953
- 38, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2954
- 39, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2955
- 40, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2956
- 41, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2957
- 42, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2958
- 43, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2959
- 44, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2960
- 45, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2961
- 46, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2962
- 47, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2963
- 48, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2964
- 49, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2965
- 50, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2966
- 51, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2967
- 52, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2968
- 53, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2969
- 54, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2970
- 55, {{ 0, 50 }, { 22000, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2971
- 56, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2972
- 57, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2973
- 58, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2974
- 59, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2975
- 60, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2976
- 61, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2977
- 62, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2978
- 63, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2979
- 64, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2980
- 65, {{ 0, 50 }, { 17000, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2981
- 66, {{ 0, 53 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2982
- 67, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2983
- 68, {{ 0, 53 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2984
- 69, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2985
- 70, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2986
- 71, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2987
- 72, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2988
- 73, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2989
- 74, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2990
- 75, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2991
- 76, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2992
- 77, {{ 0, 50 }, { 15000, 60 }, { 19000, 70 }, { -1, -1 }, { -1, -1 }, },
2993
- 78, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2994
- 79, {{ 0, 50 }, { 15000, 60 }, { 19000, 70 }, { -1, -1 }, { -1, -1 }, },
2995
- 80, {{ 0, 45 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2996
- 81, {{ 0, 50 }, { 15000, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2997
- 82, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
2998
- 83, {{ 0, 50 }, { 15000, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2999
- 84, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
3000
- 85, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
3001
- 86, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
3002
- 87, {{ 0, 50 }, { 14000, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3003
- 88, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
3004
- 89, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, },
3005
- 90, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3006
- 91, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, }, 
3007
- 92, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3008
- 93, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, },
3009
- 94, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3010
- 95, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, },
3011
- 96, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, },
3012
- 97, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3013
- 98, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3014
- 99, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3015
- 100, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3016
- 101, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3017
- 102, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3018
- 103, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3019
- 104, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3020
- 105, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3021
- 106, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3022
- 107, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3023
- 108, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
3024
-   0, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, },
2937
+ {21, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2938
+ {22, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2939
+ {23, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2940
+ {24, {{ 0, 75 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2941
+ {25, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2942
+ {26, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2943
+ {27, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2944
+ {28, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2945
+ {29, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2946
+ {30, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2947
+ {31, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2948
+ {32, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2949
+ {33, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2950
+ {34, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2951
+ {35, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2952
+ {36, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2953
+ {37, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2954
+ {38, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2955
+ {39, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2956
+ {40, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2957
+ {41, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2958
+ {42, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2959
+ {43, {{ 0, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2960
+ {44, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2961
+ {45, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2962
+ {46, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2963
+ {47, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2964
+ {48, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2965
+ {49, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2966
+ {50, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2967
+ {51, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2968
+ {52, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2969
+ {53, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2970
+ {54, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2971
+ {55, {{ 0, 50 }, { 22000, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2972
+ {56, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2973
+ {57, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2974
+ {58, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2975
+ {59, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2976
+ {60, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2977
+ {61, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2978
+ {62, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2979
+ {63, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2980
+ {64, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2981
+ {65, {{ 0, 50 }, { 17000, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2982
+ {66, {{ 0, 53 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2983
+ {67, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2984
+ {68, {{ 0, 53 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2985
+ {69, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2986
+ {70, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2987
+ {71, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2988
+ {72, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2989
+ {73, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2990
+ {74, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2991
+ {75, {{ 0, 55 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2992
+ {76, {{ 0, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2993
+ {77, {{ 0, 50 }, { 15000, 60 }, { 19000, 70 }, { -1, -1 }, { -1, -1 }, }},
2994
+ {78, {{ 0, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2995
+ {79, {{ 0, 50 }, { 15000, 60 }, { 19000, 70 }, { -1, -1 }, { -1, -1 }, }},
2996
+ {80, {{ 0, 45 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2997
+ {81, {{ 0, 50 }, { 15000, 70 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
2998
+ {82, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, }},
2999
+ {83, {{ 0, 50 }, { 15000, 65 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3000
+ {84, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, }},
3001
+ {85, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, }},
3002
+ {86, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, }},
3003
+ {87, {{ 0, 50 }, { 14000, 60 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3004
+ {88, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, }},
3005
+ {89, {{ 0, 50 }, { 12500, 60 }, { 14000, 65 }, { 17000, 70 }, { -1, -1 }, }},
3006
+ {90, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3007
+ {91, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, }}, 
3008
+ {92, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3009
+ {93, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, }},
3010
+ {94, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3011
+ {95, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, }},
3012
+ {96, {{ 0, 40 }, { 12500, 50 }, { 14000, 60 }, { 17000, 65 }, { -1, -1 }, }},
3013
+ {97, {{ 0, 40 }, { 14000, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3014
+ {98, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3015
+ {99, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3016
+ {100, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3017
+ {101, {{ 0, 50 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3018
+ {102, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3019
+ {103, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3020
+ {104, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3021
+ {105, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3022
+ {106, {{ -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3023
+ {107, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3024
+ {108, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3025
+ {  0, {{ -1, -1}, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, }},
3025 3026
 
3026 3027
 };
3027 3028
 
@@ -3135,6 +3136,7 @@ cmDspInst_t*  _cmDspPicadaeAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsign
3135 3136
     { "status", kStatusPcId, 0,  0,  kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI status" },
3136 3137
     { "d0",     kD0PcId,     0,  0,  kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI channel message d0" },
3137 3138
     { "d1",     kD1PcId,     0,  0,  kOutDsvFl | kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "MIDI channel message d1" },
3139
+    { "alloff", kAllOffPcId, 0,  0,  kOutDsvFl | kInDsvFl | kSymDsvFl  | kOptArgDsvFl, "All notes off."}, 
3138 3140
     { NULL, 0, 0, 0, 0 }
3139 3141
   };
3140 3142
 
@@ -3205,6 +3207,10 @@ cmDspRC_t _cmDspPicadaeRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
3205 3207
       }
3206 3208
       break;
3207 3209
 
3210
+    case kAllOffPcId:
3211
+      printf("Picadae All Off\n");
3212
+      _cmDspPicadaReset( ctx, inst );
3213
+      break;
3208 3214
 
3209 3215
     default:
3210 3216
       // store 

+ 32
- 15
dsp/cmDspPgm.c Parādīt failu

@@ -131,11 +131,11 @@ cmDspRC_t _cmDspSysPgm_MidiFilePlay( cmDspSysH_t h, void** userPtrPtr )
131 131
   cmDspRC_t rc = kOkDspRC;
132 132
 
133 133
 
134
-  //const cmChar_t* deviceName = "Scarlett 18i20 USB";
135
-  //const cmChar_t* portName   = "Scarlett 18i20 USB MIDI 1";
134
+  const cmChar_t* deviceName = "Scarlett 18i20 USB";
135
+  const cmChar_t* portName   = "Scarlett 18i20 USB MIDI 1";
136 136
   
137
-  const cmChar_t* deviceName = "Fastlane";
138
-  const cmChar_t* portName   = "Fastlane MIDI A";
137
+  //const cmChar_t* deviceName = "Fastlane";
138
+  //const cmChar_t* portName   = "Fastlane MIDI A";
139 139
 
140 140
   //const cmChar_t* deviceName = "DKV-M4";
141 141
   //const cmChar_t* portName   = "DKV-M4 MIDI 1";
@@ -150,7 +150,8 @@ cmDspRC_t _cmDspSysPgm_MidiFilePlay( cmDspSysH_t h, void** userPtrPtr )
150 150
   cmDspInst_t* ai1p = cmDspSysAllocInst(h,"AudioIn", NULL,   1, 3 );
151 151
 
152 152
   cmDspInst_t* mfp   = cmDspSysAllocInst(h,"MidiFilePlay",NULL,  0 );
153
-  cmDspInst_t* mop   = cmDspSysAllocInst( h,"MidiOut", NULL,     2, deviceName, portName);
153
+  cmDspInst_t* pic   = cmDspSysAllocInst(h,"Picadae",     NULL,  0 );
154
+  cmDspInst_t* mop   = cmDspSysAllocInst( h,"MidiOut",    NULL,  2, deviceName, portName);
154 155
 
155 156
   cmDspInst_t* start = cmDspSysAllocInst( h,"Button", "start",    2, kButtonDuiId, 0.0 );
156 157
   cmDspInst_t* stop  = cmDspSysAllocInst( h,"Button", "stop",     2, kButtonDuiId, 0.0 );
@@ -159,10 +160,10 @@ cmDspRC_t _cmDspSysPgm_MidiFilePlay( cmDspSysH_t h, void** userPtrPtr )
159 160
   cmDspInst_t* beg = cmDspSysAllocInst(h,"Scalar", "Beg Samp",    5, kNumberDuiId, 0.0, 1000000000.0, 1.0,   0.0 );  
160 161
   cmDspInst_t* end = cmDspSysAllocInst(h,"Scalar", "End Samp",    5, kNumberDuiId, 0.0, 1000000000.0, 1.0,   1000000000.0 );  
161 162
    
162
-  cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 0 );
163
-  cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 1 );
164
-  cmDspInst_t* ao2p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 2 );
165
-  cmDspInst_t* ao3p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 3 );
163
+  cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 2 );
164
+  cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 3 );
165
+  cmDspInst_t* ao2p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 4 );
166
+  cmDspInst_t* ao3p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 5 );
166 167
 
167 168
   cmDspInst_t* im0p = cmDspSysAllocInst(h,"AMeter","In 0",  0);
168 169
   cmDspInst_t* im1p = cmDspSysAllocInst(h,"AMeter","In 1", 0);
@@ -190,11 +191,25 @@ cmDspRC_t _cmDspSysPgm_MidiFilePlay( cmDspSysH_t h, void** userPtrPtr )
190 191
   cmDspSysInstallCb(   h, stop,  "sym",   mfp, "sel",    NULL);
191 192
   cmDspSysInstallCb(   h, cont,  "sym",   mfp, "sel",    NULL);
192 193
 
194
+  bool usePicadaeFl = false;
195
+  
196
+  if( usePicadaeFl )
197
+  {
198
+    cmDspSysInstallCb(   h, mfp,  "d1",     pic, "d1",     NULL);
199
+    cmDspSysInstallCb(   h, mfp,  "d0",     pic, "d0",     NULL);
200
+    cmDspSysInstallCb(   h, mfp,  "status", pic, "status", NULL);
193 201
 
194
-  cmDspSysInstallCb(   h, mfp,  "d1",     mop, "d1",     NULL);
195
-  cmDspSysInstallCb(   h, mfp,  "d0",     mop, "d0",     NULL);
196
-  cmDspSysInstallCb(   h, mfp,  "status", mop, "status", NULL);
197
-
202
+    cmDspSysInstallCb(   h, pic,  "d1",     mop, "d1",     NULL);
203
+    cmDspSysInstallCb(   h, pic,  "d0",     mop, "d0",     NULL);
204
+    cmDspSysInstallCb(   h, pic,  "status", mop, "status", NULL);
205
+  }
206
+  else
207
+  {
208
+    cmDspSysInstallCb(   h, mfp,  "d1",     mop, "d1",     NULL);
209
+    cmDspSysInstallCb(   h, mfp,  "d0",     mop, "d0",     NULL);
210
+    cmDspSysInstallCb(   h, mfp,  "status", mop, "status", NULL);
211
+  }
212
+  
198 213
   //cmDspSysConnectAudio(h, ai0p, "out", ao0p, "in"); 
199 214
   //cmDspSysConnectAudio(h, ai1p, "out", ao1p, "in"); 
200 215
 
@@ -357,7 +372,7 @@ cmDspRC_t _cmDspSysPgm_Test_Pedals( cmDspSysH_t h, void** userPtrPtr )
357 372
 cmDspRC_t _cmDspSysPgm_Stereo_Through( cmDspSysH_t h, void** userPtrPtr )
358 373
 {
359 374
 
360
-  cmDspInst_t* ignp = cmDspSysAllocInst( h,"Scalar", "In Gain",  5, kNumberDuiId, 0.0,  4.0, 0.01,  1.0);
375
+  cmDspInst_t* ignp = cmDspSysAllocInst( h,"Scalar", "In Gain",  5, kNumberDuiId, 0.0,  4.0, 0.01,  0.0);
361 376
   //cmDspInst_t* ognp = cmDspSysAllocInst( h,"Scalar", "Out Gain", 5, kNumberDuiId, 0.0,  4.0, 0.01,  1.0);
362 377
   cmDspInst_t* hzp  =  cmDspSysAllocInst(h,"Scalar", "Hz",       5, kNumberDuiId, 0.0, 10.0, 0.001, 1.0);
363 378
 
@@ -403,7 +418,9 @@ cmDspRC_t _cmDspSysPgm_Stereo_Through( cmDspSysH_t h, void** userPtrPtr )
403 418
   return kOkDspRC;
404 419
 }
405 420
 
406
-
421
+//------------------------------------------------------------------------------
422
+//)
423
+//( { label:cmDspSysPgm_All_In_And_Out file_desc:"Meter all the input channels and pass two channels to the output." kw:[spgm] }
407 424
 cmDspRC_t _cmDspSysPgm_All_In_And_Out( cmDspSysH_t h, void** userPtrPtr )
408 425
 {
409 426
   cmDspInst_t* ignp = cmDspSysAllocInst( h,"Scalar", "In Gain",  5, kNumberDuiId, 0.0,  4.0, 0.01,  1.0);

+ 2
- 0
dsp/cmDspPgmKrTimeLineLite.c Parādīt failu

@@ -95,6 +95,7 @@ cmDspRC_t _cmDspSysPgm_TimeLineLite(cmDspSysH_t h, void** userPtrPtr )
95 95
   cmDspInst_t* ao3 = cmDspSysAllocInst(h,"AudioOut",    NULL,   1, 3 ); // 3          2
96 96
 
97 97
   cmDspSysNewPage(h,"Main");
98
+  cmDspInst_t* notesOffb= cmDspSysAllocInst(h,"Button", "notesOff",   2, kButtonDuiId, 1.0 );
98 99
   cmDspInst_t* onb     = cmDspSysAllocInst(h,"Button", "start",   2, kButtonDuiId, 1.0 );
99 100
   cmDspInst_t* offb    = cmDspSysAllocInst(h,"Button", "stop",    2, kButtonDuiId, 1.0 );
100 101
   cmDspInst_t* mod_sel = cmDspSysAllocMsgList(h, NULL, "mod_sel", 1 );
@@ -233,6 +234,7 @@ cmDspRC_t _cmDspSysPgm_TimeLineLite(cmDspSysH_t h, void** userPtrPtr )
233 234
 
234 235
   cmDspSysInstallCb(h, prePath, "out", tlp, "path", NULL );
235 236
 
237
+  cmDspSysInstallCb(h, notesOffb,  "sym",    pic, "alloff",  NULL );
236 238
   
237 239
   // start connections
238 240
   cmDspSysInstallCb(h, onb,  "sym",    tlRt, "s-in",  NULL );

+ 1
- 1
dsp/cmDspSys.c Parādīt failu

@@ -1547,7 +1547,7 @@ cmDspRC_t cmDspSysInstallCb1NN1M2( cmDspSysH_t h, cmDspInst_t* srcInstPtr,  cons
1547 1547
 double       cmDspSysSampleRate( cmDspSysH_t h )
1548 1548
 {
1549 1549
   cmDsp_t* p = _cmDspHandleToPtr(h);
1550
-  return p->ctx.ctx->ss->args.srate;
1550
+  return cmDspSampleRate( &p->ctx );
1551 1551
 }
1552 1552
 
1553 1553
 cmJsonH_t    cmDspSysPgmRsrcHandle( cmDspSysH_t h )

Notiek ielāde…
Atcelt
Saglabāt