Ada 2012 bindings for libcanberra.
A minimal example to synchronously play an event sound:
with Canberra;
procedure Example is
Context : Canberra.Context := Canberra.Create;
begin
Context.Play ("bell");
end Example;An example that shows how to play sounds asynchronously and cancel or wait for them to finish playing:
with Canberra;
procedure Example is
Context : Canberra.Context := Canberra.Create
(Name => "Ada",
ID => "ada.lovelace",
Icon => "utilities-terminal");
S1, S2 : Canberra.Sound;
begin
Context.Set_Property ("canberra.xdg-theme.name", "ubuntu");
Context.Play ("phone-outgoing-busy", S1);
Context.Play ("desktop-login", S2, Canberra.Music, "Login");
-- Stop playing the music sound
delay 1.5;
Context.Cancel (S2);
-- But wait for the event sound to finish playing
S1.Await_Finish_Playing;
end Example;In order to build the bindings for libcanberra, you need to have:
-
An Ada 2012 compiler
-
GPRBuild and
make
Install the dependencies using apt:
$ sudo apt install gnat-7 gprbuild make libcanberra-devFor the PulseAudio backend you can install libcanberra-pulse.
A Makefile is provided to build the source code and tests. Use make to build
the source code:
$ make
You can override CFLAGS if desired. After having compiled the source code, the bindings can be installed by executing:
$ make PREFIX=/usr install
Change PREFIX to the preferred destination folder, for example ~/.local.
Specify the dependency in your *.gpr project file:
with "canberra";Read the contributing guidelines if you want to add a bugfix or an improvement.
These bindings are licensed under the Apache License 2.0. The first line of each Ada file should contain an SPDX license identifier tag that refers to this license:
SPDX-License-Identifier: Apache-2.0