From d0c6741b655ea2166597dc2a45b8030e2a02d39d Mon Sep 17 00:00:00 2001 From: kpl_harpo Date: Mon, 17 Mar 2014 11:55:25 -0400 Subject: [PATCH] cmDspPgm.c : Added _cmDspSysPgm_MultiOut() and _cmDspSysPgm_MultiIn(). --- dsp/cmDspPgm.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/dsp/cmDspPgm.c b/dsp/cmDspPgm.c index 5b31c81..b601849 100644 --- a/dsp/cmDspPgm.c +++ b/dsp/cmDspPgm.c @@ -291,6 +291,98 @@ cmDspRC_t _cmDspSysPgm_PlayFile( cmDspSysH_t h, void** userPtrPtr ) } +cmDspRC_t _cmDspSysPgm_MultiOut( cmDspSysH_t h, void** userPtrPtr ) +{ + cmDspRC_t rc = kOkDspRC; + double frqHz = 440.0; + unsigned chCnt = 8; + unsigned oneOfN_chCnt = 2; + double offs = 34612504; + cmDspInst_t* aout[chCnt]; + unsigned i; + + const char* fn0 = "media/audio/20110723-Kriesberg/Audio Files/Piano 3_23.wav"; + const cmChar_t* fn = cmFsMakeFn(cmFsUserDir(),fn0,NULL,NULL ); + + cmDspInst_t* f_phs = cmDspSysAllocInst(h,"Phasor", NULL, 0 ); + cmDspInst_t* f_wt = cmDspSysAllocInst(h,"WaveTable",NULL, 2, ((int)cmDspSysSampleRate(h)), 1 ); + cmDspInst_t* f_mtr = cmDspSysAllocInst(h,"AMeter", "File Out", 0); + + cmDspInst_t* f_rew = cmDspSysAllocInst(h,"Button", "Rewind", 2, kButtonDuiId, 1.0 ); + cmDspInst_t* f_pts = cmDspSysAllocInst(h,"PortToSym", NULL, 1, "on" ); + cmDspInst_t* f_beg = cmDspSysAllocInst(h,"Scalar", "File Begin", 5, kNumberDuiId, 0.0, cmDspSysSampleRate(h)*6000.0, 1.0, offs); + cmDspInst_t* f_nam = cmDspSysAllocInst(h,"Fname", NULL, 3, false,"Audio Files (*.wav,*.aiff,*.aif)\tAudio Files (*.{wav,aiff,aif})",fn); + + + cmDspInst_t* s_phs = cmDspSysAllocInst(h,"Phasor", NULL, 2, cmDspSysSampleRate(h), frqHz ); + cmDspInst_t* s_wt = cmDspSysAllocInst(h,"WaveTable", NULL, 2, ((int)cmDspSysSampleRate(h)), 4); + cmDspInst_t* s_mtr = cmDspSysAllocInst(h,"AMeter", "Tone Out", 0); + + cmDspInst_t* swtch = cmDspSysAllocInst(h,"1ofN", NULL, 2, oneOfN_chCnt, 0 ); + + for(i=0; i wave table + cmDspSysConnectAudio( h, s_wt, "out", s_mtr, "in" ); // sine wave table -> meter + cmDspSysConnectAudio( h, s_wt, "out", swtch, "a-in-1"); + + cmDspSysConnectAudio( h, f_phs, "out", f_wt, "phs" ); // file phasor -> wave table + cmDspSysConnectAudio( h, f_wt, "out", f_mtr, "in" ); // file wave table -> meter + cmDspSysConnectAudio( h, f_wt, "out", swtch, "a-in-0"); + + cmDspSysConnectAudio11N1( h, swtch, "a-out", aout, "in", chCnt ); + cmDspSysInstallCbN1N1( h, vol, "val", aout, "gain", chCnt ); + + cmDspSysInstallCb( h, chck, "out", swtch, "chidx", NULL ); + cmDspSysInstallCb( h, f_nam, "out", f_wt, "fn", NULL ); + cmDspSysInstallCb( h, f_beg, "val", f_wt, "beg", NULL ); + cmDspSysInstallCb( h, f_rew, "out", f_pts, "on", NULL ); + cmDspSysInstallCb( h, f_pts, "on", f_beg, "send", NULL ); + cmDspSysInstallCb( h, f_pts, "on", f_nam, "send", NULL ); + cmDspSysInstallCb( h, f_pts, "on", f_wt, "cmd", NULL ); + + errLabel: + return rc; +} + +cmDspRC_t _cmDspSysPgm_MultiIn(cmDspSysH_t h, void** userPtrPtr) +{ + int chCnt = 8; + cmDspInst_t* a[chCnt]; + int i; + for(i=0; i