--- cui_midi.c- Wed Apr 9 00:00:00 2014 +++ cui_midi.c Wed Apr 9 01:00:00 2014 @@ -181,6 +181,60 @@ return FALSE; } +struct test3_ch{ + int prog, vol; + int note, note_num, velo, note_len; +}; + +struct test3{ + cui mn_ch, prog, vol; + cui mn_note, note_num, velo, note_out; + cui bs_note_len, note_len; + + int midi_ch; + struct test3_ch ch[16]; +}; + +int +t3_btn_hdr(cui obj, int evt, int val, void *prm) +{ + /* CUI_EVT_BUTTON */ + + struct test3 *p = (struct test3 *)prm; + struct test3_ch *ch = &p->ch[ p->midi_ch ]; + + if(obj == p->mn_ch){ + cui_num_vp_set(p->prog, &ch->prog); + cui_num_vp_set(p->vol, &ch->vol); + cui_menu_popup_set(p->mn_note, ch->note); /* ! */ + cui_handler_call(p->mn_note, CUI_EVT_BUTTON, ch->note); /* ! */ + cui_num_vp_set(p->note_num, &ch->note_num); + cui_num_vp_set(p->velo, &ch->velo); + cui_num_vp_set(p->note_len, &ch->note_len); + }else if(obj == p->prog){ + set_char2_wrt((0xc<<4) | p->midi_ch, ch->prog); + }else if(obj == p->vol){ + set_char3_wrt((0xb<<4) | p->midi_ch, 7 /* vol msb */, ch->vol); + }else if(obj == p->mn_note){ /* ! */ + char *s = cui_menu_popup_str_get(p->mn_note); + if(strcmp(s, "on/off") == 0) cui_show(p->bs_note_len); + else cui_hide(p->bs_note_len); + ch->note = cui_menu_popup_get(p->mn_note); + }else if(obj == p->note_out){ + char *s = cui_menu_popup_str_get(p->mn_note); + if(strcmp(s, "on") == 0){ + set_char3_wrt((9<<4) | p->midi_ch, ch->note_num, ch->velo); + }else if(strcmp(s, "off") == 0){ + set_char3_wrt((8<<4) | p->midi_ch, ch->note_num, ch->velo); + }else if(strcmp(s, "on/off") == 0){ + set_char3_wrt((9<<4) | p->midi_ch, ch->note_num, ch->velo); + usleep(ch->note_len * 1000); + set_char3_wrt((8<<4) | p->midi_ch, ch->note_num, ch->velo); + }else return FALSE; + }else return FALSE; + return TRUE; +} + int main(int ac, char **av) { @@ -202,13 +256,29 @@ char *note_lst[] = {"on", "off", "on/off", NULL}; struct test2 t2; + cui bs3 = cui_base_new(scp->view, quit->x, cui_y2(quit)+1, 0, 0); + struct test3 t3; + cui obj; + char *cmd = "./add_delta | ./prog31 -V0 -q -play"; int div = 96; int i; - cui tab_sheets[] = { bs1, bs2 }; + cui tab_sheets[] = { bs1, bs2, bs3 }; cui_hide(bs1); cui_hide(bs2); + cui_hide(bs3); + + lb_buf[0] = '\0'; + cui_label_str_set(lb, lb_buf); + + cui_wh_fit(bs1); + + cui_bind(quit, CUI_EVT_BUTTON, btn_hdr, prm_arr); + cui_bind(add, CUI_EVT_BUTTON, btn_hdr, prm_arr); + cui_bind(out, CUI_EVT_BUTTON, btn_hdr, prm_arr); + + /* t2 */ t2.lb_ch = cui_label_new(bs2, 0, 0, "midi ch : "); t2.mn_ch = cui_menu_popup_new(bs2, cui_x2(t2.lb_ch), 0, 4, ch_lst, 0); @@ -230,38 +300,80 @@ t2.note_len = cui_num_new(t2.bs_note_len, cui_x2(t2.lb_note_len), 0, 12, 500, 0, 10*1000, 0); t2.lb_ms = cui_label_new(t2.bs_note_len, cui_x2(t2.note_len)+2, 0, "msec"); - for(i=1; iview, cui_x2(quit)+2, quit->y, -1, - (char *[]){"1st ", "2nd ", NULL}, - tab_sheets, 1); - - cui_bind(quit, CUI_EVT_BUTTON, btn_hdr, prm_arr); - cui_bind(add, CUI_EVT_BUTTON, btn_hdr, prm_arr); - cui_bind(out, CUI_EVT_BUTTON, btn_hdr, prm_arr); - cui_bind(t2.prog_out, CUI_EVT_BUTTON, t2_btn_hdr, &t2); cui_bind(t2.vol_out, CUI_EVT_BUTTON, t2_btn_hdr, &t2); cui_bind(t2.note_out, CUI_EVT_BUTTON, t2_btn_hdr, &t2); cui_bind(t2.mn_note, CUI_EVT_BUTTON, t2_btn_hdr, &t2); - cui_wh_fit(bs1); + cui_hide(t2.bs_note_len); cui_wh_fit(t2.bs_note_len); cui_wh_fit(bs2); + + /* t3 */ + + t3.midi_ch = 0; + for(i=0; i<16; i++){ + t3.ch[i].prog = 0; + t3.ch[i].vol = 0; + t3.ch[i].note = 0; + t3.ch[i].note_num = 69; + t3.ch[i].velo = 64; + t3.ch[i].note_len = 500; + } + obj = cui_label_new(bs3, 0, 0, "midi ch : "); + t3.mn_ch = cui_menu_int_new(bs3, cui_x2(obj), 0, 4, 0, 0, 15); + cui_menu_int_vp_set(t3.mn_ch, &t3.midi_ch); + + obj = cui_label_new(bs3, 2, 2, "prog num : "); + t3.prog = cui_num_new(bs3, cui_x2(obj), 2, 8, 0, 0, 127, 0); + + obj = cui_label_new(bs3, 2, 4, "vol (msb) : "); + t3.vol = cui_num_new(bs3, cui_x2(obj), 4, 8, 0, 0, 127, 0); + + obj = cui_label_new(bs3, 2, 6, "note : "); + t3.mn_note = cui_menu_popup_new(bs3, cui_x2(obj), 6, 7, note_lst, 0); + + obj = cui_label_new(bs3, cui_x2(t3.mn_note)+2, 6, "num : "); + t3.note_num = cui_num_new(bs3, cui_x2(obj), 6, 8, 0, 0, 127, 0); + obj = cui_label_new(bs3, cui_x2(t3.note_num)+2, 6, "velo : "); + t3.velo = cui_num_new(bs3, cui_x2(obj), 6, 8, 0, 0, 127, 0); + t3.note_out = cui_button_new(bs3, cui_x2(t3.velo)+2, 6, "Out"); + + t3.bs_note_len = cui_base_new(bs3, t3.mn_note->x, 7, 0, 0); + obj = cui_label_new(t3.bs_note_len, 0, 0, "note len : "); + t3.note_len = cui_num_new(t3.bs_note_len, cui_x2(obj), 0, 12, 0, 0, 10*1000, 0); + cui_label_new(t3.bs_note_len, cui_x2(t3.note_len)+2, 0, "msec"); + + cui_hide(t3.bs_note_len); + cui_wh_fit(t3.bs_note_len); + cui_wh_fit(bs3); + + cui_bind(t3.mn_ch, CUI_EVT_BUTTON, t3_btn_hdr, &t3); + cui_bind(t3.prog, CUI_EVT_BUTTON, t3_btn_hdr, &t3); + cui_bind(t3.vol, CUI_EVT_BUTTON, t3_btn_hdr, &t3); + cui_bind(t3.note_out, CUI_EVT_BUTTON, t3_btn_hdr, &t3); + cui_bind(t3.mn_note, CUI_EVT_BUTTON, t3_btn_hdr, &t3); + + cui_handler_call(t3.mn_ch, CUI_EVT_BUTTON, cui_menu_int_get(t3.mn_ch)); + + /**/ + + cui_show(bs3); + cui_tab_new(scp->view, cui_x2(quit)+2, quit->y, -1, + (char *[]){"1st ", "2nd ", "3rd ", NULL}, + tab_sheets, 2); + cui_wh_fit(scp->view); cui_wh_exp(bs1); cui_wh_set(root, scp->view->w+3, scp->view->h+3); cui_xy_set(scp->rszbox, root->w-1, root->h-1); - cui_hide(t2.bs_note_len); + + for(i=1; i