Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames <olpc@localhost.localdomain>2007-01-25 08:40:00 (GMT)
committer James <olpc@localhost.localdomain>2007-01-25 08:40:00 (GMT)
commiteae4efe983b2aaf46338a6e2983f83ac5a3fe5f3 (patch)
tree3bb7df2a8ba597608ad386179bcb781d6503b259
parent0701b52b495c7a3aaf62ecc4eab52ca1ddae136f (diff)
SoundClient can disconnect, reconnect
-rw-r--r--Util/Clooper/SoundClient.cpp88
-rwxr-xr-xUtil/Clooper/_SClient.sobin158878 -> 158906 bytes
-rwxr-xr-xUtil/Clooper/_ttest.sobin39840 -> 39840 bytes
-rwxr-xr-xscripts/olpc_get_stuff.sh3
-rw-r--r--ttt.py14
5 files changed, 53 insertions, 52 deletions
diff --git a/Util/Clooper/SoundClient.cpp b/Util/Clooper/SoundClient.cpp
index ff6e061..9e39e6d 100644
--- a/Util/Clooper/SoundClient.cpp
+++ b/Util/Clooper/SoundClient.cpp
@@ -145,6 +145,7 @@ struct TamTamSound
{
void * ThreadID;
CSOUND * csound;
+ char * csound_orc;
enum {CONTINUE, STOP} PERF_STATUS;
int verbosity;
FILE * _debug;
@@ -153,32 +154,12 @@ struct TamTamSound
EvLoop * loop;
TamTamSound(char * orc)
- : ThreadID(NULL), PERF_STATUS(STOP), verbosity(3), _debug(NULL), thread_playloop(0), thread_measurelag(0), loop(NULL)
+ : ThreadID(NULL), csound(NULL), PERF_STATUS(STOP), verbosity(3), _debug(NULL), thread_playloop(0), thread_measurelag(0), loop(NULL)
{
_debug = fopen("debug.log", "w");
csound = csoundCreate(NULL);
- int argc = 2;
- char * prog = "fake_progname";
- char ** argv = (char **) malloc(argc * sizeof(char*));
- argv[0] = prog;
- argv[1] = orc;
-
- csoundInitialize(&argc, &argv, 0);
- int result = csoundCompile( csound, argc, argv);
- free(argv);
- if (!result)
- {
- //PERF_STATUS = CONTINUE;
- //ThreadID = csoundCreateThread(csThread, (void*)this);
- }
- else
- {
- fprintf(_debug, "ERROR: csoundCompile() returned %i\n", result);
- csoundDestroy(csound);
- csound = NULL;
- ThreadID = NULL;
- }
+ csound_orc = strdup(orc);
loop = new EvLoop(csound);
}
@@ -190,6 +171,7 @@ struct TamTamSound
delete loop;
csoundDestroy(csound);
}
+ free(csound_orc);
fclose(_debug);
}
static double pytime(const struct timeval * tv)
@@ -227,13 +209,51 @@ struct TamTamSound
}
++loops;
}
- csoundDestroy(csound);
- return 1;
+ return 0;
}
static uintptr_t csThread(void *clientData)
{
return ((TamTamSound*)clientData)->thread_fn();
}
+ void start()
+ {
+ if (!ThreadID)
+ {
+ int argc=3;
+ char **argv = (char**)malloc(argc*sizeof(char*));
+ argv[0] = "csound";
+ argv[1] ="-m0";
+ argv[2] = csound_orc;
+ fprintf(_debug, "loading file %s\n", csound_orc);
+
+ csoundInitialize(&argc, &argv, 0);
+ int result = csoundCompile(csound, argc, &(argv[0]));
+ free(argv);
+
+ if (!result)
+ {
+ PERF_STATUS = CONTINUE;
+ ThreadID = csoundCreateThread(csThread, (void*)this);
+ }
+ else
+ {
+ fprintf(_debug, "ERROR: failed to compile orchestra\n");
+ ThreadID = NULL;
+ }
+ }
+ }
+ void stop()
+ {
+ if (ThreadID)
+ {
+ PERF_STATUS = STOP;
+ if (verbosity > 0) fprintf(_debug, "INFO: stop()");
+ uintptr_t rval = csoundJoinThread(ThreadID);
+ if (rval) fprintf(_debug, "WARNING: thread returned %zu\n", rval);
+ ThreadID = NULL;
+ csoundReset(csound);
+ }
+ }
void scoreEvent(char type, MYFLT * p, int np)
{
@@ -314,26 +334,6 @@ struct TamTamSound
fprintf(_debug, "ERROR: failed to set master volume\n");
}
}
- void start()
- {
- if (!ThreadID)
- {
- PERF_STATUS = CONTINUE;
- ThreadID = csoundCreateThread(csThread, (void*)this);
- }
- }
- void stop()
- {
- if (ThreadID)
- {
- PERF_STATUS = STOP;
- if (verbosity > 0) fprintf(_debug, "INFO: stop()");
- uintptr_t rval = csoundJoinThread(ThreadID);
- if (rval) fprintf(stderr, "INFO: thread returned %zu\n", rval);
- ThreadID = NULL;
- csoundReset(csound);
- }
- }
};
diff --git a/Util/Clooper/_SClient.so b/Util/Clooper/_SClient.so
index a6a60ba..85fbd32 100755
--- a/Util/Clooper/_SClient.so
+++ b/Util/Clooper/_SClient.so
Binary files differ
diff --git a/Util/Clooper/_ttest.so b/Util/Clooper/_ttest.so
index 6b14ebe..2019799 100755
--- a/Util/Clooper/_ttest.so
+++ b/Util/Clooper/_ttest.so
Binary files differ
diff --git a/scripts/olpc_get_stuff.sh b/scripts/olpc_get_stuff.sh
index 9751900..a64189d 100755
--- a/scripts/olpc_get_stuff.sh
+++ b/scripts/olpc_get_stuff.sh
@@ -1,5 +1,6 @@
-yum install vim-common vim-enhanced screen git-core xterm fluxbox ctags irssi gcc make python-devel
+yum install vim-common vim-enhanced screen git-core xterm fluxbox ctags sox irssi
+yum install gcc make python-devel gcc-c++ csound-devel
if [ ! -f ~/.Xdefaults ] ; then
#use a legible xterm font
diff --git a/ttt.py b/ttt.py
index 8b5e4cf..6626136 100644
--- a/ttt.py
+++ b/ttt.py
@@ -42,12 +42,12 @@ if __name__ == "__main__":
while True:
i = raw_input()
- if i == 'w':
+ if i == 'w': # stop note
n = CSoundNote(0.0, 0, 1.0, 0.0, 1.0, 1.0, instrument = inst, decay=0.7)
n.playNow(1.0)
- elif i == 'q':
+ elif i == 'q': # quit
break
- elif i == 'b':
+ elif i == 'b': # generate and start a beat
sc_loop_setNumTicks( 4 * Config.TICKS_PER_BEAT)
sc_loop_clear()
sc_loop_setTickDuration(23.0)
@@ -57,16 +57,16 @@ if __name__ == "__main__":
sc_loop_setTick(sc_loop_getTick())
sc_loop_playing(1)
print 'playing true!'
- elif i == 's':
+ elif i == 's': # stop a beat
sc_loop_playing(0)
- elif i == 'u':
+ elif i == 'u': # start csound
sc_start()
load_instruments()
time.sleep(0.2)
sc_setMasterVolume(50.0)
- elif i == 'd':
+ elif i == 'd': # stop csound
sc_stop()
- else:
+ else: # play a sitar
n = CSoundNote(0.0, 24 + 4, 1.0, 0.0, -1.0, 1.0, instrument = inst)
n.playNow(1.0)