Skip to content

onox/canberra-ada

Repository files navigation

Build status License Alire crate GitHub release IRC Gitter chat

canberra-ada

Ada 2012 bindings for libcanberra.

Usage

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;

Dependencies

In order to build the bindings for libcanberra, you need to have:

  • An Ada 2012 compiler

  • Alire

To use libcanberra, you need to have some backend installed:

  • libcanberra-pulse for the PulseAudio backend

Contributing

Please read the contributing guidelines before opening issues or pull requests.

License

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