hal/sdl/audio.lisp
The interleaved staging buffer, grown to the largest push so far.
One playback stream on the default audio device.
Open a playback stream taking CHANNELS-channel float frames at rate.
The device is opened at whatever it prefers; SDL converts. Playback starts at once, so a sink with nothing queued is one playing silence.
Destroy sink's stream, dropping whatever was still queued. Idempotent.
Queue count mono samples for sink, placed between the channels by left and
right. A two-channel sink gets the sample times left on the left and times
right on the right; any other channel count gets it times left everywhere.
This is where a point source becomes a stereo image: the film's sound is one signal, and its place in the room is decided per push, so a listener who walks past the screen hears it cross over.
How many frames have gone out: pushed less still queued. This is the sink's clock, in frames at its own rate.
Drop everything queued, so the next push is heard at once.
What is dropped was never played; the clock must not count it.
Set sink's overall loudness, 0 silent, 1 as decoded.
One playback stream on the default audio device.
32-bit float, native (little) endian.
(&key (rate 48000) (channels 2))Open a playback stream taking CHANNELS-channel float frames at RATE. The device is opened at whatever it prefers; SDL converts. Playback starts at once, so a sink with nothing queued is one playing silence.
(&body body)(sink)Logical negation of one test or raw truth value.
(sink)(sink frames)Test whether one compatible scalar is less than another.
Multiplication and scalar scaling.
(sink samples count &key (left 1.0) (right 1.0))Queue COUNT mono SAMPLES for SINK, placed between the channels by LEFT and RIGHT. A two-channel sink gets the sample times LEFT on the left and times RIGHT on the right; any other channel count gets it times LEFT everywhere. This is where a point source becomes a stereo image: the film's sound is one signal, and its…
Headings, paragraphs, figures and their IDs, mentions, marks.
Test whether two compatible scalars are equal.
Sample a two-dimensional texture through a sampler at a UV coordinate.
Addition over compatible quantities.
(sink)How many frames have gone out: pushed less still queued. This is the sink's clock, in frames at its own rate.
The maximum of compatible quantities.
Subtraction or unary negation.
Division of two represented quantities.
Convert one scalar float or unsigned value to a 32-bit float.
(sink)
Sound out, through SDL3.
An
audio-sinkis one SDL audio stream bound to the default playback device: the caller pushes interleaved single-float frames at the rate it has them and SDL resamples, mixes, and paces them out to the hardware on its own thread. Everything here is thread-safe in SDL3, so a decoder may feed the sink from wherever it runs while the render thread reads the clock and turns the gain.The clock is the point. How many frames have been handed over minus how many SDL still holds is how many have gone out the speaker, and that -- not a wall clock -- is what a picture should be shown against, because the ear notices a lip out of step long before the eye notices a picture held a frame too long.