2 * Copyright (C) 2010-2016 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef __PIANO_KEYBOARD_H__
21 #define __PIANO_KEYBOARD_H__
24 #include <gtk/gtkdrawingarea.h>
28 #define TYPE_PIANO_KEYBOARD (piano_keyboard_get_type ())
29 #define PIANO_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PIANO_KEYBOARD, PianoKeyboard))
30 #define PIANO_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PIANO_KEYBOARD, PianoKeyboardClass))
31 #define IS_PIANO_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PIANO_KEYBOARD))
32 #define IS_PIANO_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PIANO_KEYBOARD))
33 #define PIANO_KEYBOARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PIANO_KEYBOARD, PianoKeyboardClass))
35 typedef struct _PianoKeyboard PianoKeyboard;
36 typedef struct _PianoKeyboardClass PianoKeyboardClass;
40 #define OCTAVE_MIN (-1)
41 #define OCTAVE_MAX (7)
44 int pressed; /* 1 if key is in pressed down state. */
45 int sustained; /* 1 if note is sustained. */
46 int x; /* Distance between the left edge of the key
47 * and the left edge of the widget, in pixels. */
48 int w; /* Width of the key, in pixels. */
49 int h; /* Height of the key, in pixels. */
50 int white; /* 1 if key is white; 0 otherwise. */
56 int maybe_stop_sustained_notes;
57 int sustain_new_notes;
58 int enable_keyboard_cue;
61 int note_being_pressed_using_mouse;
64 struct PKNote notes[NNOTES];
65 /* Table used to translate from PC keyboard character to MIDI note number. */
66 GHashTable* key_bindings;
69 struct _PianoKeyboardClass
71 GtkDrawingAreaClass parent_class;
74 GType piano_keyboard_get_type (void) G_GNUC_CONST;
75 GtkWidget* piano_keyboard_new (void);
77 void piano_keyboard_sustain_press (PianoKeyboard *pk);
78 void piano_keyboard_sustain_release (PianoKeyboard *pk);
79 void piano_keyboard_set_note_on (PianoKeyboard *pk, int note);
80 void piano_keyboard_set_note_off (PianoKeyboard *pk, int note);
81 void piano_keyboard_set_keyboard_cue (PianoKeyboard *pk, int enabled);
82 void piano_keyboard_set_monophonic (PianoKeyboard *pk, gboolean monophonic);
83 void piano_keyboard_set_octave (PianoKeyboard *pk, int octave);
85 gboolean piano_keyboard_set_keyboard_layout (PianoKeyboard *pk, const char *layout);
89 #endif /* __PIANO_KEYBOARD_H__ */