Преглед изворни кода

DSP time line processor integration

master
kevin пре 12 година
родитељ
комит
f93924a449
4 измењених фајлова са 62 додато и 18 уклоњено
  1. 1
    1
      dsp/cmDspClass.h
  2. 50
    9
      dsp/cmDspKr.c
  3. 6
    3
      dsp/cmDspPgmKr.c
  4. 5
    5
      dsp/cmDspUi.c

+ 1
- 1
dsp/cmDspClass.h Прегледај датотеку

@@ -392,7 +392,7 @@ 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 valVarId,  unsigned lblVarId, unsigned tlFileId, unsigned audPathId );
395
+  cmDspRC_t  cmDspUiTimeLineCreate(cmDspCtx_t* ctx,cmDspInst_t* inst, unsigned tlFileVarId,  unsigned audPathVarId, unsigned selVarId );
396 396
 
397 397
   cmDspRC_t  cmDspUiNewColumn(        cmDspCtx_t* ctx, unsigned colW );
398 398
   cmDspRC_t  cmDspUiInsertHorzBorder( cmDspCtx_t* ctx );

+ 50
- 9
dsp/cmDspKr.c Прегледај датотеку

@@ -24,6 +24,7 @@
24 24
 #include "cmOp.h"
25 25
 #include "cmMath.h"
26 26
 
27
+
27 28
 #include "cmAudioFile.h"
28 29
 #include "cmFileSys.h"
29 30
 #include "cmProcObj.h"
@@ -33,6 +34,10 @@
33 34
 #include "cmProc2.h"
34 35
 #include "cmVectOpsTemplateMain.h"
35 36
 
37
+#include "cmAudioFile.h"
38
+#include "cmMidiFile.h"
39
+#include "cmTimeLine.h"
40
+
36 41
 enum
37 42
 {
38 43
   kWndSmpCntKrId,
@@ -229,10 +234,12 @@ struct cmDspClass_str* cmKrClassCons( cmDspCtx_t* ctx )
229 234
 //==========================================================================================================================================
230 235
 enum
231 236
 {
232
-  kValTlId,
233
-  kLblTlId,
234 237
   kTlFileTlId,
235
-  kAudPathTlId
238
+  kAudPathTlId,
239
+  kSelTlId,
240
+  kAudFnTlId,
241
+  kBegSmpIdxTlId,
242
+  kEndSmpIdxTlId
236 243
 };
237 244
 
238 245
 cmDspClass_t _cmTimeLineDC;
@@ -240,29 +247,62 @@ cmDspClass_t _cmTimeLineDC;
240 247
 typedef struct
241 248
 {
242 249
   cmDspInst_t inst;
250
+  cmTlH_t     tlH;
243 251
 } cmDspTimeLine_t;
244 252
 
245 253
 cmDspInst_t*  _cmDspTimeLineAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
246 254
 {
247 255
   cmDspVarArg_t args[] =
248 256
   {
249
-    { "val",  kValTlId,  0, 0, kInDsvFl  | kOutDsvFl    | kStrzDsvFl | kReqArgDsvFl | kSendDfltDsvFl,  "Current string"},
250
-    { "lbl",  kLblTlId,  0, 0, kStrzDsvFl | kOptArgDsvFl, "Label"},
257
+    { "tlfile",  kTlFileTlId,    0, 0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl,   "Time line file." },
258
+    { "path",    kAudPathTlId,   0, 0, kInDsvFl   | kStrzDsvFl | kReqArgDsvFl,   "Audio path"    },
259
+    { "sel",     kSelTlId,       0, 0, kInDsvFl   | kInDsvFl   | kOutDsvFl  | kUIntDsvFl,   "Selected marker id."},
260
+    { "afn",     kAudFnTlId,     0, 0, kOutDsvFl  | kStrzDsvFl,   "Selected Audio file." },
261
+    { "bsi",     kBegSmpIdxTlId, 0, 0, kOutDsvFl  | kUIntDsvFl,   "Begin audio sample index."},
262
+    { "esi",     kEndSmpIdxTlId, 0, 0, kOutDsvFl  | kUIntDsvFl,   "End audio sample index."},
251 263
     { NULL, 0, 0, 0, 0 }
252 264
   };
253 265
 
254 266
   cmDspTimeLine_t* p = cmDspInstAlloc(cmDspTimeLine_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
267
+  
268
+  cmDspSetDefaultUInt(  ctx, &p->inst,  kSelTlId,       0, cmInvalidId);
269
+  cmDspSetDefaultStrcz( ctx, &p->inst,  kAudFnTlId,     NULL, "");
270
+  cmDspSetDefaultUInt(  ctx, &p->inst,  kBegSmpIdxTlId, 0, cmInvalidIdx);
271
+  cmDspSetDefaultUInt(  ctx, &p->inst,  kEndSmpIdxTlId, 0, cmInvalidIdx);
255 272
 
256 273
   // create the UI control
257
-  cmDspUiTimeLineCreate(ctx,&p->inst,kValTlId,kLblTlId,kTlFileTlId,kAudPathTlId);
274
+  cmDspUiTimeLineCreate(ctx,&p->inst,kTlFileTlId,kAudPathTlId,kSelTlId);
275
+
276
+  p->tlH = cmTimeLineNullHandle;
258 277
 
259 278
   return &p->inst;
260 279
 }
261 280
 
281
+cmDspRC_t _cmDspTimeLineFree(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
282
+{
283
+  cmDspRC_t        rc = kOkDspRC;
284
+  cmDspTimeLine_t* p = (cmDspTimeLine_t*)inst;
285
+
286
+  if( cmTimeLineFinalize(&p->tlH) != kOkTlRC )
287
+    return cmErrMsg(&inst->classPtr->err, kInstFinalFailDspRC, "Time-line finalize failed.");
288
+
289
+  return rc;
290
+}
291
+
292
+
262 293
 cmDspRC_t _cmDspTimeLineReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
263 294
 {
295
+  cmDspRC_t        rc = kOkDspRC;
296
+  cmDspTimeLine_t* p  = (cmDspTimeLine_t*)inst;
297
+
264 298
   cmDspApplyAllDefaults(ctx,inst);
265
-  return kOkDspRC;
299
+
300
+  const cmChar_t* tlFn;
301
+  if((tlFn =  cmDspStrcz(inst, kTlFileTlId )) !=  NULL )
302
+    if( cmTimeLineInitializeFromFile(ctx->cmCtx, &p->tlH, NULL, NULL, tlFn ) != kOkTlRC )
303
+      rc = cmErrMsg(&inst->classPtr->err, kInstResetFailDspRC, "Time-line file open failed.");
304
+
305
+  return rc;
266 306
 }
267 307
 
268 308
 cmDspRC_t _cmDspTimeLineRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
@@ -270,8 +310,9 @@ cmDspRC_t _cmDspTimeLineRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
270 310
 
271 311
   switch( evt->dstVarId )
272 312
   {
273
-    case kValTlId:
313
+    case kSelTlId:
274 314
       cmDspSetEvent(ctx,inst,evt);
315
+      
275 316
       break;
276 317
 
277 318
     default:
@@ -286,7 +327,7 @@ struct cmDspClass_str* cmTimeLineClassCons( cmDspCtx_t* ctx )
286 327
   cmDspClassSetup(&_cmTimeLineDC,ctx,"TimeLine",
287 328
     NULL,
288 329
     _cmDspTimeLineAlloc,
289
-    NULL,
330
+    _cmDspTimeLineFree,
290 331
     _cmDspTimeLineReset,
291 332
     NULL,
292 333
     _cmDspTimeLineRecv,

+ 6
- 3
dsp/cmDspPgmKr.c Прегледај датотеку

@@ -36,16 +36,19 @@
36 36
 
37 37
 cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
38 38
 {
39
-  cmDspRC_t rc = kOkDspRC;
39
+  cmDspRC_t       rc      = kOkDspRC;
40
+  const cmChar_t* tlFn    = "/home/kevin/src/cmgv/src/gv/data/tl7.js";
41
+  const cmChar_t* audPath = "/home/kevin/media/audio/20110723-Kriesberg/Audio Files";
40 42
 
41
-  cmDspInst_t* tlp = cmDspSysAllocInst(h,"TimeLine",   "text",      1, "Hello" );
43
+  cmDspInst_t* tlp = cmDspSysAllocInst(h,"TimeLine",   "tl",  2, tlFn, audPath );
42 44
   cmDspInst_t* prp = cmDspSysAllocInst(h,"Printer", NULL,   1, ">" );
43 45
   
44 46
   if((rc = cmDspSysLastRC(h)) != kOkDspRC )
45 47
     return rc;
46 48
 
47 49
   
48
-  cmDspSysInstallCb(h, tlp, "val", prp, "in", NULL );
50
+  cmDspSysInstallCb(h, tlp, "afn", prp, "in", NULL );
51
+  cmDspSysInstallCb(h, tlp, "sel", prp, "in", NULL );
49 52
 
50 53
   return rc;
51 54
 }

+ 5
- 5
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 valVarId, unsigned lblVarId, unsigned tlFileVarId, unsigned audPathVarId )
364
+cmDspRC_t  cmDspUiTimeLineCreate(   cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned tlFileVarId, unsigned audPathVarId, unsigned selVarId )
365 365
 {
366 366
   cmDspRC_t    rc;
367
-  unsigned     arr[] = { valVarId, lblVarId, tlFileVarId, audPathVarId  };
367
+  unsigned     arr[] = { tlFileVarId, audPathVarId, selVarId  };
368 368
   cmDspValue_t v;
369 369
   unsigned     vn    = sizeof(arr)/sizeof(arr[0]);
370 370
   cmDsvSetUIntMtx(&v,arr,vn,1);
@@ -374,14 +374,14 @@ cmDspRC_t  cmDspUiTimeLineCreate(   cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned
374 374
     return cmDspInstErr(ctx,inst,kUiEleCreateFailDspRC,"Time Line UI element create failed.");
375 375
 
376 376
   // use instance symbol as default label
377
-  if((rc = _cmDspUiUseInstSymbolAsLabel(ctx, inst, lblVarId, "TimeLine")) != kOkDspRC )
378
-    return rc;
377
+  //if((rc = _cmDspUiUseInstSymbolAsLabel(ctx, inst, lblVarId, "TimeLine")) != kOkDspRC )
378
+  //  return rc;
379 379
 
380 380
   // Set the kUiDsvFl on the variables used for the min/max/def/val for this scalar
381 381
   // Setting this flag will cause their values to be sent to the UI whenever they change.
382
-  cmDspInstVarSetFlags( ctx, inst, valVarId,     kUiDsvFl );
383 382
   cmDspInstVarSetFlags( ctx, inst, tlFileVarId,  kUiDsvFl );
384 383
   cmDspInstVarSetFlags( ctx, inst, audPathVarId, kUiDsvFl );
384
+  cmDspInstVarSetFlags( ctx, inst, selVarId,     kUiDsvFl );
385 385
   return rc;
386 386
 }
387 387
 

Loading…
Откажи
Сачувај