26 case(XK_w) : (*midi_key) = 12.0;
28 case(XK_s) : (*midi_key) = 13.0;
30 case(XK_x) : (*midi_key) = 14.0;
32 case(XK_d) : (*midi_key) = 15.0;
34 case(XK_c) : (*midi_key) = 16.0;
36 case(XK_v) : (*midi_key) = 17.0;
38 case(XK_g) : (*midi_key) = 18.0;
40 case(XK_b) : (*midi_key) = 19.0;
42 case(XK_h) : (*midi_key) = 20.0;
44 case(XK_n) : (*midi_key) = 21.0;
46 case(XK_j) : (*midi_key) = 22.0;
48 case(XK_comma) : (*midi_key) = 23.0;
50 case(XK_a) : (*midi_key) = 24.0;
52 case(XK_eacute) : (*midi_key) = 25.0;
54 case(XK_z) : (*midi_key) = 26.0;
56 case(XK_quotedbl) : (*midi_key) = 27.0;
58 case(XK_e) : (*midi_key) = 28.0;
60 case(XK_r) : (*midi_key) = 29.0;
62 case(XK_parenleft) : (*midi_key) = 30.0;
64 case(XK_t) : (*midi_key) = 31.0;
66 case(XK_minus) : (*midi_key) = 32.0;
68 case(XK_y) : (*midi_key) = 33.0;
70 case(XK_egrave) : (*midi_key) = 34.0;
72 case(XK_u) : (*midi_key) = 35.0;
74 case(XK_i) : (*midi_key) = 36.0;
76 case(XK_ccedilla) : (*midi_key) = 37.0;
78 case(XK_o) : (*midi_key) = 38.0;
80 case(XK_agrave) : (*midi_key) = 39.0;
82 case(XK_p) : (*midi_key) = 40.0;
84 case(XK_dead_diaeresis) :
85 case(XK_dead_circumflex) : (*midi_key) = 41.0;
92 case(XK_y) : (*midi_key) = 12.0;
94 case(XK_s) : (*midi_key) = 13.0;
96 case(XK_x) : (*midi_key) = 14.0;
98 case(XK_d) : (*midi_key) = 15.0;
100 case(XK_c) : (*midi_key) = 16.0;
102 case(XK_v) : (*midi_key) = 17.0;
104 case(XK_g) : (*midi_key) = 18.0;
106 case(XK_b) : (*midi_key) = 19.0;
108 case(XK_h) : (*midi_key) = 20.0;
110 case(XK_n) : (*midi_key) = 21.0;
112 case(XK_j) : (*midi_key) = 22.0;
114 case(XK_m) : (*midi_key) = 23.0;
116 case(XK_q) : (*midi_key) = 24.0;
118 case(XK_2) : (*midi_key) = 25.0;
120 case(XK_w) : (*midi_key) = 26.0;
122 case(XK_3) : (*midi_key) = 27.0;
124 case(XK_e) : (*midi_key) = 28.0;
126 case(XK_r) : (*midi_key) = 29.0;
128 case(XK_5) : (*midi_key) = 30.0;
130 case(XK_t) : (*midi_key) = 31.0;
132 case(XK_6) : (*midi_key) = 32.0;
134 case(XK_z) : (*midi_key) = 33.0;
136 case(XK_7) : (*midi_key) = 34.0;
138 case(XK_u) : (*midi_key) = 35.0;
140 case(XK_i) : (*midi_key) = 36.0;
142 case(XK_9) : (*midi_key) = 37.0;
144 case(XK_o) : (*midi_key) = 38.0;
146 case(XK_0) : (*midi_key) = 39.0;
148 case(XK_p) : (*midi_key) = 40.0;
150 case(XK_udiaeresis) : (*midi_key) = 41.0;
152 case(XK_plus) : (*midi_key) = 42.0;
159 if ((*midi_key) == 12) (*midi_key) = 33;
160 else if ((*midi_key) == 33) (*midi_key) = 12;
163static void set_key_in_matrix(
unsigned long *key_matrix,
int key,
bool set) {
164 unsigned long *use_matrix = &key_matrix[0];
167 use_matrix = &key_matrix[3];
170 use_matrix = &key_matrix[2];
173 use_matrix = &key_matrix[1];
177 (*use_matrix) |= (1 << key);
179 (*use_matrix) &= (~(1 << key));
184 unsigned long *use_matrix = &key_matrix[0];
188 use_matrix = &key_matrix[3];
191 use_matrix = &key_matrix[2];
194 use_matrix = &key_matrix[1];
198 if((*use_matrix) & (1<<key)) {
211 if(key_matrix[j] & (1<<i)) {
226 key_matrix[j] &= (~(1 << i));
235 int width = metrics.
width-2;
236 int height = metrics.
height-2;
239 const double scale_zero = 20 * (M_PI/180);
244 int grow = (width > height) ? height:width;
249 int knobx = (width - knob_x) * 0.5;
250 int knobx1 = width* 0.5;
252 int knoby = (height - knob_y) * 0.5;
253 int knoby1 = height * 0.5;
256 double angle = scale_zero + knobstate * 2 * (M_PI - scale_zero);
258 double pointer_off =knob_x/3.5;
259 double radius = min(knob_x-pointer_off, knob_y-pointer_off) / 2;
260 double lengh_x = (knobx+radius+pointer_off/2) - radius * sin(angle);
261 double lengh_y = (knoby+radius+pointer_off/2) + radius * cos(angle);
262 double radius_x = (knobx+radius+pointer_off/2) - radius/ 1.18 * sin(angle);
263 double radius_y = (knoby+radius+pointer_off/2) + radius/ 1.18 * cos(angle);
264 cairo_pattern_t* pat;
265 cairo_new_path (w->
crb);
267 pat = cairo_pattern_create_linear (0, 0, 0, knob_y);
268 cairo_pattern_add_color_stop_rgba (pat, 1, 0.3, 0.3, 0.3, 1.0);
269 cairo_pattern_add_color_stop_rgba (pat, 0.75, 0.2, 0.2, 0.2, 1.0);
270 cairo_pattern_add_color_stop_rgba (pat, 0.5, 0.15, 0.15, 0.15, 1.0);
271 cairo_pattern_add_color_stop_rgba (pat, 0.25, 0.1, 0.1, 0.1, 1.0);
272 cairo_pattern_add_color_stop_rgba (pat, 0, 0.05, 0.05, 0.05, 1.0);
274 cairo_scale (w->
crb, 0.95, 1.05);
275 cairo_arc(w->
crb,knobx1+arc_offset/2, knoby1-arc_offset, knob_x/2.2, 0, 2 * M_PI );
276 cairo_set_source (w->
crb, pat);
277 cairo_fill_preserve (w->
crb);
278 cairo_set_source_rgb (w->
crb, 0.1, 0.1, 0.1);
279 cairo_set_line_width(w->
crb,1);
280 cairo_stroke(w->
crb);
281 cairo_scale (w->
crb, 1.05, 0.95);
282 cairo_new_path (w->
crb);
283 cairo_pattern_destroy (pat);
286 pat = cairo_pattern_create_linear (0, 0, 0, knob_y);
287 cairo_pattern_add_color_stop_rgba (pat, 0, 0.3, 0.3, 0.3, 1.0);
288 cairo_pattern_add_color_stop_rgba (pat, 0.25, 0.2, 0.2, 0.2, 1.0);
289 cairo_pattern_add_color_stop_rgba (pat, 0.5, 0.15, 0.15, 0.15, 1.0);
290 cairo_pattern_add_color_stop_rgba (pat, 0.75, 0.1, 0.1, 0.1, 1.0);
291 cairo_pattern_add_color_stop_rgba (pat, 1, 0.05, 0.05, 0.05, 1.0);
293 cairo_arc(w->
crb,knobx1, knoby1, knob_x/2.6, 0, 2 * M_PI );
294 cairo_set_source (w->
crb, pat);
295 cairo_fill_preserve (w->
crb);
296 cairo_set_source_rgb (w->
crb, 0.1, 0.1, 0.1);
297 cairo_set_line_width(w->
crb,1);
298 cairo_stroke(w->
crb);
299 cairo_new_path (w->
crb);
300 cairo_pattern_destroy (pat);
303 cairo_set_line_cap(w->
crb, CAIRO_LINE_CAP_ROUND);
304 cairo_set_line_join(w->
crb, CAIRO_LINE_JOIN_BEVEL);
305 cairo_move_to(w->
crb, radius_x, radius_y);
306 cairo_line_to(w->
crb,lengh_x,lengh_y);
307 cairo_set_line_width(w->
crb,3);
308 cairo_set_source_rgb (w->
crb,0.63,0.63,0.63);
309 cairo_stroke(w->
crb);
310 cairo_new_path (w->
crb);
312 cairo_text_extents_t extents;
317 cairo_set_source_rgb (w->
crb, 0.6, 0.6, 0.6);
318 cairo_set_font_size (w->
crb, knobx1/3);
319 cairo_text_extents(w->
crb, s, &extents);
320 cairo_move_to (w->
crb, knobx1-extents.width/2, knoby1+extents.height/2);
321 cairo_show_text(w->
crb, s);
322 cairo_new_path (w->
crb);
327 float font_size = ((height/2.2 < (width*0.5)/3) ? height/2.2 : (width*0.5)/3);
328 cairo_set_font_size (w->
crb, font_size);
329 cairo_text_extents(w->
crb,w->
label , &extents);
331 cairo_move_to (w->
crb, knobx1-extents.width/2, height );
333 cairo_new_path (w->
crb);
336static void draw_keyboard(
void *w_,
void* user_data) {
340 int width_t = metrics.
width;
341 int height_t = metrics.
height;
345 cairo_rectangle(w->
crb,0,0,width_t,height_t*0.4);
350 cairo_rectangle(w->
crb,0,height_t*0.38,width_t,height_t*0.02);
351 cairo_fill_preserve (w->
crb);
354 cairo_set_line_width(w->
crb, 1.0);
355 cairo_stroke(w->
crb);
361 for(;i<width_t;i++) {
362 cairo_rectangle(w->
crb,i,height_t*0.4,25,height_t*0.6);
363 if ( k+keys->octave == keys->active_key ||
mk_is_key_in_matrix(keys->key_matrix,k+keys->octave)) {
365 cairo_set_line_width(w->
crb, 1.0);
366 }
else if ( k+keys->octave == keys->prelight_key) {
368 cairo_set_line_width(w->
crb, 2.0);
371 cairo_set_line_width(w->
crb, 1.0);
374 cairo_fill_preserve(w->
crb);
376 cairo_stroke(w->
crb);
384 }
else if (set == 4) {
402 for(;i<width_t;i++) {
405 cairo_set_line_width(w->
crb, 1.0);
406 cairo_rectangle(w->
crb,i+15,height_t*0.4,20,height_t*0.39);
407 if ( k+keys->octave == keys->active_key ||
mk_is_key_in_matrix(keys->key_matrix,k+keys->octave)) {
409 cairo_set_line_width(w->
crb, 1.0);
410 }
else if ( k+keys->octave == keys->prelight_key) {
412 cairo_set_line_width(w->
crb, 2.0);
415 cairo_set_line_width(w->
crb, 1.0);
418 cairo_fill_preserve(w->
crb);
420 cairo_stroke(w->
crb);
431 }
else if (set == 3) {
444static void keyboard_motion(
void *w_,
void* xmotion_,
void* user_data) {
451 int width = metrics.
width;
452 int height = metrics.
height;
455 bool catchit =
false;
457 if(xmotion->
y < height*0.4) {
458 keys->active_key = keys->prelight_key = -1;
463 if(xmotion->
y < height*0.8) {
470 if(xmotion->
x > i+15 && xmotion->
x < i+35) {
471 keys->prelight_key = set_key+keys->octave;
472 if(xmotion->
state & Button1Mask) {
473 if (keys->active_key != keys->prelight_key) {
474 keys->send_key = keys->active_key;
475 keys->mk_send_note(p, &keys->send_key,
false);
476 keys->active_key = keys->prelight_key;
477 keys->send_key = keys->active_key;
478 keys->mk_send_note(p, &keys->send_key,
true);
492 }
else if (set == 3) {
509 if(xmotion->
x > i && xmotion->
x < i+25) {
510 keys->prelight_key = k+keys->octave;
511 if(xmotion->
state & Button1Mask) {
512 if (keys->active_key != keys->prelight_key) {
513 keys->send_key = keys->active_key;
514 keys->mk_send_note(p, &keys->send_key,
false);
515 keys->active_key = keys->prelight_key;
516 keys->send_key = keys->active_key;
517 keys->mk_send_note(p, &keys->send_key,
true);
530 }
else if (set == 4) {
557static void key_press(
void *w_,
void *key_,
void *user_data) {
569 KeySym sym = XLookupKeysym (key, 0);
571 get_outkey(keys, sym, &outkey);
579 if (sym == XK_space) {
586static void key_release(
void *w_,
void *key_,
void *user_data) {
598 KeySym sym = XLookupKeysym (key, 0);
600 get_outkey(keys, sym, &outkey);
609static void leave_keyboard(
void *w_,
void* user_data) {
616static void button_pressed_keyboard(
void *w_,
void* button_,
void* user_data) {
622 if(xbutton->
button == Button1) {
631static void button_released_keyboard(
void *w_,
void* button_,
void* user_data) {
637 if(xbutton->
button == Button1) {
646static void octave_callback(
void *w_,
void* user_data) {
653static void layout_callback(
void *w_,
void* user_data) {
660static void modwheel_callback(
void *w_,
void* user_data) {
669static void detune_callback(
void *w_,
void* user_data) {
678static void attack_callback(
void *w_,
void* user_data) {
687static void sustain_callback(
void *w_,
void* user_data) {
696static void release_callback(
void *w_,
void* user_data) {
705static void volume_callback(
void *w_,
void* user_data) {
714static void velocity_callback(
void *w_,
void* user_data) {
723static void pitchwheel_callback(
void *w_,
void* user_data) {
732static void pitchsensity_callback(
void *w_,
void* user_data) {
741static void wheel_key_release(
void *w_,
void *key_,
void *user_data) {
744 p->func.key_release_callback(p, key_, user_data);
747static void wheel_key_press(
void *w_,
void *key_,
void *user_data) {
750 p->func.key_press_callback(p, key_, user_data);
760static void keyboard_mem_free(
void *w_,
void* user_data) {
766static void map_keyboard(
void *w_,
void* user_data) {
778static void key_dummy(
Widget_t *w,
int *key,
bool on_off) {
785static void wheel_dummy(
Widget_t *w,
int *value) {
790 int x,
int y,
int width,
int height) {
evfunc button_release_callback
xevfunc map_notify_callback
evfunc key_release_callback
evfunc key_press_callback
xevfunc value_changed_callback
xevfunc mem_free_callback
evfunc button_press_callback
Metrics_t - struct to receive window size, position & visibility Pass this struct to os_get_window_...
mk_midiwheelfunc mk_send_attack
mk_midiwheelfunc mk_send_sustain
mk_midiwheelfunc mk_send_detune
mk_midikeyfunc mk_send_note
mk_midiwheelfunc mk_send_volume
mk_midiwheelfunc mk_send_mod
mk_midiwheelfunc mk_send_pitchsensity
mk_midiwheelfunc mk_send_velocity
unsigned long key_matrix[4]
mk_midiwheelfunc mk_send_all_sound_off
mk_midiwheelfunc mk_send_release
mk_midiwheelfunc mk_send_pitch
float adj_get_value(Adjustment_t *adj)
adj_get_value - get the current value of the Adjustment_t
void set_adjustment(Adjustment_t *adj, float std_value, float value, float min_value, float max_value, float step, CL_type type)
*set_adjustment - set a new range to a existing Adjustment_t or create if it not exists yet
float adj_get_state(Adjustment_t *adj)
adj_get_state - get the current state of the Adjustment_t
void adj_set_scale(Adjustment_t *adj, float value)
adj_set_scale - internal use to scale the pointer movement (0.1 -1.0)
Color_state get_color_state(Widget_t *wid)
get_color_state - get the Color_state to use in relation to the Widget_t state
void use_text_color_scheme(Widget_t *w, Color_state st)
use_text_color_scheme - use text Colors to paint on Widget_t
void use_bg_color_scheme(Widget_t *w, Color_state st)
use_bg_color_scheme - use background Colors to paint on Widget_t
void use_fg_color_scheme(Widget_t *w, Color_state st)
use_fg_color_scheme - use forground Colors to paint on Widget_t
void set_pattern(Widget_t *w, Colors *from, Colors *to, Color_mod mod)
set_pattern - set pattern for the selected Colors
void use_base_color_scheme(Widget_t *w, Color_state st)
use_base_color_scheme - use base Colors to paint on Widget_t
void combobox_set_active_entry(Widget_t *w, int active)
combobox_set_active_entry - set the active combobox entry
void combobox_add_entry(Widget_t *wid, const char *label)
combobox_add_entry - add a entry to the combobox
Widget_t * add_combobox(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_combobox - add a combobox
Widget_t * add_knob(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_knob - add a knob to a Widget_t connect to func.value_changed_callback to implement your actions ...
void mk_draw_knob(void *w_, void *user_data)
void mk_keysym_qwerty_to_midi_key(unsigned int inkey, float *midi_key)
void mk_clear_key_matrix(unsigned long *key_matrix)
Widget_t * add_keyboard_knob(Widget_t *parent, const char *label, int x, int y, int width, int height)
bool mk_is_key_in_matrix(unsigned long *key_matrix, int key)
bool mk_have_key_in_matrix(unsigned long *key_matrix)
Widget_t * mk_open_midi_keyboard(Widget_t *w)
void mk_keysym_qwertz_to_midi_key(long inkey, float *midi_key)
void mk_keysym_azerty_to_midi_key(long inkey, float *midi_key)
void widget_set_icon_from_png(Widget_t *w, const unsigned char *name)
widget_set_icon_from_png - set icon image from png binary to Widget_t those icon will be used in the ...
Widget_t * add_hslider(Widget_t *parent, const char *label, int x, int y, int width, int height)
add_hslider - add a horizontal slider to a Widget_t connect to func.value_changed_callback to impleme...