structClip
struct Clip
samples: int
frames: int
endsound: plays WAV files and made-up tones through the speakers, many at once. use "sound.jamo"
Sound goes out through waveOut, 44100 frames a second in 16-bit stereo, as six short buffers that take turns: while the speakers play some, update() mixes the next ones. Windows reads those buffers and writes their headers whenever it likes, so they live in memory from VirtualAlloc, which the memory cleaner never sees, and only close() gives it back. The block: six 48-byte headers, then at 512 the six buffers of 2048 bytes each. A clip keeps its frames as 16-bit stereo with 32768 added, so each sample reads back with peek_u16.
struct Clip
samples: int
frames: int
endstruct Voice
clip: Clip
place: int
volume: float
looping: bool
playing: bool
endstruct Sound
device: int
block: int
next: int
mix: int
voices: [Voice]
volume: float
gaps: int
started: bool
silent: bool
open: bool
closed_by_program: bool
endfunc start_sound(): Sound
Opens the PC's default speakers
func start_sound_device(number: int): Sound
Opens one sound device by number, from 0. A PC without it runs on in silence, with a note saying so
func Sound.quiet()
Keeps tests silent: the speakers still play, at no volume. If Windows can't turn the volume down, only silence goes out
func Sound.must_be_open()
func Sound.has_device(): bool
True when sound really reaches a device
func Sound.close()
Stops every sound and lets the speakers go
func Sound.play(clip: Clip): Voice
func Sound.play_loop(clip: Clip): Voice
Plays a clip over and over until it's stopped
func Sound.start_voice(clip: Clip, looping: bool): Voice
func Sound.set_volume(volume: float)
Sets the volume of everything, from 0.0 to 1.0. Above 1.0 makes it louder, up to 4.0
func Sound.stop_all()
func Sound.playing(): int
How many sounds are playing now
func Sound.gaps(): int
How many times the speakers ran out of sound, because update() wasn't called often enough
func Sound.played(): int
How many frames the speakers have played since the start
func Voice.stop()
func Voice.is_playing(): bool
func Voice.set_volume(volume: float)
func sound_volume(volume: float): float
func Sound.update()
Mixes the next sound for the speakers. Call it once a frame
func Sound.fill(data: int)
Mixes 512 frames into one buffer
func Clip.seconds(): float
How long a clip lasts, in seconds
func tone(frequency: float, seconds: float, wave: string): Clip
Makes a tone: "sine", "square", "saw", "triangle" or "noise", fading in and out over 5 ms
func silence(seconds: float): Clip
A clip of silence, to mix other clips into, like a song made from notes
func Clip.mix(other: Clip, at: float, volume: float)
Adds another clip into this one, starting at a time in seconds, at a volume from 0.0 to 4.0. The part that goes past the end is left off, and loud parts are kept from wrapping around
func sound_sine(x: float): float
The sine of a whole turn times x, for x from 0.0 to 1.0
func sound_damaged(path: string, why: string)
func sound_number(data: string, place: int, size: int): int
func sound_power(i: int): int
func load_sound(path: string): Clip
Reads a WAV file: 8, 16, 24 or 32-bit, or 32-bit float, in mono or stereo, at any rate
func sound_sample(raw: int, at: int, kind: int, bits: int): int
One sample as a 16-bit number