Browse Source

cmDspPgm.c : Added _cmDspSysPgm_All_In_And_Out() and other minor changes to test Focusrite audio interface.

master
kevin.larke 4 years ago
parent
commit
d4af37682b
1 changed files with 56 additions and 7 deletions
  1. 56
    7
      dsp/cmDspPgm.c

+ 56
- 7
dsp/cmDspPgm.c View File

128
 {
128
 {
129
   
129
   
130
   cmDspRC_t rc = kOkDspRC;
130
   cmDspRC_t rc = kOkDspRC;
131
+
132
+
133
+  //const cmChar_t* deviceName = "Scarlett 18i20 USB";
134
+  //const cmChar_t* portName   = "Scarlett 18i20 USB MIDI 1";
135
+  
131
   const cmChar_t* deviceName = "Fastlane";
136
   const cmChar_t* deviceName = "Fastlane";
132
   const cmChar_t* portName   = "Fastlane MIDI A";
137
   const cmChar_t* portName   = "Fastlane MIDI A";
133
 
138
 
134
   //const cmChar_t* deviceName = "DKV-M4";
139
   //const cmChar_t* deviceName = "DKV-M4";
135
   //const cmChar_t* portName   = "DKV-M4 MIDI 1";
140
   //const cmChar_t* portName   = "DKV-M4 MIDI 1";
136
 
141
 
137
-  const char*     fn0   = "media/midi/kriesberg/part2/piano_score_part_2_draft_1_master_m191-195.mid";
142
+  const char*     fn0   = "media/audio/midi/988-v25.mid";
138
   const cmChar_t* fn    = cmFsMakeFn(cmFsUserDir(),fn0,NULL,NULL );
143
   const cmChar_t* fn    = cmFsMakeFn(cmFsUserDir(),fn0,NULL,NULL );
139
   cmDspInst_t* fnp =  cmDspSysAllocInst(h,"Fname",    NULL,  3, false,"MIDI Files (*.mid)\tMIDI Files (*.{mid})",fn);
144
   cmDspInst_t* fnp =  cmDspSysAllocInst(h,"Fname",    NULL,  3, false,"MIDI Files (*.mid)\tMIDI Files (*.{mid})",fn);
140
 
145
 
155
    
160
    
156
   cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 0 );
161
   cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 0 );
157
   cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 1 );
162
   cmDspInst_t* ao1p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 1 );
163
+  cmDspInst_t* ao2p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 2 );
164
+  cmDspInst_t* ao3p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 3 );
158
 
165
 
159
   cmDspInst_t* im0p = cmDspSysAllocInst(h,"AMeter","In 0",  0);
166
   cmDspInst_t* im0p = cmDspSysAllocInst(h,"AMeter","In 0",  0);
160
   cmDspInst_t* im1p = cmDspSysAllocInst(h,"AMeter","In 1", 0);
167
   cmDspInst_t* im1p = cmDspSysAllocInst(h,"AMeter","In 1", 0);
161
 
168
 
162
   cmDspInst_t* om0p = cmDspSysAllocInst(h,"AMeter","Out 0", 0);
169
   cmDspInst_t* om0p = cmDspSysAllocInst(h,"AMeter","Out 0", 0);
163
   cmDspInst_t* om1p = cmDspSysAllocInst(h,"AMeter","Out 1",0);
170
   cmDspInst_t* om1p = cmDspSysAllocInst(h,"AMeter","Out 1",0);
171
+  cmDspInst_t* om2p = cmDspSysAllocInst(h,"AMeter","Out 2", 0);
172
+  cmDspInst_t* om3p = cmDspSysAllocInst(h,"AMeter","Out 3",0);
164
 
173
 
165
 
174
 
166
   // check for allocation errors
175
   // check for allocation errors
199
   cmDspSysConnectAudio(h, ai1p,"out", ao1p, "in" );         // ain1  -> aout1 
208
   cmDspSysConnectAudio(h, ai1p,"out", ao1p, "in" );         // ain1  -> aout1 
200
   cmDspSysConnectAudio(h, ai1p,"out", om1p, "in" );         // ain1  -> omtr1 
209
   cmDspSysConnectAudio(h, ai1p,"out", om1p, "in" );         // ain1  -> omtr1 
201
 
210
 
211
+  cmDspSysConnectAudio(h, ai0p,"out", ao2p, "in" );         // ain0  -> aout2 
212
+  cmDspSysConnectAudio(h, ai0p,"out", om2p, "in" );         // ain0  -> omtr0
213
+  
214
+  cmDspSysConnectAudio(h, ai1p,"out", ao3p, "in" );         // ain1  -> aout3 
215
+  cmDspSysConnectAudio(h, ai1p,"out", om3p, "in" );         // ain0  -> omtr0 
216
+  
202
  errLabel:
217
  errLabel:
203
 
218
 
204
   cmFsFreeFn(fn);
219
   cmFsFreeFn(fn);
348
   cmDspInst_t* php =  cmDspSysAllocInst(h,"Phasor",   NULL,  0 );
363
   cmDspInst_t* php =  cmDspSysAllocInst(h,"Phasor",   NULL,  0 );
349
   cmDspInst_t* wtp =  cmDspSysAllocInst(h,"WaveTable",NULL,  2, cmDspSysSampleRate(h), 2 );
364
   cmDspInst_t* wtp =  cmDspSysAllocInst(h,"WaveTable",NULL,  2, cmDspSysSampleRate(h), 2 );
350
 
365
 
351
-  cmDspInst_t* ai0p = cmDspSysAllocInst(h,"AudioIn", NULL,   1, 0 );
352
-  cmDspInst_t* ai1p = cmDspSysAllocInst(h,"AudioIn", NULL,   1, 1 );
366
+  cmDspInst_t* ai0p = cmDspSysAllocInst(h,"AudioIn", NULL,   1, 2 );
367
+  cmDspInst_t* ai1p = cmDspSysAllocInst(h,"AudioIn", NULL,   1, 3 );
353
    
368
    
354
   // MOTU Traveler: Use channels 2&3 (out plugs:3&4) because 0&1 do not show up on plugs 1&2.
369
   // MOTU Traveler: Use channels 2&3 (out plugs:3&4) because 0&1 do not show up on plugs 1&2.
355
   cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 2 );
370
   cmDspInst_t* ao0p = cmDspSysAllocInst(h,"AudioOut",NULL,   1, 2 );
387
   return kOkDspRC;
402
   return kOkDspRC;
388
 }
403
 }
389
 
404
 
405
+
406
+cmDspRC_t _cmDspSysPgm_All_In_And_Out( cmDspSysH_t h, void** userPtrPtr )
407
+{
408
+  cmDspInst_t* ignp = cmDspSysAllocInst( h,"Scalar", "In Gain",  5, kNumberDuiId, 0.0,  4.0, 0.01,  1.0);
409
+
410
+  const unsigned inN = 18;
411
+
412
+  cmDspInst_t* ainA[inN];
413
+  cmDspInst_t* aoutA[inN];
414
+  cmDspInst_t* imtrA[inN];
415
+  
416
+  int i;
417
+  for(i=0;i<inN; ++i)
418
+  {
419
+    char label[32];
420
+    snprintf(label,32,"in %i",i);
421
+    ainA[i]  = cmDspSysAllocInst(h,"AudioIn", NULL,   1, i );
422
+    imtrA[i] = cmDspSysAllocInst(h,"AMeter",label,  0);
423
+    aoutA[i]  = cmDspSysAllocInst(h,"AudioOut", NULL,   1, i );
424
+  }
425
+
426
+  for(i=0; i<inN; ++i)
427
+  {
428
+    cmDspSysInstallCb(   h, ignp,   "val", ainA[i], "gain", NULL);  // igain -> ain
429
+    cmDspSysConnectAudio(h, ainA[i],"out", imtrA[i], "in" );         // ain  -> imtr 
430
+    cmDspSysConnectAudio(h, ainA[i],"out", aoutA[i], "in" );         // ain  -> aout 
431
+  }
432
+
433
+
434
+  return kOkDspRC;
435
+}
436
+
437
+
390
 //------------------------------------------------------------------------------
438
 //------------------------------------------------------------------------------
391
 //)
439
 //)
392
 //( { label:cmDspPgm_Stereo_Fx file_desc:"Stereo audio effects example program." kw:[spgm] }
440
 //( { label:cmDspPgm_Stereo_Fx file_desc:"Stereo audio effects example program." kw:[spgm] }
463
 //( { label:cmDspPgm_PlaySine file_desc:"Play a sine signal." kw:[spgm] }
511
 //( { label:cmDspPgm_PlaySine file_desc:"Play a sine signal." kw:[spgm] }
464
 cmDspRC_t _cmDspSysPgm_PlaySine( cmDspSysH_t h, void** userPtrPtr )
512
 cmDspRC_t _cmDspSysPgm_PlaySine( cmDspSysH_t h, void** userPtrPtr )
465
 {
513
 {
466
-  bool useBuiltInFl = true;
514
+  bool useBuiltInFl = false;
467
   double frqHz = 440.0;
515
   double frqHz = 440.0;
468
 
516
 
469
   cmDspInst_t* chp = cmDspSysAllocInst( h,"Scalar", "Channel",  5, kNumberDuiId, 0.0,  100.0, 1.0,  0.0);
517
   cmDspInst_t* chp = cmDspSysAllocInst( h,"Scalar", "Channel",  5, kNumberDuiId, 0.0,  100.0, 1.0,  0.0);
867
 cmDspRC_t _cmDspSysPgm_Xfade( cmDspSysH_t h, void** userPtrPtr )
915
 cmDspRC_t _cmDspSysPgm_Xfade( cmDspSysH_t h, void** userPtrPtr )
868
 {
916
 {
869
   cmDspRC_t rc         = kOkDspRC;
917
   cmDspRC_t rc         = kOkDspRC;
870
-  unsigned  leftChIdx  = 0;
871
-  unsigned  rightChIdx = 1;
918
+  unsigned  leftChIdx  = 2;
919
+  unsigned  rightChIdx = 3;
872
   unsigned  chCnt      = 2;
920
   unsigned  chCnt      = 2;
873
   double    xfadeMs    = 1000;  // cross fade time
921
   double    xfadeMs    = 1000;  // cross fade time
874
   double    sgHz       = 500;
922
   double    sgHz       = 500;
3208
 _cmDspSysPgm_t _cmDspSysPgmArray[] = 
3256
 _cmDspSysPgm_t _cmDspSysPgmArray[] = 
3209
 {
3257
 {
3210
   { "reflect",       _cmDspSysPgm_ReflectCalc,  NULL, NULL },
3258
   { "reflect",       _cmDspSysPgm_ReflectCalc,  NULL, NULL },
3211
-  { "tksblite",     _cmDspSysPgm_TksbLite,     NULL, NULL }, 
3259
+  { "tksblite",      _cmDspSysPgm_TksbLite,     NULL, NULL }, 
3212
   { "tksb",          _cmDspSysPgm_Tksb,         NULL, NULL },
3260
   { "tksb",          _cmDspSysPgm_Tksb,         NULL, NULL },
3213
   { "time_line",     _cmDspSysPgm_TimeLine,     NULL, NULL },
3261
   { "time_line",     _cmDspSysPgm_TimeLine,     NULL, NULL },
3214
   { "time_line_lite",_cmDspSysPgm_TimeLineLite, NULL, NULL },  
3262
   { "time_line_lite",_cmDspSysPgm_TimeLineLite, NULL, NULL },  
3244
   { "pedal_test",  _cmDspSysPgm_Test_Pedals,    NULL, NULL },
3292
   { "pedal_test",  _cmDspSysPgm_Test_Pedals,    NULL, NULL },
3245
   { "midi_file",   _cmDspSysPgm_MidiFilePlay,   NULL, NULL },
3293
   { "midi_file",   _cmDspSysPgm_MidiFilePlay,   NULL, NULL },
3246
   { "2_thru",      _cmDspSysPgm_Stereo_Through, NULL, NULL },
3294
   { "2_thru",      _cmDspSysPgm_Stereo_Through, NULL, NULL },
3295
+  { "all_in_out",  _cmDspSysPgm_All_In_And_Out, NULL, NULL },
3247
   { "guitar",      _cmDspSysPgmGuitar,          NULL, NULL },
3296
   { "guitar",      _cmDspSysPgmGuitar,          NULL, NULL },
3248
   { "2_fx",        _cmDspSysPgm_Stereo_Fx,      NULL, NULL },
3297
   { "2_fx",        _cmDspSysPgm_Stereo_Fx,      NULL, NULL },
3249
   { "sine",        _cmDspSysPgm_PlaySine,       NULL, NULL },
3298
   { "sine",        _cmDspSysPgm_PlaySine,       NULL, NULL },

Loading…
Cancel
Save