diff options
author | David Thompson <dthompson2@worcester.edu> | 2022-10-23 07:41:32 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2022-10-23 07:41:32 -0400 |
commit | 808ea4175a2d91c1f21c2d0bf2c423da56172d25 (patch) | |
tree | 2e2b4519ae5c5c50210e96c2793410b3269b8ad9 /sdl2/audio.scm | |
parent | 34ec6b54f26445ff4a5d0740d477a06f55521f53 (diff) |
Add beginnings of audio API bindings.
Just a first baby step. Nothing usable yet.
Diffstat (limited to 'sdl2/audio.scm')
-rw-r--r-- | sdl2/audio.scm | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/sdl2/audio.scm b/sdl2/audio.scm new file mode 100644 index 0000000..0e35d4e --- /dev/null +++ b/sdl2/audio.scm @@ -0,0 +1,48 @@ +;;; guile-sdl2 --- FFI bindings for SDL2 +;;; Copyright © 2022 David Thompson <davet@gnu.org> +;;; +;;; This file is part of guile-sdl2. +;;; +;;; Guile-sdl2 is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU Lesser General Public License as +;;; published by the Free Software Foundation; either version 3 of the +;;; License, or (at your option) any later version. +;;; +;;; Guile-sdl2 is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU Lesser General Public +;;; License along with guile-sdl2. If not, see +;;; <http://www.gnu.org/licenses/>. + +;;; Commentary: +;; +;; Platform-independent audio API. +;; +;;; Code: + +(define-module (sdl2 audio) + #:use-module (sdl2) + #:use-module ((sdl2 bindings) #:prefix ffi:) + #:use-module (system foreign) + #:export (audio-device-name + num-audio-devices)) + +(define* (num-audio-devices #:optional capture?) + "Return the number of recording or playback audio devices available. + If CAPTURE is not given or #f, the number of playback devices is +returned. If CAPTURE? is #t, the number of recording devices is +returned." + (ffi:sdl-get-num-audio-devices (if capture? 1 0))) + +(define* (audio-device-name index #:optional capture?) + "Return the name of the audio device at INDEX. If CAPTURE? is not +given or #f, the name of the playback device for INDEX is returned. +If CAPTURE? is #t, the name of the recording device for INDEX is +returned." + (let ((ptr (ffi:sdl-get-audio-device-name index (if capture? 0 1)))) + (if (null-pointer? ptr) + #f + (pointer->string ptr)))) |