@ -2,8 +2,8 @@
PREFIX?= /usr/local
OBJS= main.o vm.o dmx.o midi.o beatdetect.o fft.o map3d.o mouse.o
OBJS= main.o vm.o plugins.o dmx.o midi.o beatdetect.o fft.o map3d.o mouse.o
SRCS= main.c vm.c dmx.c midi.c beatdetect.c fft.c map3d.c mouse.c
SRCS= main.c vm.c plugins.c dmx.c midi.c beatdetect.c fft.c map3d.c mouse.c
COMMONOBJS= mem.o hash.o
COMMONDIR= ../common
@ -114,7 +114,7 @@ double beatdetect_getconfidence(void)
return confidence;
}
void beatdetect_init(void)
int beatdetect_init(void)
{
audio_info_t info, oinfo;
@ -156,6 +156,8 @@ void beatdetect_init(void)
/* vm_register_blah */
vm_register_signal_fd(audiofd, VM_BEATQ);
return 1;
int beatdetect_read(void)
@ -1,6 +1,6 @@
/* beatdetect.h */
void beatdetect_init(void);
int beatdetect_init(void);
void beatdetect_close(void);
double beatdetect_getphase(void);
double beatdetect_getconfidence(void);
@ -92,7 +92,7 @@ out:
printf("%x %x %x %x %x %x %x %x %x %x %x %x\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]);
void dmx_init(void)
int dmx_init(void)
dmx_open();
dmxpacket[0] = 0x7e;
@ -104,6 +104,7 @@ void dmx_init(void)
dmxpacket[DMX_UNIVERSESIZE+5] = 0xe7;
dmxuniverse = dmxpacket+5;
// dmx_dumpparams();
void dmx_setchannel(int channel, int value)
@ -3,7 +3,7 @@
#define DMX_UNIVERSESIZE 512
void dmx_close(void);
void dmx_init(void);
int dmx_init(void);
void dmx_setchannel(int channel, int value);
void dmx_output(void);
@ -2,18 +2,25 @@
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <err.h>
#include "vm.h"
#include "dmx.h"
#include "plugins.h"
#include "midi.h"
#include "beatdetect.h"
/* This macro exists purely to shorten subsequent lines for readability */
#include "mouse.h"
#define PT(i) plugins_table[i]
void finish(void)
dmx_close();
int i;
midi_close();
beatdetect_close();
for (i = nplugins-1; i >= 0; i--) {
printf("Shutting down plugin '%s'\n", PT(i).pl_name);
(PT(i).pl_init)();
printf("Plugin '%s' shut down\n", PT(i).pl_name);
PT(i).pl_active = 0;
exit(0);
@ -24,6 +31,8 @@ void sigint_handler(int signal)
int main(int argc, char *argv[])
argv++;
argc--;
if (argc != 1)
@ -31,10 +40,20 @@ int main(int argc, char *argv[])
vm_init();
vm_load(argv[0]);
signal(SIGINT, sigint_handler);
midi_init();
dmx_init();
/* Initialise plugins */
beatdetect_init();
for (i = 0; i < nplugins; i++) {
mouse_init();
printf("Initialising plugin '%s'\n", PT(i).pl_name);
if ((PT(i).pl_init)()) {
printf("Plugin '%s' initialised\n", PT(i).pl_name);
PT(i).pl_active = 1;
} else {
printf("Plugin '%s' failed\n", PT(i).pl_name);
/* Showtime */
vm_spawn("main");
vm_run();
finish();
@ -16,7 +16,7 @@ int midi_bytes;
seq_event_rec midi_buf;
int midi_initialised = 0;
void midi_init(void)
int midi_init(void)
midi_fd = open(PORT, O_NONBLOCK | O_RDONLY, 0);
if (midi_fd == -1) {
@ -25,6 +25,7 @@ void midi_init(void)
midi_bytes = 0;
midi_initialised = 1;
vm_register_signal_fd(midi_fd, VM_MIDIQ);
void midi_close(void)
/* midi.h */
void midi_init(void);
int midi_init(void);
void midi_close(void);
int midi_filter(void);
int midi_read(void);
@ -50,7 +50,7 @@ struct wscons_event mouse_buf;
int mouse_initialised = 0;
int mouse_x, mouse_y, mouse_z;
void mouse_init(void)
int mouse_init(void)
mouse_fd = open(MOUSEDEVICE, O_RDONLY);
if (mouse_fd < 0)
@ -61,6 +61,8 @@ void mouse_init(void)
mouse_x = 0;
mouse_y = 0;
mouse_z = 0;
void mouse_close(void)
/* mouse.h */
void mouse_init(void);
int mouse_init(void);
void mouse_close(void);
int mouse_filter(void);
void mouse_getpos(int *, int *, int *);