Browse Source

make displays settable via osc

master
parent
commit
6d6c4cbe77
1 changed files with 45 additions and 9 deletions
  1. +45
    -9
      main.c

+ 45
- 9
main.c View File



#define ZONE_COUNT 0x1e #define ZONE_COUNT 0x1e
#define PORT_COUNT 196 #define PORT_COUNT 196
#define DISPLAY_COUNT 9
#define DISPLAY_COUNT 17
#define HDR 0xf0, 0x00, 0x00, 0x66, 0x05, 0x00


enum display_type { enum display_type {
LABEL, LABEL,
VPOT
VPOT,
MAIN_DISPLAY
}; };


typedef struct { typedef struct {
void register_osc_receives(void *arg); void register_osc_receives(void *arg);
int osc_in_button_handler(const char *path, const char *types, lo_arg ** argv, int osc_in_button_handler(const char *path, const char *types, lo_arg ** argv,
int argc, void *data, void *user_data); int argc, void *data, void *user_data);
int osc_in_label_handler (const char *path, const char *types, lo_arg ** argv,
int osc_in_display_handler (const char *path, const char *types, lo_arg ** argv,
int argc, void *data, void *user_data); int argc, void *data, void *user_data);




lo_server_thread_add_method(IOs->osc_in, lo_server_thread_add_method(IOs->osc_in,
address, address,
"s", "s",
osc_in_label_handler,
osc_in_display_handler,
&IOs->display_outs[display_c]);
display_c++;
}

for (i=0;i<8;i++) {
Hui_display_port_t out = {MAIN_DISPLAY,i,IOs};
IOs->display_outs[display_c] = out;
sprintf(address,"/main_display/%d",i);
lo_server_thread_add_method(IOs->osc_in,
address,
"s",
osc_in_display_handler,
&IOs->display_outs[display_c]); &IOs->display_outs[display_c]);
display_c++; display_c++;
} }
} }


int osc_in_label_handler(const char *path, const char *types, lo_arg ** argv,
int osc_in_display_handler(const char *path, const char *types, lo_arg ** argv,
int argc, void *data, void *user_data) { int argc, void *data, void *user_data) {
char* val;

val = (char *)(lo_arg*) argv[0]->s;
Hui_display_port_t* out = (Hui_display_port_t*)user_data;
housicIO* IOs = (housicIO*) out->io;
char* val = (char*)argv[0];
int i;
int size;
char message[52] = {HDR};

if (out->type == LABEL) {
size=13;
message[6] = 0x10;
message[7] = out->id;
for (i=0; i<4; i++) {
message[8+i] = val[i] ? val[i] & 0x7f : 0x20;
}
} else if (out->type == MAIN_DISPLAY) {
size=19;
message[6] = 0x12;
message[7] = out->id;
for (i=0; i<10; i++) {
message[8+i] = (val[i] > 0x10) ? val[i] & 0x7f : 0x20;
}
}
printf("%s: %d: %x\n",types,argc, argv);
message[size-1] = 0xf7;

snd_rawmidi_write(IOs->midiout,message,size);

return 1; return 1;
} }



Loading…
Cancel
Save