Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/kernel/ui/chirp.h # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / kernel / ui / chirp.h` 42 lines ยท 2360 bytes Raw Blame History 1 /* chirp.h -- the startup sound: a quick "blirp", the last moment of the chirp 2 * two bodies make as they spiral into each other and merge (a gravitational 3 * wave), raised into hearing and timed to the night sky of the startup 4 * (ui/night.h). Silent until CK_CHIRP_RISE_MS before the merger; then it 5 * comes in over CK_CHIRP_IN_MS and sweeps up in pitch and loudness the way 6 * the real wave does (pitch as t^(-3/8), loudness as pitch^(2/3), t the time 7 * left), with its peak at the merger (CK_NIGHT_MERGE_MS); then a short 8 * ringing fade. Under a second in all. Made from that formula, no recorded 9 * sound. Integer only (the kernel builds with -mgeneral-regs-only), 10 * freestanding, no memory of its own beyond a sine table. Host tested in 11 * ui/tests/chirp_test.c. */ 12 #ifndef AIENOS_CHIRP_H 13 #define AIENOS_CHIRP_H 14 #include 15 #include "night.h" 16 17 #define CK_CHIRP_RATE 48000u /* frames a second; each frame is a left and a right sample, 16 bits */ 18 #define CK_CHIRP_FROM_HZ 200u /* the pitch the sweep starts at */ 19 #define CK_CHIRP_TO_HZ 1000u /* the pitch at the merger, held through the fade */ 20 #define CK_CHIRP_PEAK 22937 /* 70% of full scale */ 21 #define CK_CHIRP_RISE_MS 600u /* the sweep up to the merger */ 22 #define CK_CHIRP_IN_MS 40u /* the sound comes in over this, just before the sweep */ 23 #define CK_CHIRP_START_MS (CK_NIGHT_MERGE_MS - CK_CHIRP_RISE_MS) 24 #define CK_CHIRP_END_MS (CK_NIGHT_MERGE_MS + 300u) /* the ring has died away */ 25 #define CK_CHIRP_FRAMES (CK_CHIRP_RATE / 1000u * CK_CHIRP_END_MS) 26 27 /* Writes frames [from, from + n) as left, right pairs into out (2n samples), 28 * frame 0 being the night's 0 ms. Silent past CK_CHIRP_FRAMES. Any frame 29 * can be asked for in any order: each is worked out from the formula. */ 30 void ck_chirp_fill(int16_t *out, uint32_t from, uint32_t n); 31 32 /* The pitch in Hz and the loudness (0..CK_CHIRP_PEAK) at a frame. */ 33 uint32_t ck_chirp_hz(uint32_t frame); 34 uint32_t ck_chirp_level(uint32_t frame); 35 36 /* The chirp at 44.1 kHz instead: frames [from, from + n) of that rate, frame 37 * 0 the night's 0 ms, each sample in the top 16 bits of a 32-bit slot (a 38 * 24-bit converter's layout), left and right. */ 39 #define CK_CHIRP_RATE_441 44100u 40 #define CK_CHIRP_FRAMES_441 (CK_CHIRP_RATE_441 / 100u * CK_CHIRP_END_MS / 10u) 41 void ck_chirp_fill_441(int32_t *out, uint32_t from, uint32_t n); 42 #endif