diff options
author | James <olpc@localhost.localdomain> | 2007-01-28 01:37:58 (GMT) |
---|---|---|
committer | James <olpc@localhost.localdomain> | 2007-01-28 01:37:58 (GMT) |
commit | b3fd3b66290e1ad90ed3898eb3e81366117c87c4 (patch) | |
tree | 79bcecd184d41e7023fb3bf029acfedd0e74991d /Util/Clooper | |
parent | 386917bb06f058b013f1644541aa00f5dd6e4984 (diff) |
simplified sclient interface
Diffstat (limited to 'Util/Clooper')
-rw-r--r-- | Util/Clooper/SClient.py | 9 | ||||
-rw-r--r-- | Util/Clooper/SoundClient.cpp | 99 | ||||
-rw-r--r-- | Util/Clooper/SoundClient.h | 9 | ||||
-rwxr-xr-x | Util/Clooper/_SClient.so | bin | 158906 -> 156976 bytes | |||
-rw-r--r-- | Util/Clooper/cmd_csound.cpp | 2 |
5 files changed, 53 insertions, 66 deletions
diff --git a/Util/Clooper/SClient.py b/Util/Clooper/SClient.py index 6ca740c..5171569 100644 --- a/Util/Clooper/SClient.py +++ b/Util/Clooper/SClient.py @@ -50,13 +50,12 @@ del types sc_destroy = _SClient.sc_destroy sc_initialize = _SClient.sc_initialize -sc_instrumentLoad = _SClient.sc_instrumentLoad -sc_instrumentUnloadBatch = _SClient.sc_instrumentUnloadBatch -sc_micRecord = _SClient.sc_micRecord -sc_setMasterVolume = _SClient.sc_setMasterVolume -sc_scoreEvent15 = _SClient.sc_scoreEvent15 sc_start = _SClient.sc_start sc_stop = _SClient.sc_stop +sc_setMasterVolume = _SClient.sc_setMasterVolume +sc_inputMessage = _SClient.sc_inputMessage +sc_scoreEvent4 = _SClient.sc_scoreEvent4 +sc_scoreEvent15 = _SClient.sc_scoreEvent15 sc_loop_addScoreEvent15 = _SClient.sc_loop_addScoreEvent15 sc_loop_clear = _SClient.sc_loop_clear sc_loop_getTick = _SClient.sc_loop_getTick diff --git a/Util/Clooper/SoundClient.cpp b/Util/Clooper/SoundClient.cpp index 9e39e6d..cbb51c0 100644 --- a/Util/Clooper/SoundClient.cpp +++ b/Util/Clooper/SoundClient.cpp @@ -215,7 +215,7 @@ struct TamTamSound { return ((TamTamSound*)clientData)->thread_fn(); } - void start() + int start() { if (!ThreadID) { @@ -234,15 +234,18 @@ struct TamTamSound { PERF_STATUS = CONTINUE; ThreadID = csoundCreateThread(csThread, (void*)this); + return 0; } else { fprintf(_debug, "ERROR: failed to compile orchestra\n"); ThreadID = NULL; + return 1; } } + return 1; } - void stop() + int stop() { if (ThreadID) { @@ -252,7 +255,9 @@ struct TamTamSound if (rval) fprintf(_debug, "WARNING: thread returned %zu\n", rval); ThreadID = NULL; csoundReset(csound); + return 0; } + return 1; } void scoreEvent(char type, MYFLT * p, int np) @@ -270,26 +275,6 @@ struct TamTamSound } csoundScoreEvent(csound, type, p, np); } - void scoreEvent(char type, MYFLT p1, MYFLT p2, MYFLT p3, MYFLT p4, MYFLT p5, MYFLT p6, MYFLT p7, MYFLT p8, MYFLT p9, MYFLT p10, MYFLT p11, MYFLT p12, MYFLT p13, MYFLT p14, MYFLT p15) - { - MYFLT p[15]; - p[0] = p1; - p[1] = p2; - p[2] = p3; - p[3] = p4; - p[4] = p5; - p[5] = p6; - p[6] = p7; - p[7] = p8; - p[8] = p9; - p[9] = p10; - p[10] = p11; - p[11] = p12; - p[12] = p13; - p[13] = p14; - p[14] = p15; - scoreEvent(type, p, 15); - } void inputMessage(const char * msg) { if (!csound) @@ -305,25 +290,6 @@ struct TamTamSound return csound != NULL; } - - void instrumentLoad(int table, const char * fname) - { - char str[512]; - sprintf(str, "f%d 0 0 -1 \"%s\" 0 0 0", table, fname); - inputMessage(str); - } - void instrumentUnloadBatch(int count) - { - MYFLT p[4] = {5000.0, 0.0, 0.1, 0.0}; - p[3] = (MYFLT) count; - scoreEvent('i', p, 4); - } - void micRecord(int table) - { - MYFLT p[4] = {5201.0, 0.0, 5.0, 0.0}; - p[3] = (MYFLT) table; - scoreEvent('i', p, 4); - } void setMasterVolume(MYFLT vol) { MYFLT *p; @@ -339,44 +305,67 @@ struct TamTamSound TamTamSound * sc_tt = NULL; +//call once at startup, should return 0 int sc_initialize(char * csd) { sc_tt = new TamTamSound(csd); if (sc_tt->good()) return 0; else return -1; } +//call once at end void sc_destroy() { delete sc_tt; sc_tt = NULL; } -void sc_instrumentLoad(int table, const char * fname) -{ - sc_tt->instrumentLoad(table, fname); -} -void sc_instrumentUnloadBatch(int count) +//compile the score, connect to device, start a sound rendering thread +int sc_start() { - sc_tt->instrumentUnloadBatch(count); + return sc_tt->start(); } -void sc_micRecord(int table) +//stop csound rendering thread, disconnect from sound device, clear tables. +int sc_stop() { - sc_tt->micRecord(table); + return sc_tt->stop(); } +//set the output volume to given level. max volume is 100.0 void sc_setMasterVolume(double v) { sc_tt->setMasterVolume(v); } -void sc_scoreEvent15(char type, MYFLT p1, MYFLT p2, MYFLT p3, MYFLT p4, MYFLT p5, MYFLT p6, MYFLT p7, MYFLT p8, MYFLT p9, MYFLT p10, MYFLT p11, MYFLT p12, MYFLT p13, MYFLT p14, MYFLT p15) + +void sc_inputMessage(const char *msg) { - sc_tt->scoreEvent(type, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); + sc_tt->inputMessage(msg); } -void sc_start() +void sc_scoreEvent4(char type, MYFLT p0, MYFLT p1, MYFLT p2, MYFLT p3) { - sc_tt->start(); + MYFLT p[4]; + p[0] = p0; + p[1] = p1; + p[2] = p2; + p[3] = p3; + sc_tt->scoreEvent(type, p, 4); } -void sc_stop() +void sc_scoreEvent15(char type, MYFLT p1, MYFLT p2, MYFLT p3, MYFLT p4, MYFLT p5, MYFLT p6, MYFLT p7, MYFLT p8, MYFLT p9, MYFLT p10, MYFLT p11, MYFLT p12, MYFLT p13, MYFLT p14, MYFLT p15) { - sc_tt->stop(); + MYFLT p[15]; + p[0] = p1; + p[1] = p2; + p[2] = p3; + p[3] = p4; + p[4] = p5; + p[5] = p6; + p[6] = p7; + p[7] = p8; + p[8] = p9; + p[9] = p10; + p[10] = p11; + p[11] = p12; + p[12] = p13; + p[13] = p14; + p[14] = p15; + sc_tt->scoreEvent(type, p, 15); } int sc_loop_getTick() diff --git a/Util/Clooper/SoundClient.h b/Util/Clooper/SoundClient.h index eb535d7..fd1b4bd 100644 --- a/Util/Clooper/SoundClient.h +++ b/Util/Clooper/SoundClient.h @@ -10,13 +10,12 @@ extern "C" #endif void sc_destroy(); int sc_initialize(char * csd); - void sc_instrumentLoad(int, const char *); - void sc_instrumentUnloadBatch(int); - void sc_micRecord(int); + int sc_start(); + int sc_stop(); void sc_setMasterVolume(double); + void sc_inputMessage(const char *msg); + void sc_scoreEvent4(char type, MYFLT p0, MYFLT p1, MYFLT p2, MYFLT p3); void sc_scoreEvent15(char type, MYFLT p1, MYFLT p2, MYFLT p3, MYFLT p4, MYFLT p5, MYFLT p6, MYFLT p7, MYFLT p8, MYFLT p9, MYFLT p10, MYFLT p11, MYFLT p12, MYFLT p13, MYFLT p14, MYFLT p15); - void sc_start(); - void sc_stop(); void sc_loop_addScoreEvent15(char type, MYFLT p1, MYFLT p2, MYFLT p3, MYFLT p4, MYFLT p5, MYFLT p6, MYFLT p7, MYFLT p8, MYFLT p9, MYFLT p10, MYFLT p11, MYFLT p12, MYFLT p13, MYFLT p14, MYFLT p15); void sc_loop_clear(); diff --git a/Util/Clooper/_SClient.so b/Util/Clooper/_SClient.so Binary files differindex 85fbd32..8336364 100755 --- a/Util/Clooper/_SClient.so +++ b/Util/Clooper/_SClient.so diff --git a/Util/Clooper/cmd_csound.cpp b/Util/Clooper/cmd_csound.cpp index 5a0ca63..ef94f84 100644 --- a/Util/Clooper/cmd_csound.cpp +++ b/Util/Clooper/cmd_csound.cpp @@ -14,7 +14,7 @@ int main( int argc, char ** argv) { fprintf(stderr, "Enter a pitch\n"); scanf("%i", &userInput); - sc_instrumentLoad(5083, "/home/olpc/tamtam/Resources/Sounds/sitar"); + //sc_instrumentLoad(5083, "/home/olpc/tamtam/Resources/Sounds/sitar"); scanf("%i", &userInput); } |