summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8>2006-12-05 13:20:47 (GMT)
committer jaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8>2006-12-05 13:20:47 (GMT)
commitf2f50337c1a67eb7f0584b9afd7b1ff1e33fe4c8 (patch)
tree82be97b974a5ab1b67a00804b98f9b5eb7e99efd
parentcd23076fffe4f75acd23f8fd8e9ea751f51e2b66 (diff)
jardin secret: interactivity accomplished
git-svn-id: svn://dyne.org/montevideo/ivysync@80 949728d9-16ea-0310-a75c-cbdf8430a4b8
-rw-r--r--branches/lydia/cmdline.cpp191
-rw-r--r--branches/lydia/parport.cpp4
-rw-r--r--branches/lydia/sndfile_decoder.cpp4
-rw-r--r--branches/lydia/sound_decoder.cpp28
-rw-r--r--branches/lydia/sound_decoder.h1
5 files changed, 156 insertions, 72 deletions
diff --git a/branches/lydia/cmdline.cpp b/branches/lydia/cmdline.cpp
index 4a3051c..1a37fe4 100644
--- a/branches/lydia/cmdline.cpp
+++ b/branches/lydia/cmdline.cpp
@@ -1,7 +1,7 @@
/* IvySync - Video SyncStarter
*
- * (c) Copyright 2004-2006 Denis Roio aka jaromil <jaromil@dyne.org>
+ * (c) Copyright 2004-2006 Denis Rojo aka jaromil <jaromil@dyne.org>
* Nederlands Instituut voor Mediakunst
*
* This source code is free software; you can redistribute it and/or
@@ -74,6 +74,23 @@ IvySyncDaemon *ivydaemon = NULL;
// Parallel port controller
ParPort *parport = NULL;
+
+// hardcoded movie offset positions
+class Offset {
+public:
+ Offset(int f, int b, int e) {
+ fogstart = f;
+ black = b;
+ enddrama = e;
+ }
+ ~Offset() { };
+ int fogstart;
+ int black;
+ int enddrama;
+};
+Offset *minidrama[5];
+
+
char *help =
"Usage: ivysync [-hsDgt] [ -d /dev/video16 [ -p playmode files ] ]\n"
" -h --help show this help\n"
@@ -88,16 +105,16 @@ char *help =
char *short_options = "-hd:sb:x:p:gtD:";
const struct option long_options[] = {
- { "help", no_argument, NULL, 'h'},
- { "device", required_argument, NULL, 'd'},
- { "scan", no_argument, NULL, 's'},
- { "buffer", required_argument, NULL, 'b'},
- { "xmlrpc", required_argument, NULL, 'x'},
- { "playmode", required_argument, NULL, 'p'},
- { "gui", no_argument, NULL, 'g'},
- { "test", no_argument, NULL, 't'},
- { "debug", required_argument, NULL, 'D'},
- {0, 0, 0, 0}
+{ "help", no_argument, NULL, 'h'},
+{ "device", required_argument, NULL, 'd'},
+{ "scan", no_argument, NULL, 's'},
+{ "buffer", required_argument, NULL, 'b'},
+{ "xmlrpc", required_argument, NULL, 'x'},
+{ "playmode", required_argument, NULL, 'p'},
+{ "gui", no_argument, NULL, 'g'},
+{ "test", no_argument, NULL, 't'},
+{ "debug", required_argument, NULL, 'D'},
+{0, 0, 0, 0}
};
@@ -136,43 +153,43 @@ int cmdline(int argc, char **argv) {
FILE *fd = NULL;
int c;
int res;
-
+
N("IvySync 0.3 / (c)2004-2006 Denis Rojo <jaromil@dyne.org>");
-
+
do {
- res = getopt_long(argc, argv, short_options, long_options, NULL);
-
- switch(res) {
+ res = getopt_long(argc, argv, short_options, long_options, NULL);
- case 'h':
- fprintf(stderr,"%s",help);
- exit(1);
- break;
-
- case 'd':
- dec = new Decoder();
- dec->dummy = dummytest;
- if( dec->init(optarg) )
- decoders.append( dec );
- else {
- E("can't initialize device %s",optarg);
- delete dec;
- dec = NULL;
- }
- break;
-
- case 's':
- N("Scanning for available playback devices...");
- dec = new Decoder();
- c=0;
-
- if( dec->init("/dev/video16") ) {
- A("1. /dev/video16 is present");
- c++;
- }
- dec->close();
-
-
+ switch(res) {
+
+ case 'h':
+ fprintf(stderr,"%s",help);
+ exit(1);
+ break;
+
+ case 'd':
+ dec = new Decoder();
+ dec->dummy = dummytest;
+ if( dec->init(optarg) )
+ decoders.append( dec );
+ else {
+ E("can't initialize device %s",optarg);
+ delete dec;
+ dec = NULL;
+ }
+ break;
+
+ case 's':
+ N("Scanning for available playback devices...");
+ dec = new Decoder();
+ c=0;
+
+ if( dec->init("/dev/video16") ) {
+ A("1. /dev/video16 is present");
+ c++;
+ }
+ dec->close();
+
+
if( dec->init("/dev/video17") ) {
A("2. /dev/video17 is present");
c++;
@@ -377,7 +394,13 @@ int main(int argc, char **argv) {
parport->light(false);
parport->launch();
-
+ /////////////////////////////////
+ // video files minidrama offsets
+ minidrama[0] = new Offset(1750, 1950, 3200);
+ minidrama[1] = new Offset(4680, 4880, 5560);
+ minidrama[2] = new Offset(6955, 7140, 7900);
+ minidrama[3] = new Offset(9460, 9610, 9990);
+ minidrama[4] = new Offset(10380, 10520, 11170);
////////////////////////////////
@@ -408,42 +431,94 @@ int main(int argc, char **argv) {
}
syncstart = 1;
- ////////////////////////////////
+ //////////////////////////////////////
+ // live interactive part while playing
+ int c, off;
+ bool trigger;
+ int interval = 100;
+ static bool syncer;
+
+ for( c=0; c<5; c++) { // cycle thru 5 minidramas
+ trigger = false;
+ dec = (Decoder*)decoders.begin();
+
+ do {
+ jsleep(0, interval);
+ off = dec->getoffset();
+ } while(off < minidrama[c]->fogstart);
+
+ A("fogstart of minidrama %u",c);
+
+ // fog start: reset button and play sound
+ parport->button_reset();
+ parport->light(true);
+ sndfile->replay = true;
+
+ do {
+ jsleep(0, interval);
+ off = dec->getoffset();
+ } while(off < minidrama[c]->black);
+
+ A("end of fog at minidrama %u",c);
+ parport->light(false);
+
+ // fog end: check button and skip if not pressed
+ if(! parport->button_is_pressed() ) {
+ A("no button pressed: skipping minidrama %u", c);
+ D("seek to offset %u", minidrama[c]->enddrama);
+ /// global seek of all channels
+ dec = (Decoder*) decoders.begin();
+ syncer = false;
+ while(dec) {
+ dec->stop();
+ dec->setup(&syncer, 0);
+ dec->setoffset( minidrama[c]->enddrama );
+ dec->play();
+ dec = (Decoder*) dec->next;
+ }
+ jsleep(0, interval);
+ syncer = true;
+ } else {
+ A("button was pressed: showing minidrama %u",c);
+ }
+ }
+
+ //////////////////////////////////////
if(rpcdaemon) {
-
+
// run as a daemon: quit only when requested
while( ! ivydaemon->quit ) {
ivydaemon->run(1.0);
jsleep(0,10);
}
-
+
} else {
-
+
// run until all the channels are at the end
int still_running = decoders.len();
-
+
while(still_running) {
-
+
still_running = 0;
dec = (Decoder*)decoders.begin();
-
+
while(dec) {
-
+
if(dec->playing) still_running++;
-
+
jsleep(1,0); // 1 second delay check
-
+
dec = (Decoder*)dec->next;
}
}
}
-
+
N("quit!");
-
+
exit(1);
}
diff --git a/branches/lydia/parport.cpp b/branches/lydia/parport.cpp
index 3c5779d..42c0ba4 100644
--- a/branches/lydia/parport.cpp
+++ b/branches/lydia/parport.cpp
@@ -72,10 +72,8 @@ void ParPort::run() {
// Read from the status port (BASE+2)
status = inb(BASEPORT + 1);
- if( status == 120 ) {
+ if( status == 120 )
button_state = true;
- D("button has been pressed", status);
- }
}
diff --git a/branches/lydia/sndfile_decoder.cpp b/branches/lydia/sndfile_decoder.cpp
index d14d35d..958e011 100644
--- a/branches/lydia/sndfile_decoder.cpp
+++ b/branches/lydia/sndfile_decoder.cpp
@@ -96,7 +96,7 @@ IN_DATATYPE *MuseDecSndFile::get_audio () {
framepos += frames/channels;
fps = samplerate;
- // D("MuseDecSndFile::get_audio => Frames readed: %d/%d", framepos, frametot);
+ // D("MuseDecSndFile::get_audio => Frames readed: %d/%d", framepos, frametot);
return ((IN_DATATYPE *) snd_buffer);
} else { framepos=0; eos = true; return (NULL); }
@@ -109,7 +109,7 @@ bool MuseDecSndFile::seek (float pos) {
framepos = 0;
sf_seek(sf, 0, SEEK_SET);
- D("MuseDecSndFile::seek => Stop. Return to the begin of the track");
+ D("MuseDecSndFile::seek => rewinded to the beginning of the track");
} else {
diff --git a/branches/lydia/sound_decoder.cpp b/branches/lydia/sound_decoder.cpp
index 783d1b5..e284ccb 100644
--- a/branches/lydia/sound_decoder.cpp
+++ b/branches/lydia/sound_decoder.cpp
@@ -18,6 +18,7 @@ MuseDec::~MuseDec() { }
bool MuseDec::play_once(SoundDevice *dev) {
seek(0.0);
+ replay = true;
eos = false;
device = dev;
launch();
@@ -33,15 +34,24 @@ void MuseDec::run() {
return;
}
- while(!eos) {
-
- buf = get_audio();
-
- if(!buf) break;
-
- device->write(buf, IN_CHUNK);
-
- // device->flush_output();
+ while(true) {
+
+ while(!replay) { jsleep(0,500); }
+
+ while(!eos) {
+
+ buf = get_audio();
+
+ if(!buf) break;
+
+ device->write(buf, IN_CHUNK);
+
+ // device->flush_output();
+
+ }
+ replay = false;
+ eos = false;
+ seek(0.0);
}
diff --git a/branches/lydia/sound_decoder.h b/branches/lydia/sound_decoder.h
index f0edfd2..037e395 100644
--- a/branches/lydia/sound_decoder.h
+++ b/branches/lydia/sound_decoder.h
@@ -146,6 +146,7 @@ class MuseDec: public Thread {
@brief playback once the audio file
@return true on success, false otherwise */
bool play_once(SoundDevice *dev);
+ bool replay;
SoundDevice *device;