From 54746411fef4a35461898429f33c230d4eab3f65 Mon Sep 17 00:00:00 2001
From: Akshay Nair <phenax5@gmail.com>
Date: Fri, 12 Jun 2026 14:44:38 +0530
Subject: Some cool alien shit with spectrogram

---
 src/spectrogramming.audio.sql | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 src/spectrogramming.audio.sql

(limited to 'src/spectrogramming.audio.sql')

diff --git a/src/spectrogramming.audio.sql b/src/spectrogramming.audio.sql
new file mode 100644
index 0000000..3add75f
--- /dev/null
+++ b/src/spectrogramming.audio.sql
@@ -0,0 +1,15 @@
+INSERT OR REPLACE INTO audio_tracks (id, sample_rate, format) VALUES ('spectrogramming', 8000, 'u8') RETURNING id;
+
+WITH RECURSIVE
+  audio AS
+    (SELECT *, 160 AS gain FROM audio_tracks WHERE id = 'spectrogramming'),
+  note_positions(position) AS
+    (SELECT 0 UNION ALL
+      SELECT position + 1 FROM note_positions, audio
+        WHERE position < 100000),
+  samples(value, position) AS
+    (SELECT
+      (100.0*SIN(position * 2.0 / sample_rate) + 1.0) / 2.0 * gain
+      , position
+    FROM note_positions, audio)
+INSERT INTO audio_track_samples (audio_track_id, value, position) SELECT 'spectrogramming', value, position FROM samples ORDER BY position;
-- 
cgit v1.3.1

