瀏覽代碼

cmDspKr.h/c Added Score Object added Time-line cursor.

master
kpl 12 年之前
父節點
當前提交
f0e00c3d37
共有 5 個文件被更改,包括 155 次插入16 次删除
  1. 1
    0
      cmMsgProtocol.h
  2. 2
    1
      dsp/cmDspClass.h
  3. 129
    13
      dsp/cmDspKr.c
  4. 1
    0
      dsp/cmDspKr.h
  5. 22
    2
      dsp/cmDspUi.c

+ 1
- 0
cmMsgProtocol.h 查看文件

@@ -31,6 +31,7 @@ extern "C" {
31 31
     kCheckDuiId,   // ui<--eng create a check box control
32 32
     kLabelDuiId,   // ui<--end create a label control
33 33
     kTimeLineDuiId,// ui<--end create a time-line control
34
+    kScoreDuiId,   // ui<--end create a score control
34 35
     kNumberDuiId,  // ui<--eng create a number box
35 36
     kTextDuiId,    // ui<--eng create a text entry control
36 37
     kFnameDuiId,   // ui<--eng create a file/directory picker control

+ 2
- 1
dsp/cmDspClass.h 查看文件

@@ -392,7 +392,8 @@ extern "C" {
392 392
   cmDspRC_t  cmDspUiMeterCreate(  cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned minVarId,  unsigned maxVarId,  unsigned valVarId,  unsigned lblVarId );
393 393
   cmDspRC_t  cmDspUiButtonCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned typeDuiId, unsigned outVarId, unsigned lblVarId );
394 394
   cmDspRC_t  cmDspUiLabelCreate(  cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned lblVarId,  unsigned alignVarId );
395
-  cmDspRC_t  cmDspUiTimeLineCreate(cmDspCtx_t* ctx,cmDspInst_t* inst, unsigned tlFileVarId,  unsigned audPathVarId, unsigned selVarId );
395
+  cmDspRC_t  cmDspUiTimeLineCreate(cmDspCtx_t* ctx,cmDspInst_t* inst, unsigned tlFileVarId,  unsigned audPathVarId, unsigned selVarId, unsigned cursVarId );
396
+  cmDspRC_t  cmDspUiScoreCreate(   cmDspCtx_t* ctx,cmDspInst_t* inst, unsigned scFileVarId,  unsigned selVarId );
396 397
 
397 398
   cmDspRC_t  cmDspUiNewColumn(        cmDspCtx_t* ctx, unsigned colW );
398 399
   cmDspRC_t  cmDspUiInsertHorzBorder( cmDspCtx_t* ctx );

+ 129
- 13
dsp/cmDspKr.c 查看文件

@@ -21,7 +21,6 @@
21 21
 #include "cmDspCtx.h"
22 22
 #include "cmDspClass.h"
23 23
 #include "cmDspUi.h"
24
-#include "cmOp.h"
25 24
 #include "cmMath.h"
26 25
 
27 26
 
@@ -163,7 +162,7 @@ cmDspRC_t _cmDspKrExec(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt
163 162
   cmSpecDistExec(p->sdp,ip,iSmpCnt);
164 163
   
165 164
   if((sp = cmSpecDistOut(p->sdp)) != NULL )
166
-    vs_Copy(op,sp,oSmpCnt);
165
+    cmVOS_Copy(op,oSmpCnt,sp);
167 166
   
168 167
   return rc;
169 168
 }
@@ -241,13 +240,14 @@ enum
241 240
   kTlFileTlId,
242 241
   kAudPathTlId,
243 242
   kSelTlId,
243
+  kCursTlId,
244
+  kResetTlId,
244 245
   kAudFnTlId,
245 246
   kMidiFnTlId,
246 247
   kBegAudSmpIdxTlId,
247 248
   kEndAudSmpIdxTlId,
248 249
   kBegMidiSmpIdxTlId,
249 250
   kEndMidiSmpIdxTlId
250
-
251 251
 };
252 252
 
253 253
 cmDspClass_t _cmTimeLineDC;
@@ -256,27 +256,31 @@ typedef struct
256 256
 {
257 257
   cmDspInst_t inst;
258 258
   cmTlH_t     tlH;
259
+  unsigned    afIdx;
259 260
 } cmDspTimeLine_t;
260 261
 
261 262
 cmDspInst_t*  _cmDspTimeLineAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
262 263
 {
263 264
   cmDspVarArg_t args[] =
264 265
   {
265
-    { "tlfile",  kTlFileTlId,         0, 0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl,   "Time line file." },
266
-    { "path",    kAudPathTlId,        0, 0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl,   "Audio path"    },
267
-    { "sel",     kSelTlId,            0, 0, kInDsvFl   | kInDsvFl   | kOutDsvFl  | kUIntDsvFl,   "Selected marker id."},
268
-    { "afn",     kAudFnTlId,          0, 0, kOutDsvFl  | kStrzDsvFl,   "Selected Audio file." },
269
-    { "mfn",     kMidiFnTlId,         0, 0, kOutDsvFl  | kStrzDsvFl,   "Selected MIDI file." },
270
-    { "absi",     kBegAudSmpIdxTlId,  0, 0, kOutDsvFl  | kIntDsvFl,   "Begin audio sample index."},
271
-    { "aesi",     kEndAudSmpIdxTlId,  0, 0, kOutDsvFl  | kIntDsvFl,   "End audio sample index."},
272
-    { "mbsi",     kBegMidiSmpIdxTlId, 0, 0, kOutDsvFl  | kIntDsvFl,   "Begin MIDI sample index."},
273
-    { "mesi",     kEndMidiSmpIdxTlId, 0, 0, kOutDsvFl  | kIntDsvFl,   "End MIDI sample index."},
266
+    { "tlfile",  kTlFileTlId,         0, 0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl, "Time line file." },
267
+    { "path",    kAudPathTlId,        0, 0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl, "Audio path"    },
268
+    { "sel",     kSelTlId,            0, 0, kInDsvFl   | kOutDsvFl  | kUIntDsvFl,   "Selected marker id."},
269
+    { "curs",    kCursTlId,           0, 0, kInDsvFl   | kUIntDsvFl,  "Current audio file index."},
270
+    { "reset",   kResetTlId,          0, 0, kInDsvFl   | kSymDsvFl,   "Resend all outputs." },
271
+    { "afn",     kAudFnTlId,          0, 0, kOutDsvFl  | kStrzDsvFl,  "Selected Audio file." },
272
+    { "mfn",     kMidiFnTlId,         0, 0, kOutDsvFl  | kStrzDsvFl,  "Selected MIDI file." },
273
+    { "absi",    kBegAudSmpIdxTlId,   0, 0, kOutDsvFl  | kIntDsvFl,   "Begin audio sample index."},
274
+    { "aesi",    kEndAudSmpIdxTlId,   0, 0, kOutDsvFl  | kIntDsvFl,   "End audio sample index."},
275
+    { "mbsi",    kBegMidiSmpIdxTlId,  0, 0, kOutDsvFl  | kIntDsvFl,   "Begin MIDI sample index."},
276
+    { "mesi",    kEndMidiSmpIdxTlId,  0, 0, kOutDsvFl  | kIntDsvFl,   "End MIDI sample index."},
274 277
     { NULL, 0, 0, 0, 0 }
275 278
   };
276 279
 
277 280
   cmDspTimeLine_t* p = cmDspInstAlloc(cmDspTimeLine_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
278 281
   
279 282
   cmDspSetDefaultUInt( ctx, &p->inst,  kSelTlId,           0, cmInvalidId);
283
+  cmDspSetDefaultUInt( ctx, &p->inst,  kCursTlId,          0, 0);
280 284
   cmDspSetDefaultStrcz(ctx, &p->inst,  kAudFnTlId,         NULL, "");
281 285
   cmDspSetDefaultStrcz(ctx, &p->inst,  kMidiFnTlId,        NULL, "");
282 286
   cmDspSetDefaultInt(  ctx, &p->inst,  kBegAudSmpIdxTlId,  0, cmInvalidIdx);
@@ -285,7 +289,7 @@ cmDspInst_t*  _cmDspTimeLineAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
285 289
   cmDspSetDefaultInt(  ctx, &p->inst,  kEndMidiSmpIdxTlId, 0, cmInvalidIdx);
286 290
 
287 291
   // create the UI control
288
-  cmDspUiTimeLineCreate(ctx,&p->inst,kTlFileTlId,kAudPathTlId,kSelTlId);
292
+  cmDspUiTimeLineCreate(ctx,&p->inst,kTlFileTlId,kAudPathTlId,kSelTlId,kCursTlId);
289 293
 
290 294
   p->tlH = cmTimeLineNullHandle;
291 295
 
@@ -325,6 +329,11 @@ cmDspRC_t _cmDspTimeLineRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
325 329
 
326 330
   switch( evt->dstVarId )
327 331
   {
332
+    case kCursTlId:
333
+      cmDspSetEvent(ctx,inst,evt);
334
+      break;
335
+
336
+    case kResetTlId:
328 337
     case kSelTlId:
329 338
       {
330 339
         unsigned markerId;
@@ -339,6 +348,8 @@ cmDspRC_t _cmDspTimeLineRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
339 348
           {
340 349
             assert(op->typeId == kMarkerTlId);
341 350
 
351
+            p->afIdx = op->begSmpIdx;
352
+
342 353
             cmDspSetInt(ctx, inst, kBegAudSmpIdxTlId,  op->begSmpIdx );
343 354
             cmDspSetInt(ctx, inst, kEndAudSmpIdxTlId,  op->begSmpIdx + op->durSmpCnt );
344 355
             
@@ -387,6 +398,111 @@ struct cmDspClass_str* cmTimeLineClassCons( cmDspCtx_t* ctx )
387 398
 }
388 399
 
389 400
 //==========================================================================================================================================
401
+// Score UI Object
402
+
403
+enum
404
+{
405
+  kFnScId,
406
+  kSelScId,
407
+  kSendScId
408
+};
409
+
410
+cmDspClass_t _cmScoreDC;
411
+
412
+typedef struct
413
+{
414
+  cmDspInst_t inst;
415
+  cmScH_t     scH;
416
+} cmDspScore_t;
417
+
418
+cmDspInst_t*  _cmDspScoreAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
419
+{
420
+  cmDspVarArg_t args[] =
421
+  {
422
+    { "fn",      kFnScId,             0, 0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl, "Score file." },
423
+    { "sel",     kSelScId,            0, 0, kInDsvFl   |  kOutDsvFl | kUIntDsvFl,   "Selected score element index."},
424
+    { "send",    kSendScId,           0, 0, kInDsvFl   | kTypeDsvMask,              "Resend last selected score element."},
425
+    { NULL, 0, 0, 0, 0 }
426
+  };
427
+
428
+  cmDspScore_t* p = cmDspInstAlloc(cmDspScore_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
429
+  
430
+  cmDspSetDefaultUInt( ctx, &p->inst,  kSelScId,           0, cmInvalidId);
431
+
432
+  // create the UI control
433
+  cmDspUiScoreCreate(ctx,&p->inst,kFnScId,kSelScId);
434
+
435
+  p->scH = cmScNullHandle;
436
+
437
+  return &p->inst;
438
+}
439
+
440
+cmDspRC_t _cmDspScoreFree(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
441
+{
442
+  cmDspRC_t        rc = kOkDspRC;
443
+  cmDspScore_t* p = (cmDspScore_t*)inst;
444
+
445
+  if( cmScoreFinalize(&p->scH) != kOkTlRC )
446
+    return cmErrMsg(&inst->classPtr->err, kInstFinalFailDspRC, "Score finalize failed.");
447
+
448
+  return rc;
449
+}
450
+
451
+
452
+cmDspRC_t _cmDspScoreReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
453
+{
454
+  cmDspRC_t        rc = kOkDspRC;
455
+  cmDspScore_t* p  = (cmDspScore_t*)inst;
456
+
457
+  cmDspApplyAllDefaults(ctx,inst);
458
+
459
+  const cmChar_t* tlFn;
460
+  if((tlFn =  cmDspStrcz(inst, kFnScId )) !=  NULL )
461
+    if( cmScoreInitialize(ctx->cmCtx, &p->scH, tlFn, NULL, NULL ) != kOkTlRC )
462
+      rc = cmErrMsg(&inst->classPtr->err, kInstResetFailDspRC, "Score file open failed.");
463
+
464
+  return rc;
465
+}
466
+
467
+cmDspRC_t _cmDspScoreRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
468
+{
469
+  switch( evt->dstVarId )
470
+  {
471
+    case kSelScId:
472
+      cmDspSetEvent(ctx,inst,evt);
473
+      break;
474
+
475
+    case kSendScId:
476
+      {
477
+        unsigned selIdx;
478
+        if((selIdx = cmDspUInt(inst,kSelScId)) != cmInvalidIdx )
479
+          cmDspSetUInt(ctx,inst,kSelScId, selIdx );
480
+      }
481
+      break;
482
+
483
+    default:
484
+      {assert(0);}
485
+  }
486
+
487
+  return kOkDspRC;
488
+}
489
+
490
+struct cmDspClass_str* cmScoreClassCons( cmDspCtx_t* ctx )
491
+{
492
+  cmDspClassSetup(&_cmScoreDC,ctx,"Score",
493
+    NULL,
494
+    _cmDspScoreAlloc,
495
+    _cmDspScoreFree,
496
+    _cmDspScoreReset,
497
+    NULL,
498
+    _cmDspScoreRecv,
499
+    NULL,NULL,
500
+    "Score control.");
501
+
502
+  return &_cmScoreDC;
503
+}
504
+
505
+//==========================================================================================================================================
390 506
 // MIDI File Player
391 507
 
392 508
 enum

+ 1
- 0
dsp/cmDspKr.h 查看文件

@@ -7,6 +7,7 @@ extern "C" {
7 7
 
8 8
   struct cmDspClass_str* cmKrClassCons( cmDspCtx_t* ctx );
9 9
   struct cmDspClass_str* cmTimeLineClassCons( cmDspCtx_t* ctx );
10
+  struct cmDspClass_str* cmScoreClassCons( cmDspCtx_t* ctx );
10 11
   struct cmDspClass_str* cmMidiFilePlayClassCons( cmDspCtx_t* ctx );
11 12
   struct cmDspClass_str* cmScFolClassCons( cmDspCtx_t* ctx );
12 13
 

+ 22
- 2
dsp/cmDspUi.c 查看文件

@@ -361,10 +361,10 @@ cmDspRC_t  cmDspUiLabelCreate(  cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned lbl
361 361
   return rc;
362 362
 }
363 363
 
364
-cmDspRC_t  cmDspUiTimeLineCreate(   cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned tlFileVarId, unsigned audPathVarId, unsigned selVarId )
364
+cmDspRC_t  cmDspUiTimeLineCreate(   cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned tlFileVarId, unsigned audPathVarId, unsigned selVarId, unsigned cursVarId )
365 365
 {
366 366
   cmDspRC_t    rc;
367
-  unsigned     arr[] = { tlFileVarId, audPathVarId, selVarId  };
367
+  unsigned     arr[] = { tlFileVarId, audPathVarId, selVarId, cursVarId  };
368 368
   cmDspValue_t v;
369 369
   unsigned     vn    = sizeof(arr)/sizeof(arr[0]);
370 370
   cmDsvSetUIntMtx(&v,arr,vn,1);
@@ -382,6 +382,26 @@ cmDspRC_t  cmDspUiTimeLineCreate(   cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned
382 382
   cmDspInstVarSetFlags( ctx, inst, tlFileVarId,  kUiDsvFl );
383 383
   cmDspInstVarSetFlags( ctx, inst, audPathVarId, kUiDsvFl );
384 384
   cmDspInstVarSetFlags( ctx, inst, selVarId,     kUiDsvFl );
385
+  cmDspInstVarSetFlags( ctx, inst, cursVarId,     kUiDsvFl );
386
+  return rc;
387
+}
388
+
389
+cmDspRC_t  cmDspUiScoreCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned scFileVarId, unsigned selVarId )
390
+{
391
+  cmDspRC_t    rc;
392
+  unsigned     arr[] = { scFileVarId, selVarId  };
393
+  cmDspValue_t v;
394
+  unsigned     vn    = sizeof(arr)/sizeof(arr[0]);
395
+  cmDsvSetUIntMtx(&v,arr,vn,1);
396
+
397
+  // tell the UI to create a score control
398
+  if((rc = _cmDspUiMsg( ctx, kUiSelAsId, kScoreDuiId, 0, inst, cmInvalidId, &v )) != kOkDspRC )
399
+    return cmDspInstErr(ctx,inst,kUiEleCreateFailDspRC,"Score UI element create failed.");
400
+
401
+  // Set the kUiDsvFl on the variables used for the min/max/def/val for this scalar
402
+  // Setting this flag will cause their values to be sent to the UI whenever they change.
403
+  cmDspInstVarSetFlags( ctx, inst, scFileVarId,  kUiDsvFl );
404
+  cmDspInstVarSetFlags( ctx, inst, selVarId,     kUiDsvFl );
385 405
   return rc;
386 406
 }
387 407
 

Loading…
取消
儲存