Browse Source

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

master
kpl 12 years ago
parent
commit
f0e00c3d37
5 changed files with 155 additions and 16 deletions
  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 View File

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

+ 2
- 1
dsp/cmDspClass.h View File

392
   cmDspRC_t  cmDspUiMeterCreate(  cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned minVarId,  unsigned maxVarId,  unsigned valVarId,  unsigned lblVarId );
392
   cmDspRC_t  cmDspUiMeterCreate(  cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned minVarId,  unsigned maxVarId,  unsigned valVarId,  unsigned lblVarId );
393
   cmDspRC_t  cmDspUiButtonCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned typeDuiId, unsigned outVarId, unsigned lblVarId );
393
   cmDspRC_t  cmDspUiButtonCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned typeDuiId, unsigned outVarId, unsigned lblVarId );
394
   cmDspRC_t  cmDspUiLabelCreate(  cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned lblVarId,  unsigned alignVarId );
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
   cmDspRC_t  cmDspUiNewColumn(        cmDspCtx_t* ctx, unsigned colW );
398
   cmDspRC_t  cmDspUiNewColumn(        cmDspCtx_t* ctx, unsigned colW );
398
   cmDspRC_t  cmDspUiInsertHorzBorder( cmDspCtx_t* ctx );
399
   cmDspRC_t  cmDspUiInsertHorzBorder( cmDspCtx_t* ctx );

+ 129
- 13
dsp/cmDspKr.c View File

21
 #include "cmDspCtx.h"
21
 #include "cmDspCtx.h"
22
 #include "cmDspClass.h"
22
 #include "cmDspClass.h"
23
 #include "cmDspUi.h"
23
 #include "cmDspUi.h"
24
-#include "cmOp.h"
25
 #include "cmMath.h"
24
 #include "cmMath.h"
26
 
25
 
27
 
26
 
163
   cmSpecDistExec(p->sdp,ip,iSmpCnt);
162
   cmSpecDistExec(p->sdp,ip,iSmpCnt);
164
   
163
   
165
   if((sp = cmSpecDistOut(p->sdp)) != NULL )
164
   if((sp = cmSpecDistOut(p->sdp)) != NULL )
166
-    vs_Copy(op,sp,oSmpCnt);
165
+    cmVOS_Copy(op,oSmpCnt,sp);
167
   
166
   
168
   return rc;
167
   return rc;
169
 }
168
 }
241
   kTlFileTlId,
240
   kTlFileTlId,
242
   kAudPathTlId,
241
   kAudPathTlId,
243
   kSelTlId,
242
   kSelTlId,
243
+  kCursTlId,
244
+  kResetTlId,
244
   kAudFnTlId,
245
   kAudFnTlId,
245
   kMidiFnTlId,
246
   kMidiFnTlId,
246
   kBegAudSmpIdxTlId,
247
   kBegAudSmpIdxTlId,
247
   kEndAudSmpIdxTlId,
248
   kEndAudSmpIdxTlId,
248
   kBegMidiSmpIdxTlId,
249
   kBegMidiSmpIdxTlId,
249
   kEndMidiSmpIdxTlId
250
   kEndMidiSmpIdxTlId
250
-
251
 };
251
 };
252
 
252
 
253
 cmDspClass_t _cmTimeLineDC;
253
 cmDspClass_t _cmTimeLineDC;
256
 {
256
 {
257
   cmDspInst_t inst;
257
   cmDspInst_t inst;
258
   cmTlH_t     tlH;
258
   cmTlH_t     tlH;
259
+  unsigned    afIdx;
259
 } cmDspTimeLine_t;
260
 } cmDspTimeLine_t;
260
 
261
 
261
 cmDspInst_t*  _cmDspTimeLineAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
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
   cmDspVarArg_t args[] =
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
     { NULL, 0, 0, 0, 0 }
277
     { NULL, 0, 0, 0, 0 }
275
   };
278
   };
276
 
279
 
277
   cmDspTimeLine_t* p = cmDspInstAlloc(cmDspTimeLine_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
280
   cmDspTimeLine_t* p = cmDspInstAlloc(cmDspTimeLine_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
278
   
281
   
279
   cmDspSetDefaultUInt( ctx, &p->inst,  kSelTlId,           0, cmInvalidId);
282
   cmDspSetDefaultUInt( ctx, &p->inst,  kSelTlId,           0, cmInvalidId);
283
+  cmDspSetDefaultUInt( ctx, &p->inst,  kCursTlId,          0, 0);
280
   cmDspSetDefaultStrcz(ctx, &p->inst,  kAudFnTlId,         NULL, "");
284
   cmDspSetDefaultStrcz(ctx, &p->inst,  kAudFnTlId,         NULL, "");
281
   cmDspSetDefaultStrcz(ctx, &p->inst,  kMidiFnTlId,        NULL, "");
285
   cmDspSetDefaultStrcz(ctx, &p->inst,  kMidiFnTlId,        NULL, "");
282
   cmDspSetDefaultInt(  ctx, &p->inst,  kBegAudSmpIdxTlId,  0, cmInvalidIdx);
286
   cmDspSetDefaultInt(  ctx, &p->inst,  kBegAudSmpIdxTlId,  0, cmInvalidIdx);
285
   cmDspSetDefaultInt(  ctx, &p->inst,  kEndMidiSmpIdxTlId, 0, cmInvalidIdx);
289
   cmDspSetDefaultInt(  ctx, &p->inst,  kEndMidiSmpIdxTlId, 0, cmInvalidIdx);
286
 
290
 
287
   // create the UI control
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
   p->tlH = cmTimeLineNullHandle;
294
   p->tlH = cmTimeLineNullHandle;
291
 
295
 
325
 
329
 
326
   switch( evt->dstVarId )
330
   switch( evt->dstVarId )
327
   {
331
   {
332
+    case kCursTlId:
333
+      cmDspSetEvent(ctx,inst,evt);
334
+      break;
335
+
336
+    case kResetTlId:
328
     case kSelTlId:
337
     case kSelTlId:
329
       {
338
       {
330
         unsigned markerId;
339
         unsigned markerId;
339
           {
348
           {
340
             assert(op->typeId == kMarkerTlId);
349
             assert(op->typeId == kMarkerTlId);
341
 
350
 
351
+            p->afIdx = op->begSmpIdx;
352
+
342
             cmDspSetInt(ctx, inst, kBegAudSmpIdxTlId,  op->begSmpIdx );
353
             cmDspSetInt(ctx, inst, kBegAudSmpIdxTlId,  op->begSmpIdx );
343
             cmDspSetInt(ctx, inst, kEndAudSmpIdxTlId,  op->begSmpIdx + op->durSmpCnt );
354
             cmDspSetInt(ctx, inst, kEndAudSmpIdxTlId,  op->begSmpIdx + op->durSmpCnt );
344
             
355
             
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
 // MIDI File Player
506
 // MIDI File Player
391
 
507
 
392
 enum
508
 enum

+ 1
- 0
dsp/cmDspKr.h View File

7
 
7
 
8
   struct cmDspClass_str* cmKrClassCons( cmDspCtx_t* ctx );
8
   struct cmDspClass_str* cmKrClassCons( cmDspCtx_t* ctx );
9
   struct cmDspClass_str* cmTimeLineClassCons( cmDspCtx_t* ctx );
9
   struct cmDspClass_str* cmTimeLineClassCons( cmDspCtx_t* ctx );
10
+  struct cmDspClass_str* cmScoreClassCons( cmDspCtx_t* ctx );
10
   struct cmDspClass_str* cmMidiFilePlayClassCons( cmDspCtx_t* ctx );
11
   struct cmDspClass_str* cmMidiFilePlayClassCons( cmDspCtx_t* ctx );
11
   struct cmDspClass_str* cmScFolClassCons( cmDspCtx_t* ctx );
12
   struct cmDspClass_str* cmScFolClassCons( cmDspCtx_t* ctx );
12
 
13
 

+ 22
- 2
dsp/cmDspUi.c View File

361
   return rc;
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
   cmDspRC_t    rc;
366
   cmDspRC_t    rc;
367
-  unsigned     arr[] = { tlFileVarId, audPathVarId, selVarId  };
367
+  unsigned     arr[] = { tlFileVarId, audPathVarId, selVarId, cursVarId  };
368
   cmDspValue_t v;
368
   cmDspValue_t v;
369
   unsigned     vn    = sizeof(arr)/sizeof(arr[0]);
369
   unsigned     vn    = sizeof(arr)/sizeof(arr[0]);
370
   cmDsvSetUIntMtx(&v,arr,vn,1);
370
   cmDsvSetUIntMtx(&v,arr,vn,1);
382
   cmDspInstVarSetFlags( ctx, inst, tlFileVarId,  kUiDsvFl );
382
   cmDspInstVarSetFlags( ctx, inst, tlFileVarId,  kUiDsvFl );
383
   cmDspInstVarSetFlags( ctx, inst, audPathVarId, kUiDsvFl );
383
   cmDspInstVarSetFlags( ctx, inst, audPathVarId, kUiDsvFl );
384
   cmDspInstVarSetFlags( ctx, inst, selVarId,     kUiDsvFl );
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
   return rc;
405
   return rc;
386
 }
406
 }
387
 
407
 

Loading…
Cancel
Save