2
Copyright (C) 2012 Paul Davis
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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;
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;
62
volatile struct Note notes[NNOTES];
63
/* Table used to translate from PC keyboard character to MIDI note number. */
64
GHashTable *key_bindings;
67
struct _PianoKeyboardClass
69
GtkDrawingAreaClass parent_class;
72
GType piano_keyboard_get_type (void) G_GNUC_CONST;
73
GtkWidget* piano_keyboard_new (void);
74
void piano_keyboard_sustain_press (PianoKeyboard *pk);
75
void piano_keyboard_sustain_release (PianoKeyboard *pk);
76
void piano_keyboard_set_note_on (PianoKeyboard *pk, int note);
77
void piano_keyboard_set_note_off (PianoKeyboard *pk, int note);
78
void piano_keyboard_set_keyboard_cue (PianoKeyboard *pk, int enabled);
79
void piano_keyboard_set_octave (PianoKeyboard *pk, int octave);
80
gboolean piano_keyboard_set_keyboard_layout (PianoKeyboard *pk, const char *layout);
84
#endif /* __PIANO_KEYBOARD_H__ */