3s: positional audio and mixing
(require 3s) | package: 3s |
The 3s module provides a system for positional audio and mixing of sound effects. It is intended for interactive applications and integrates with lux. Presently it uses the openal library, but in principle does not require its use.
The overall model of 3s is to parameterize sounds over the world state, so that sounds created in the past can be updated (paused, move position, have the content changed, etc) by initially creating them so that they inspect the world state for cues to such updates.
The key function, render-sound, is called regularly (i.e., once per tick) and receives the updated world state, along with any additional sounds created during that tick.
1 User API Reference
procedure
(path->audio p) → audio?
p : path-string?
struct
(struct sound-state (audio posn gain relative? looping? paused?))
audio : audio? posn : inexact? gain : inexact? relative? : boolean? looping? : boolean? paused? : boolean?
value
value
procedure
(background a-f [ #:gain gain #:pause-f pause-f]) → sound/c a-f : (-> any/c audio?) gain : inexact? = 1.0 pause-f : (-> any/c boolean?) = (λ (w) #f)
procedure
(sound-at a p [ #:gain gain #:looping? looping? #:pause-f pause-f]) → sound/c a : audio? p : inexact? gain : inexact? = 1.0 looping? : boolean? = #f pause-f : (-> any/c boolean?) = (λ (w) #f)
procedure
(sound-on a p-f [ #:gain gain #:looping? looping? #:pause-f pause-f]) → sound/c a : audio? p-f : (-> any/c inexact?) gain : inexact? = 1.0 looping? : boolean? = #f pause-f : (-> any/c boolean?) = (λ (w) #f)
2 Internal API Reference
procedure
(sound-context? x) → boolean?
x : any/c
procedure
procedure
(sound-context-destroy! sc) → void?
sc : sound-context?
procedure
(system-state? x) → boolean?
x : any/c
procedure
sc : sound-context?
procedure
(sound-pause! ss) → void?
ss : system-state?
procedure
(sound-unpause! ss) → void?
ss : system-state?
procedure
(sound-destroy! ss) → void?
ss : system-state?
procedure
(render-sound ss scale lp w sounds) → system-state?
ss : system-state? scale : real? lp : inexact? w : any/c sounds : sound-scape/c
3 Integrating with lux
(require lux/chaos/3s) | package: 3s |
3s is designed to integrate with lux through the lux/chaos/3s module, which provides a chaos for sound scapes.
word-event is never called with events from this chaos.
The values that word-output should return are four element vectors where the elements correspond to the last four arguments of render-sound: the sound scale, the listener position, the world value, and the list of new sounds.