|
@@ -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
|