summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/al.zig12
-rw-r--r--src/sf.zig2
-rw-r--r--src/zeal.zig17
3 files changed, 27 insertions, 4 deletions
diff --git a/src/al.zig b/src/al.zig
index 7b2e6db..bbde02e 100644
--- a/src/al.zig
+++ b/src/al.zig
@@ -18,7 +18,10 @@
 
 const Child = @import("std").meta.Child;
 
-usingnamespace @cImport(@cInclude("AL/al.h"));
+usingnamespace @cImport({
+    @cInclude("AL/al.h");
+    @cInclude("AL/alext.h");
+});
 
 pub const Error = error {
     /// Bad name (ID) passed to an OpenAL function.
@@ -33,12 +36,17 @@ pub const Error = error {
     OutOfMemory,
 };
 
+pub const FALSE = AL_FALSE;
+pub const TRUE = AL_TRUE;
+pub const AUTO = AL_AUTO_SOFT;
+
 pub const BUFFER = AL_BUFFER;
 pub const POSITION = AL_POSITION;
 pub const ORIENTATION = AL_ORIENTATION;
 pub const PLAYING = AL_PLAYING;
 pub const SEC_OFFSET = AL_SEC_OFFSET;
 pub const SOURCE_STATE = AL_SOURCE_STATE;
+pub const SOURCE_SPATIALIZE = AL_SOURCE_SPATIALIZE_SOFT;
 
 pub const listener = struct {
     /// Set a property for the listener.
@@ -211,7 +219,5 @@ pub const source = struct {
     }
 };
 
-// alGetSourcei
 // alSourcePause
-// alSourcePlay
 // alSourceStop
diff --git a/src/sf.zig b/src/sf.zig
index a95999c..a63da19 100644
--- a/src/sf.zig
+++ b/src/sf.zig
@@ -67,7 +67,7 @@ pub const SndFile = struct {
             .channels = info.channels,
             .format = info.format,
             .sections = info.sections,
-            .seekable = if (info.seekable == 0) false else true,
+            .seekable = info.seekable != 0,
         };
     }
 
diff --git a/src/zeal.zig b/src/zeal.zig
index 26dffa8..af9fd85 100644
--- a/src/zeal.zig
+++ b/src/zeal.zig
@@ -35,6 +35,10 @@ pub const Device = struct {
         return Device{ .pimpl = try alc.openDevice(name) };
     }
 
+    pub fn enabledHrtf(self: Device) alc.Error!bool {
+        return 0 != try alc.getInt(self.pimpl, alc.HRTF);
+    }
+
     pub fn deinit(self: Device) alc.Error!void {
         try alc.closeDevice(self.pimpl);
     }
@@ -152,6 +156,19 @@ pub const Source = struct {
         try al.source.destroy(&self.reference);
     }
 
+    /// Specify if the source always has 3D spatialization features (al.ON),
+    /// never has 3D spatialization features (al.OFF), or if spatialization
+    /// is enabled based on playing a mono sound or not (al.AUTO, default).
+    pub fn setSpatialize(self: Source, value: i32) Error!void {
+        try checkContext(self.context);
+        try al.source.set(self.reference, al.SOURCE_SPATIALIZE, value);
+    }
+
+    pub fn setPosition(self: Source, position: [3]f32) Error!void {
+        try checkContext(self.context);
+        try al.source.set(self.reference, al.POSITION, position);
+    }
+
     pub fn isPlaying(self: Source) Error!bool {
         try checkContext(self.context);
         const state = try al.source.get(i32, self.reference, al.SOURCE_STATE);