From 159c35f706de14f3e3c6942934532011a1d77277 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 9 Jan 2019 20:26:28 -0500 Subject: audio: Add public audio API. * chickadee/audio.scm: New file. * Makefile.am (SOURCES): Add it. * api.texi (Audio): Add docs. --- Makefile.am | 1 + chickadee/audio.scm | 763 ++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/api.texi | 458 ++++++++++++++++++++++++++++++- 3 files changed, 1220 insertions(+), 2 deletions(-) create mode 100644 chickadee/audio.scm diff --git a/Makefile.am b/Makefile.am index 6183b03..23d7e5a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -59,6 +59,7 @@ SOURCES = \ chickadee/audio/openal.scm \ chickadee/audio/vorbis.scm \ chickadee/audio/wav.scm \ + chickadee/audio.scm \ chickadee/render/color.scm \ chickadee/render/gl.scm \ chickadee/render/gpu.scm \ diff --git a/chickadee/audio.scm b/chickadee/audio.scm new file mode 100644 index 0000000..aa56dac --- /dev/null +++ b/chickadee/audio.scm @@ -0,0 +1,763 @@ +;;; Chickadee Game Toolkit +;;; Copyright © 2020, 2019 David Thompson +;;; +;;; Chickadee is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published +;;; by the Free Software Foundation, either version 3 of the License, +;;; or (at your option) any later version. +;;; +;;; Chickadee 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 General Public License +;;; along with this program. If not, see +;;; . + +;;; Commentary: +;; +;; Audio API. +;; +;;; Code: + +(define-module (chickadee audio) + #:use-module (chickadee array-list) + #:use-module (chickadee audio mpg123) + #:use-module ((chickadee audio openal) #:prefix openal:) + #:use-module (chickadee audio vorbis) + #:use-module (chickadee audio wav) + #:use-module (chickadee math) + #:use-module (chickadee math vector) + #:use-module (ice-9 format) + #:use-module (ice-9 match) + #:use-module (rnrs bytevectors) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-9) + #:use-module (srfi srfi-9 gnu) + #:export (init-audio + quit-audio + update-audio + load-audio + audio? + streaming-audio? + static-audio? + audio-mode + audio-duration + audio-bits-per-sample + audio-channels + audio-sample-rate + audio-play + make-source + source? + streaming-source? + static-source? + source-playing? + source-paused? + source-stopped? + source-pitch + source-volume + source-min-volume + source-max-volume + source-max-distance + source-reference-distance + source-rolloff-factor + source-cone-outer-volume + source-cone-inner-angle + source-cone-outer-angle + source-position + source-velocity + source-direction + source-relative? + source-play + source-pause + source-toggle + source-stop + source-rewind + set-source-audio! + set-source-loop! + set-source-pitch! + set-source-volume! + set-source-min-volume! + set-source-max-volume! + set-source-max-distance! + set-source-reference-distance! + set-source-rolloff-factor! + set-source-cone-outer-volume! + set-source-cone-inner-angle! + set-source-cone-outer-angle! + set-source-position! + set-source-velocity! + set-source-direction! + set-source-relative!) + #:re-export ((openal:listener-volume . listener-volume) + (openal:listener-position . listener-position) + (openal:listener-velocity . listener-velocity) + (openal:listener-orientation . listener-orientation) + (openal:set-listener-volume! . set-listener-volume!) + (openal:set-listener-position! . set-listener-position!) + (openal:set-listener-velocity! . set-listener-velocity!) + (openal:set-listener-orientation! . set-listener-orientation!) + (openal:doppler-factor . doppler-factor) + (openal:speed-of-sound . speed-of-sound) + (openal:distance-model . distance-model) + (openal:set-doppler-factor! . set-doppler-factor!) + (openal:set-speed-of-sound! . set-speed-of-sound!) + (openal:set-distance-model! . set-distance-model!))) + +(define %default-cone-outer-angle (* 2.0 pi)) +(define %default-max-distance (expt 2 31)) + +(define-record-type