libgtkmusic is a GTK+ library that provides widgets for displaying and interacting with musical instruments views, as well as some utility functions. It can be used for any kind of application that needs a musical instrument view, such as virtual guitars, note detector, guitar training and games). Currently it supports a highly customizable guitar and a piano.
Building from source
Currently this is the only installation method. The source code can be accessed through its GitLab libgtkmusic Project.
The library uses the Meson build system. The instructions here provided assume the reader has a basic knowledge of GNU/Linux systems.
Please make sure the following packages are installed:
|Fedora||Debian or Ubuntu|
|meson||(outdated package; see below)|
Please make sure that a recent meson version is installed (>= 0.44). In doubt, install via pip3
sudo apt install python3-pip pip3 install --user --upgrade meson
To enable all build features, please also install the packages below:
|Fedora||Debian or Ubuntu||Feature|
|gobject-introspection||gobject-introspection||Allows use with other runtimes, such as Python|
|gobject-introspection-devel||libgirepository1.0-dev||(same as above)|
|glade3-libgladeui-devel||libgladeui-dev||Add libgtkmusic widgets to Glade designer|
|valadoc||valadoc||Generate Devhelp API reference via valadoc|
Building the library
git clone https://gitlab.gnome.org/GNOME/libgtkmusic.git cd libgtkmusic meson build cd build ninja ninja install
If needed add the directory of the installed library to LD_EXPORT_PATH:
You might will also need to tell
GObject Introspection where to find the library typelib:
Append these lines to your
~/.profile to make it permanent.
Provided that you've successfully installed the library and its GObject Introspection typelib, try out this minimal Python example:
#!/usr/bin/env python3 import gi gi.require_version('Gtk', '3.0') gi.require_version('Gdk', '3.0') gi.require_version('GtkMusic', '0.4') from gi.repository import Gtk, Gdk, GtkMusic def note_pressed(widget, event, midi_code): print('You pressed the note with MIDI code %d!' % midi_code) win = Gtk.Window() piano = GtkMusic.Piano() piano.add_events(Gdk.EventMask.BUTTON_PRESS_MASK) piano.connect('note_pressed', note_pressed) win.connect('destroy', Gtk.main_quit) win.add(piano) win.show_all() Gtk.main()
The API reference is currently hosted at https://leandromattioli.com.br/api/GtkMusic/.
- [x] ~~Migration to GitLab~~ - [ ] Add other widgets (notably a drum kit) - [ ] Add complete example with FluidSynth