jarabica
The jarabica
package attempts to provide a type-safe, mildly object-oriented
frontend to the OpenAL API. Currently, it uses the
high-quality LWJGL bindings internally, and wraps
them with a thin layer of short-lived immutable types for safety and efficiency.
It strongly separates the API and implementation to allow for easy unit testing
and mocking of code that calls OpenAL.
Features
- Type-safe OpenAL frontend.
- Strong separation of API and implementation to allow for switching to different bindings at compile-time.
- Strongly-typed interfaces with a heavy emphasis on immutable value types.
- Fully documented (JavaDoc).
- Example code included.
- High coverage test suite.
- OSGi-ready
- JPMS-ready
- ISC license.
Usage
The jarabica
package works in the same manner as the OpenAL API, but with
adjustments to make the API feel more like a Java API. Create a device factory
from which to create devices. The device factory implementation chosen
essentially decides which underlying OpenAL bindings will be used; currently,
the only real implementation is based on LWJGL.
val devices = new JALWDeviceFactory();
Enumerate the available audio devices:
List<JADeviceDescription> deviceDescriptions = devices.enumerateDevices();
Inspect the list of returned devices, and select the one that is most appropriate to your application. Use the description of the device to open the device:
try (JADeviceType device = devices.openDevice(deviceDescriptions.get(0))) {
...
}
With the open device, it's necessary to create a context.
JAContextType context = device.createContext();
The context value follows the usual OpenAL thread-safety rules; a context must be made current on the current thread before any operations can be performed using it. Creating a context automatically makes it current on the calling thread.
The context value can then be used to create OpenAL sources and buffers in a manner familiar to anyone experienced with OpenAL.
try (var source = context.createSource()) {
try (var buffer = context.createBuffer()) {
...
}
}
Example Application
A demo application is included that demonstrates how to use the API correctly, and also demonstrates numerous extensions such as the ubiquitous EFX extension.
Releases & Development Snapshots
Releases
You can subscribe to the atom feed to be notified of project releases.
The most recently released version of the package is 1.0.0.
1.0.0 Release (2024-06-01Z)
- Initial release.
The compiled artifacts for the release (and all previous releases) are available on Maven Central.
Maven Modules
<dependency> <group>com.io7m.jarabica</group> <artifactId>com.io7m.jarabica.api</artifactId> <version>1.0.0</version> </dependency><dependency> <group>com.io7m.jarabica</group> <artifactId>com.io7m.jarabica.tests</artifactId> <version>1.0.0</version> </dependency><dependency> <group>com.io7m.jarabica</group> <artifactId>com.io7m.jarabica.lwjgl</artifactId> <version>1.0.0</version> </dependency><dependency> <group>com.io7m.jarabica</group> <artifactId>com.io7m.jarabica.extensions.efx</artifactId> <version>1.0.0</version> </dependency><dependency> <group>com.io7m.jarabica</group> <artifactId>com.io7m.jarabica.demo</artifactId> <version>1.0.0</version> </dependency>
Development Snapshots
At the time of writing, the current unstable development version of the package is 1.0.1-SNAPSHOT.
Development snapshots may be available in the Central Portal Snapshots repository. Snapshots are published to this repository every time the project is built by the project's continuous integration system, but snapshots do expire after around ninety days and so may or may not be available depending on when a build of the package was last triggered.
Manual
This project does not have any user manuals or other documentation beyond what might be present on the page above.
Sources
This project uses Git to manage source code.
Repository: https://www.github.com/io7m-com/jarabica
$ git clone --recursive https://www.github.com/io7m-com/jarabica
Issues
This project uses GitHub Issues to track issues.
License
Copyright © 2023 Mark Raynsford <code@io7m.com> https://www.io7m.com Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.