This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

Wiki will be moved to GitLab

This Wiki will soon be replaced by the one in the new project's page: https://gitlab.gnome.org/GNOME/libgtkmusic/wikis/home


What's libgtkmusic?

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.

Guitar Widget Piano Widget

Installing

Building from source

Currently this is the only installation method. The source code can be accessed either 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.

Installing Dependencies

Please make sure the following packages are installed:

Fedora

Debian or Ubuntu

vala

valac

pkgconf

pkg-config

libgee-devel

libgee-0.8-dev

meson

(outdated package; see below)

git

ninja-build

Please make sure that a recent meson version is installed (>= 0.44). In doubt, install via pip3

# apt-get 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

Allows use with other runtimes, such as Python

gobject-introspection-devel

libgirepository1.0-dev

(same as above)

libgee-devel

libgladeui-dev

Add libgtkmusic widgets to Glade designer

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:

 $ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/x86_64-linux-gnu"

Usage

Provided that you've successfully installed the library and its GObject Introspection typelib, try out this minimal Python example:

   1 #!/usr/bin/env python3
   2 import gi
   3 gi.require_version('Gtk', '3.0')
   4 gi.require_version('Gdk', '3.0')
   5 gi.require_version('GtkMusic', '0.4')
   6 
   7 from gi.repository import Gtk, Gdk, GtkMusic
   8 
   9 def note_pressed(sender, widget, event, midi_code):
  10         print('You pressed the note with MIDI code %d!' % midi_code)
  11 
  12 win = Gtk.Window()
  13 piano = GtkMusic.Piano()
  14 
  15 piano.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
  16 piano.connect('note_pressed',  note_pressed)
  17 win.connect('destroy', Gtk.main_quit)
  18 
  19 win.add(piano)
  20 
  21 win.show_all()
  22 Gtk.main()

API Reference

The API reference is currently hosted at http://leandromattioli.com/api/GtkMusic/.

Future

Getting in Touch


2024-10-23 11:37