浏览代码

cmDspPgm.c : Added _cmDspSysPgm_RtRecord() to record in real-time to a file.

master
kevin 8 年前
父节点
当前提交
1091f308c6
共有 1 个文件被更改,包括 26 次插入0 次删除
  1. 26
    0
      dsp/cmDspPgm.c

+ 26
- 0
dsp/cmDspPgm.c 查看文件

@@ -627,6 +627,31 @@ cmDspRC_t _cmDspSysPgm_Record(cmDspSysH_t h, void** userPtrPtr)
627 627
 
628 628
 //------------------------------------------------------------------------------
629 629
 //)
630
+//( { label:cmDspPgm_FtRecord file_desc:"Record streaming audio input to an audio file." kw:[spgm] }
631
+cmDspRC_t _cmDspSysPgm_RtRecord(cmDspSysH_t h, void** userPtrPtr)
632
+{
633
+  cmDspInst_t* ai0   = cmDspSysAllocInst( h, "AudioIn", NULL,  1, 0 );
634
+  cmDspInst_t* ai1   = cmDspSysAllocInst( h, "AudioIn", NULL,  1, 1 );  
635
+  cmDspInst_t* afp   = cmDspSysAllocInst( h, "AudioFileOut", NULL,  2,"/Users/kevin/temp/test.aif",2);
636
+  
637
+  // AudioFileOut needs an open message to create the output file
638
+  cmDspInst_t* btn   = cmDspSysAllocInst( h, "Button",      "open",  2, kButtonDuiId, 1.0 );
639
+  cmDspSysAssignInstAttrSymbolStr(h, btn, "_reset" );
640
+  cmDspInst_t* pts = cmDspSysAllocInst(h,"PortToSym", NULL, 1, "open" );
641
+
642
+  
643
+  cmDspSysConnectAudio(h,ai0, "out", afp, "in0");
644
+  cmDspSysConnectAudio(h,ai1, "out", afp, "in1");
645
+
646
+  cmDspSysInstallCb( h, btn, "sym",  pts, "open", NULL );
647
+  cmDspSysInstallCb( h, pts, "open", afp, "sel",  NULL );
648
+
649
+  return kOkDspRC;
650
+}
651
+
652
+
653
+//------------------------------------------------------------------------------
654
+//)
630 655
 //( { label:cmDspPgm_PitchShift file_desc:"Pitch-shifter example program." kw:[spgm] }
631 656
 cmDspRC_t _cmDspSysPgm_PitchShiftFile( cmDspSysH_t h, void** userPtrPtr )
632 657
 {
@@ -3144,6 +3169,7 @@ _cmDspSysPgm_t _cmDspSysPgmArray[] =
3144 3169
   { "sine",        _cmDspSysPgm_PlaySine,       NULL, NULL },
3145 3170
   { "file",        _cmDspSysPgm_PlayFile,       NULL, NULL },
3146 3171
   { "gate_detect", _cmDspSysPgm_GateDetect,     NULL, NULL },
3172
+  { "rt_record",   _cmDspSysPgm_RtRecord,       NULL, NULL },
3147 3173
   { "record",      _cmDspSysPgm_Record,         NULL, NULL },
3148 3174
   { "pitch_shift", _cmDspSysPgm_PitchShiftFile, NULL, NULL },
3149 3175
   { "loop_recd",   _cmDspSysPgm_LoopRecd,       NULL, NULL },

正在加载...
取消
保存