Skip to content

Commit d9f27e1

Browse files
committed
dsp intro wip
1 parent e5d71a2 commit d9f27e1

File tree

1 file changed

+55
-17
lines changed

1 file changed

+55
-17
lines changed

src/signal_processing/intro.clj

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
:description "Starting the journey of DSP in Clojure."
55
:category :clojure
66
:type :post
7-
:date "2025-11-02"
7+
:date "2025-11-07"
88
:tags [:dsp :math :music]
99
:draft true}}}
1010
(ns signal-processing.intro
@@ -17,15 +17,35 @@
1717

1818
;; # Introduction to Digital Signal Processing
1919
;;
20-
;; Welcome! Let's explore how to generate and manipulate audio signals in Clojure.
21-
;; We'll start simple - creating a single tone - then build up to synthesizing
22-
;; a more complex sound like a violin.
20+
;; **Notes from the [Scicloj DSP Study Group](https://scicloj.github.io/docs/community/groups/dsp-study/)**
21+
;; *First meeting - Nov. 2nd 2025*
2322
;;
24-
;; ## What is Digital Signal Processing?
23+
;; Welcome! These are notes from our first study group session, where we're learning
24+
;; digital signal processing together using Clojure. We're following the excellent book
25+
;; [**Think DSP** by Allen B. Downey](https://greenteapress.com/wp/think-dsp/) (available free online).
26+
;;
27+
;; **Huge thanks to Professor Downey** for writing such an accessible and free introduction to DSP, and for sharing with us the work-in-progress notebooks of [Think DSP 2](https://allendowney.github.io/ThinkDSP2/index.html).
28+
;;
29+
;;;; ## What is Digital Signal Processing?
2530
;;
2631
;; Sound waves are continuous vibrations in the air. To work with them on a computer,
2732
;; we need to **sample** them - take measurements at regular intervals. The **sample rate**
2833
;; tells us how many measurements per second. CD-quality audio uses 44,100 samples per second.
34+
;;
35+
;; This session covers concepts from **Chapter 1: Sounds and Signals** of Think DSP.
36+
37+
;; ## Clojure Libraries We're Using
38+
;;
39+
;; To work with DSP in Clojure, we're using tools from the Scicloj ecosystem:
40+
;;
41+
;; - **[Kindly](https://scicloj.github.io/kindly-noted/kindly)** - Visualization protocol that renders our data as interactive HTML elements (through Clay)
42+
;; - **[dtype-next](https://github.com/cnuernber/dtype-next)** - Efficient numerical arrays and vectorized operations (like NumPy for Clojure)
43+
;; - **[Tablecloth](https://scicloj.github.io/tablecloth/)** - DataFrame library for data manipulation and transformation
44+
;; - **[Tableplot](https://scicloj.github.io/tableplot/)** - Declarative plotting library built on Plotly
45+
;;
46+
;; These libraries let us work with large audio datasets efficiently while keeping our code
47+
;; clean and interactive. The `tech.v3.datatype.functional` namespace (aliased as `dfn`) provides
48+
;; vectorized math operations that work on entire arrays at once - essential for DSP!
2949

3050
(require '[scicloj.kindly.v4.kind :as kind]
3151
'[tech.v3.datatype :as dtype]
@@ -42,6 +62,7 @@
4262
(def sample-rate 44100.0)
4363

4464
;; Now let's create the actual waveform. We'll generate 10 seconds of audio:
65+
;;
4566
;; - Create a time axis from 0 to 10 seconds
4667
;; - Calculate the sine wave: amplitude × sin(2π × frequency × time)
4768
;; - Store everything in a dataset so we can plot and analyze it
@@ -147,7 +168,16 @@ violin-components-dataset
147168
(tc/pivot->longer (complement #{:time})))
148169

149170
;; Plot all harmonics on the same chart, colored by frequency.
150-
;; Notice how the higher harmonics oscillate faster!
171+
;; Notice the mathematical relationships between these waves:
172+
;;
173+
;; - **A5 (880 Hz)** oscillates exactly twice as fast as A4 (440 Hz) - this is **one octave** higher
174+
;; - **E6 (1320 Hz)** is 3× the fundamental frequency (the 3rd harmonic)
175+
;; - **A6 (1760 Hz)** is 4× the fundamental (the 4th harmonic, two octaves up)
176+
;; - **C#7 (2200 Hz)** is 5× the fundamental (the 5th harmonic)
177+
;;
178+
;; These integer multiples create the **harmonic series**, which is fundamental to music theory
179+
;; and acoustics. When waves are related by simple ratios like 2:1, 3:1, 4:1, they blend together
180+
;; harmoniously - this is why octaves and perfect fifths sound so consonant!
151181

152182
(-> violin-components-dataset
153183
(tc/head 200)
@@ -192,20 +222,28 @@ violin-components-dataset
192222
(dfn// 7000.0)
193223
audio)
194224

195-
;; ## What's Next?
225+
;; ## What We Learned
226+
;;
227+
;; In this first session, we covered the fundamentals from Chapter 1 of Think DSP:
228+
;;
229+
;; - **Sampling and sample rates** - Converting continuous signals to discrete measurements
230+
;; - **Generating sine waves** - The building blocks of all sound
231+
;; - **Additive synthesis with harmonics** - Creating complex sounds from simple components
232+
;;
233+
;; ## Next Steps
234+
;;
235+
;; In our next study group meetings, we'll explore:
236+
;;
237+
;; - **Chapter 2:** Harmonics and the Fourier transform
238+
;; - **Chapter 3:** Non-periodic signals and spectrograms
239+
;; - **Chapter 4:** Noise and filtering
196240
;;
197-
;; You've now learned the fundamentals of digital signal processing:
198-
;; - Sampling and sample rates
199-
;; - Generating sine waves
200-
;; - Additive synthesis with harmonics
241+
;; Join us at the [Scicloj DSP Study Group](https://scicloj.github.io/docs/community/groups/dsp-study/)!
201242
;;
202-
;; From here, you could explore:
203-
;; - Envelopes (attack, decay, sustain, release) to shape sounds over time
204-
;; - Filters (low-pass, high-pass) to sculpt frequency content
205-
;; - Modulation (vibrato, tremolo) for expressive effects
206-
;; - The Fourier transform to analyze existing sounds
243+
;; ---
207244
;;
208-
;; Happy signal processing!
245+
;; *Again, huge thanks to Allen B. Downey for Think DSP. If you find this resource valuable,
246+
;; consider [supporting his work](https://greenteapress.com/wp/) or sharing it with others.*
209247

210248

211249

0 commit comments

Comments
 (0)