Entropie git · main
Entropie festival game; first steps
C 88.5% Markdown 9.1% GLSL 2.3%git clone https://git.christianimmanuel.de/games/Entropie.gitwget https://git.christianimmanuel.de/games/Entropie/archive/Entropie.tar.gzentropie/src/core/audio.h raw
#ifndef CORE_AUDIO_H
#define CORE_AUDIO_H
/*
* Sound out (SDL3). Everything is made up on the fly - noise, tones, filters,
* envelopes - no sound files. Short voices (a step, a chop, a clink) play
* once; steady beds (wind, rain, a fire, ...) run all the time and are only
* turned up and down. The game sets what plays; the audio thread mixes it.
* Without a sound device everything here quietly does nothing.
*/
#include <stdbool.h>
typedef enum {
WAVE_NOISE, /* white noise (shaped by the filters) */
WAVE_SINE, /* a tone, gliding from freq to freq_end */
WAVE_SAW, /* a buzzing tone */
WAVE_CRACKLE /* sparse clicks (gravel, glass, twigs): freq = clicks a second */
} Wave;
typedef struct {
Wave wave;
float freq, freq_end; /* Hz (freq_end 0: stays at freq) */
float low, high; /* filters: lowpass and highpass cutoff (Hz, 0: none) */
float attack, decay; /* s: up in attack, then dying away (decay: down to a third) */
float length; /* s: cut off after this (0: when it's died away) */
float gain; /* 0..1 */
float pan; /* -1 left .. +1 right */
float delay; /* s before it starts */
} Voice;
typedef enum {
BED_WIND, /* param: 0..1 how strong (brighter, gustier) */
BED_RAIN, /* param: 0 out in it .. 1 heard through a tent (dull, drumming) */
BED_FIRE, /* param: 0..1 how big */
BED_SAW, /* param: 0 idling .. 1 cutting (a chainsaw) */
BED_ENGINE, /* param: 0..1 how fast (the car) */
BED_CRICKETS, /* param: unused */
BED_HOSE, /* param: unused */
BED_FLOOR, /* a floor's music (BED_FLOOR + 0..3: rock, psytrance, hand drums, techno); param: 0 near .. 1 far off (muffled) */
BED_COUNT = BED_FLOOR + 4
} Bed;
/* Opens the sound device (false: none - the game goes on silent). */
bool Audio_init(void);
void Audio_shutdown(void);
/* One short sound. */
void Audio_play(const Voice *voice);
/* A bed this loud (0: off), from this side, its param (eased over a moment). */
void Audio_bed(Bed bed, float gain, float pan, float param);
/* All quiet (M), or not; and everything paused (menus: the beds go quiet). */
void Audio_mute(bool mute);
bool Audio_muted(void);
void Audio_pause(bool paused);
#endif /* CORE_AUDIO_H */