瀏覽代碼

make displays settable via osc

master
父節點
當前提交
6d6c4cbe77
共有 1 個文件被更改,包括 45 次插入9 次删除
  1. +45
    -9
      main.c

+ 45
- 9
main.c 查看文件

@@ -12,11 +12,13 @@

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

enum display_type {
LABEL,
VPOT
VPOT,
MAIN_DISPLAY
};

typedef struct {
@@ -131,7 +133,7 @@ void osc_send (void *arg, Item el, float value);
void register_osc_receives(void *arg);
int osc_in_button_handler(const char *path, const char *types, lo_arg ** argv,
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);


@@ -226,20 +228,54 @@ void register_osc_receives(void *arg) {
lo_server_thread_add_method(IOs->osc_in,
address,
"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]);
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) {
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;
}


Loading…
取消
儲存