Compare commits
6 Commits
songs/wank
...
3621ff049c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3621ff049c | ||
| f24b777d95 | |||
| 6d9564af66 | |||
|
|
61ea53780f | ||
|
|
f351086490 | ||
|
|
a66154d701 |
252
wip/dsp.md
Normal file
252
wip/dsp.md
Normal file
@@ -0,0 +1,252 @@
|
|||||||
|
# digital signal processing
|
||||||
|
|
||||||
|
A boring lecture about signals and systems, and its digital implementation in DSP.
|
||||||
|
Borderline 'song' less 'poetic'.
|
||||||
|
|
||||||
|
The actual material (text that is read out by a vocal synthesiser) is in Japanese.
|
||||||
|
|
||||||
|
## Simple notes
|
||||||
|
|
||||||
|
For things that are not easily pronounced (e.g. formulae, expressions, symbols), inclusive either:
|
||||||
|
- Mark how the thing should be pronounced in a pair of adjacent parentheses
|
||||||
|
- e.g. H(ω) (エッチオメガ)
|
||||||
|
- (inclusive) Or don't embed these elements too deep into the flow of sentences; use common, laymen's language instead
|
||||||
|
- e.g. not `Fs/2(サンプリング周波数の半分)までの帯域を忠実に再構成できる` but `サンプリング周波数の半分までの帯域を忠実に再構成できる`
|
||||||
|
|
||||||
|
The general direction is to stay boring, but the deadpan kind of boring. Keep technical language appearing but explain things in more laymen's language.
|
||||||
|
|
||||||
|
## Outline
|
||||||
|
|
||||||
|
### 1. Signals and systems
|
||||||
|
- What is a signal
|
||||||
|
- A function of one or more variables carrying information; here, amplitude over time
|
||||||
|
- What is a system
|
||||||
|
- A system maps an input signal to an output signal
|
||||||
|
- Characterized entirely by its behavior on inputs — the internals are not required
|
||||||
|
- Most systems are nonlinear — linearity is a special property, not the default
|
||||||
|
- Linearity: superposition holds — scaling and additivity
|
||||||
|
- Most physical systems violate this under sufficient conditions (e.g. overdrive: linear below clip threshold, nonlinear at and above it)
|
||||||
|
- Time-invariance
|
||||||
|
- A time-invariant system responds identically regardless of when the input arrives
|
||||||
|
- Violation: any system with time-varying parameters (e.g. modulated effects)
|
||||||
|
- LTI as the restricted, studied case
|
||||||
|
- Satisfies both simultaneously — analytically tractable
|
||||||
|
- A deliberate simplification; not a description of typical reality
|
||||||
|
- The impulse signal; impulse response
|
||||||
|
- The impulse: unit energy concentrated at a single point in time
|
||||||
|
- The impulse response: what an LTI system outputs when fed an impulse
|
||||||
|
- Completely characterizes the system
|
||||||
|
- The impulse response is a function — it exists in the same space as signals; systems are absorbed into signal space
|
||||||
|
|
||||||
|
### 2. LTI and convolution
|
||||||
|
- An LTI system is fully characterized by its impulse response
|
||||||
|
- Any input decomposes into scaled, shifted impulses
|
||||||
|
- By linearity and time-invariance, the output is the corresponding sum of scaled, shifted impulse responses
|
||||||
|
- Convolution as the operation
|
||||||
|
- That sum is convolution: y = x * h
|
||||||
|
- In continuous time, this is an integral: y(t) = ∫ x(τ) h(t−τ) dτ
|
||||||
|
- Symmetric in its arguments: x * h = h * x
|
||||||
|
- Signal and system are interchangeable operands — both are functions; convolution makes no distinction between them
|
||||||
|
- Commutativity: for LTI systems, order of composition is irrelevant
|
||||||
|
- Two LTI systems in series have a combined impulse response equal to the convolution of each
|
||||||
|
- h₁ * h₂ = h₂ * h₁ — order does not affect the result
|
||||||
|
|
||||||
|
### 3. Signal transformation
|
||||||
|
- A signal can be represented equivalently in the frequency domain
|
||||||
|
- The Fourier transform: s(t) ↔ S(ω); any signal is a sum of sinusoids at different frequencies
|
||||||
|
- Each sinusoid has a frequency, amplitude, and phase
|
||||||
|
- S(ω) is the spectrum: how much of each frequency is present
|
||||||
|
- Analog signals carry components from DC to arbitrarily high frequencies
|
||||||
|
|
||||||
|
### 4. Filters
|
||||||
|
- A filter is an LTI system — characterized by its frequency response H(ω)
|
||||||
|
- H(ω) is the Fourier transform of the impulse response h(t)
|
||||||
|
- Filtering: shaping a signal's spectrum by selectively attenuating or preserving frequency bands
|
||||||
|
- Basic types: lowpass, highpass, bandpass
|
||||||
|
- Lowpass: passes low frequencies, attenuates high
|
||||||
|
- Highpass: passes high frequencies, attenuates low
|
||||||
|
- Bandpass: passes a target band, attenuates above and below
|
||||||
|
- In discrete time: finite impulse response (FIR) and infinite impulse response (IIR) filters
|
||||||
|
|
||||||
|
### 5. Discrete time
|
||||||
|
- Moving from continuous to discrete: two axes require discretization
|
||||||
|
- Amplitude: N bits → 2^N discrete levels
|
||||||
|
- Each sample is mapped to the nearest representable level; the error is quantization noise
|
||||||
|
- The representable range is fixed by design and hardware (ADC/DAC reference voltage)
|
||||||
|
- Hard clip at the boundary — analog degrades gradually toward its physical limits; digital does not
|
||||||
|
- Time axis: sampling captures only finitely many values per second
|
||||||
|
- Analog signals contain frequency components up to infinity — a discrete system cannot represent all of them
|
||||||
|
- Discrete time is viable when the high-frequency components that would be lost are not needed
|
||||||
|
- Nyquist: given sampling rate Fs, faithful reconstruction is guaranteed up to Fs/2
|
||||||
|
- What Fs/2 should be is an applied engineering question — Nyquist does not answer it
|
||||||
|
- Components above Fs/2 are lost: aliasing
|
||||||
|
- LTI and convolution hold in discrete time — commutativity survives
|
||||||
|
- Convolution becomes a sum (finite for FIR, infinite for IIR)
|
||||||
|
|
||||||
|
### 6. Nonlinearity and consequences
|
||||||
|
- Real systems violate LTI: time-varying parameters, feedback, saturation
|
||||||
|
- Each breaks a different condition: time-variance breaks TI, feedback and saturation break linearity
|
||||||
|
- Examples
|
||||||
|
- Modulated delay (chorus, flanger): delay time varies with time → time-invariance breaks; same input at different times yields different output
|
||||||
|
- Overdrive: saturation above threshold → linearity breaks; EQ before overdrive ≠ overdrive before EQ
|
||||||
|
- Commutativity breaks — order of composition is no longer irrelevant
|
||||||
|
- h₁ followed by h₂ ≠ h₂ followed by h₁ in general
|
||||||
|
- No universal rule; behavior must be examined per case
|
||||||
|
|
||||||
|
## Text (lyrics if you insist)
|
||||||
|
|
||||||
|
信号とシステム、そしてデジタル信号処理について説明する。
|
||||||
|
|
||||||
|
### 1. 信号とシステム
|
||||||
|
|
||||||
|
まず信号とは何か、次にシステムとは何かを定義し、その上でシステムの性質を議論する。
|
||||||
|
|
||||||
|
信号とは情報を運ぶものである。
|
||||||
|
ここでは時間の経過とともに振幅がどう変化するか、その関数として扱う。
|
||||||
|
|
||||||
|
システムとは、入力信号を受け取り、出力信号を返す操作である。
|
||||||
|
箱の中身は問わない。何を入れたら何が出るか、その関係だけがシステムを定義する。
|
||||||
|
|
||||||
|
システムの性質として、まず線形性を取り上げる。
|
||||||
|
線形システムとは、重ね合わせの原理が成り立つシステムである。
|
||||||
|
入力を2倍にすれば出力も2倍になる。二つの入力を足し合わせたときの出力は、それぞれ単独で入れたときの出力を足したものと等しい。
|
||||||
|
この二つの条件が揃ったとき、そのシステムは線形である。
|
||||||
|
|
||||||
|
ただし注意が必要である。
|
||||||
|
多くの物理システムはこの条件を満たさない。線形性は特殊な性質であり、当たり前ではない。
|
||||||
|
|
||||||
|
次に時不変性について述べる。
|
||||||
|
時不変システムとは、入力を時間軸上でずらしたとき、出力も同じだけずれるシステムである。
|
||||||
|
今日と明日で同じ入力を与えれば、同じ出力が返ってくる。
|
||||||
|
パラメータが時間とともに変わるシステムは、この条件を満たさない。
|
||||||
|
|
||||||
|
線形かつ時不変なシステムを、線形時不変システムと呼ぶ。以降の議論はこれを対象とする。
|
||||||
|
これは解析的に扱いやすい、意図的に絞った特殊ケースである。現実の典型ではない。
|
||||||
|
|
||||||
|
線形時不変システムをさらに掘り下げる前に、インパルス信号を導入する。
|
||||||
|
インパルス信号とは、単一の瞬間に単位エネルギーが集中した信号である。実際には存在しない理想だが、有用な概念道具である。
|
||||||
|
このインパルスを線形時不変システムに入力したときの出力を、インパルス応答と呼ぶ。
|
||||||
|
|
||||||
|
インパルス応答は、そのシステムを完全に決定する。
|
||||||
|
なぜなら、任意の入力はインパルスの積み重ねとして分解できるからである。インパルス応答さえ分かれば、どんな入力に対する出力も計算できる。
|
||||||
|
|
||||||
|
もう一つ重要なことがある。
|
||||||
|
インパルス応答は、システムの出力でありながら、信号と同じ種類の関数である。
|
||||||
|
つまりシステムは、信号と同じ操作の空間に置くことができる。システムと信号の区別は、操作の上では消える。
|
||||||
|
|
||||||
|
### 2. 線形時不変システムと畳み込み
|
||||||
|
|
||||||
|
なぜインパルス応答がシステムを完全に決定できるのか。
|
||||||
|
|
||||||
|
任意の入力信号は、大きさの異なるインパルスを時間軸上に並べたものとして表せる。
|
||||||
|
線形時不変システムはそれぞれのインパルスに独立に反応し、その応答を全て重ね合わせる。
|
||||||
|
この重ね合わせ全体の操作を、畳み込みと呼ぶ。
|
||||||
|
|
||||||
|
連続時間においては、畳み込みは積分として定義される。
|
||||||
|
時間軸に沿って入力を少しずつずらしながら、そのずれに対応するインパルス応答を強さに応じて足し合わせる。その積分の結果が出力である。
|
||||||
|
|
||||||
|
y = x * h (y イコール x 畳み込み h)
|
||||||
|
|
||||||
|
ここで興味深い性質がある。畳み込みはその二つの引数に対して対称である。
|
||||||
|
x * h = h * x (x 畳み込み h イコール h 畳み込み x)
|
||||||
|
これは単なる計算上の便宜ではない。x と h が同じ種類の対象であること、つまりシステムが信号空間に吸収されることの、自然な帰結である。
|
||||||
|
|
||||||
|
この対称性から、実用上重要な結論が出てくる。
|
||||||
|
二つの線形時不変システムを直列につないだとき、合成されたシステムのインパルス応答は、各インパルス応答の畳み込みである。
|
||||||
|
h₁ * h₂ = h₂ * h₁ (h1 畳み込み h2 イコール h2 畳み込み h1)
|
||||||
|
どちらを先につないでも、結果は変わらない。
|
||||||
|
|
||||||
|
### 3. 信号変換
|
||||||
|
|
||||||
|
これまで信号を時間の関数として扱ってきた。しかし同じ信号を、全く別の視点から見ることができる。
|
||||||
|
それが周波数領域という見方である。
|
||||||
|
|
||||||
|
フーリエ変換がそれを可能にする。
|
||||||
|
s(t)(エス ティー)と S(ω)(エス オメガ)は同じ信号の二つの顔である。
|
||||||
|
一方は時間の経過を、もう一方は周波数の分布を示す。
|
||||||
|
|
||||||
|
フーリエ変換が言っているのは、こういうことである。
|
||||||
|
どんな信号も、周波数の異なる正弦波をいくつか重ね合わせたものとして表せる。
|
||||||
|
たとえば楽器の音を思い浮かべてほしい。基音があり、倍音がある。
|
||||||
|
それぞれが異なる周波数の正弦波で、それらが重なって一つの音色になる。
|
||||||
|
S(ω) はその内訳である。どの周波数の成分がどれだけの強さで含まれているか、それがスペクトルである。
|
||||||
|
|
||||||
|
アナログ信号は原理的には、ゼロから無限大まであらゆる周波数成分を持ちうる。
|
||||||
|
このことが、後の離散化の議論に関わってくる。
|
||||||
|
|
||||||
|
### 4. フィルタ
|
||||||
|
|
||||||
|
フィルタは線形時不変システムの実用的な例である。
|
||||||
|
フーリエ変換の言葉で言えば、フィルタとは信号のスペクトルを形作るシステムである。
|
||||||
|
|
||||||
|
フィルタを特徴づけるのは周波数応答 H(ω)(エイチ オメガ)である。
|
||||||
|
これはインパルス応答 h(t) をフーリエ変換したものである。
|
||||||
|
インパルス応答が時間領域でシステムを表すように、周波数応答は周波数領域でそのシステムを表している。
|
||||||
|
|
||||||
|
フィルタの働きは、周波数によって信号をふるいにかけることである。
|
||||||
|
基本的な分類としてローパス、ハイパス、バンドパスがある。
|
||||||
|
ローパスフィルタは低い周波数だけを通し、高い周波数を削ぎ落とす。
|
||||||
|
ハイパスフィルタはその逆で、高い周波数を通し、低い周波数を削ぐ。
|
||||||
|
バンドパスフィルタは特定の帯域だけを通し、それより低い成分も高い成分も減衰させる。
|
||||||
|
|
||||||
|
離散時間においては、有限インパルス応答フィルタと無限インパルス応答フィルタの区別がある。
|
||||||
|
前者のインパルス応答はある時点で終わる。後者は終わらない。
|
||||||
|
|
||||||
|
### 5. 離散時間
|
||||||
|
|
||||||
|
ここで話題を変える。これまでの議論は連続時間を前提としていた。
|
||||||
|
デジタルシステムは連続信号をそのまま扱えない。離散化が必要になる。
|
||||||
|
|
||||||
|
離散化には二つの軸がある。振幅軸と時間軸である。
|
||||||
|
|
||||||
|
まず振幅軸について。
|
||||||
|
デジタルシステムが振幅を表現できる精度は、ビット深度によって決まる。
|
||||||
|
Nビットのシステムは 2^N 個の離散的な振幅レベルを持つ。
|
||||||
|
各サンプルの値は、最も近いレベルに丸められる。この丸め誤差を量子化ノイズと呼ぶ。
|
||||||
|
表現できる振幅の上限と下限は、設計とハードウェアによって固定されている。ADCやDACの基準電圧がそれを決める。
|
||||||
|
その境界を超えると、ハードクリップが起きる。
|
||||||
|
アナログ回路は限界に近づくにつれて少しずつ歪む。デジタルにそういう曖昧さはない。境界は硬い。
|
||||||
|
|
||||||
|
次に時間軸について。
|
||||||
|
デジタルシステムは、連続した時間の流れから、一定間隔で値を取り出す。これがサンプリングである。
|
||||||
|
ここで問題がある。前の節で述べたように、アナログ信号は原理的には無限大まで周波数成分を持ちうる。
|
||||||
|
しかし有限のサンプリング頻度では、表現できる周波数に上限がある。全てを保存することはできない。
|
||||||
|
|
||||||
|
では何が失われ、何が残るのか。
|
||||||
|
もし信号の中に高すぎる周波数成分がなければ、サンプリングによって失うものは実質的にない。
|
||||||
|
これが離散化を正当化する前提である。
|
||||||
|
|
||||||
|
ナイキストの定理が、これを定量化する。
|
||||||
|
サンプリング周波数を Fs としたとき、Fs/2 より低い周波数成分は忠実に再構成できる。
|
||||||
|
定理が言うのはそれだけである。Fs をどこに設定すべきかは、定理が教えてくれることではない。用途が決める。
|
||||||
|
Fs/2 を超える成分は再構成できない。これをエイリアシングと呼ぶ。
|
||||||
|
|
||||||
|
補足しておく。この離散化によって、線形時不変システムの性質が崩れるわけではない。
|
||||||
|
連続時間において積分であった畳み込みは、離散時間においては和になる。有限インパルス応答なら有限和、無限インパルス応答なら無限和である。
|
||||||
|
可換性を含む全ての性質は引き継がれる。
|
||||||
|
|
||||||
|
### 6. 非線形性とその影響
|
||||||
|
|
||||||
|
では、現実のシステムに戻る。
|
||||||
|
先ほど線形時不変システムは特殊ケースであると述べた。
|
||||||
|
現実のシステムは線形時不変システムの条件を様々な形で破る。
|
||||||
|
時変パラメータは時不変性を破る。
|
||||||
|
フィードバックと飽和は線形性を破る。
|
||||||
|
|
||||||
|
例を挙げる。
|
||||||
|
モジュレーテッドディレイを考える。コーラスやフランジャーがその例である。
|
||||||
|
ディレイタイムが時間とともに変化するとき、同じ入力でも入力するタイミングによって出力が異なる。
|
||||||
|
これは時不変性の破れである。
|
||||||
|
|
||||||
|
次にオーバードライブを考える。
|
||||||
|
入力が閾値を超えると飽和が生じ、出力は入力に比例しなくなる。
|
||||||
|
これは線形性の破れである。
|
||||||
|
そして順序が問題になる。EQの後にオーバードライブを適用した結果と、オーバードライブの後にEQを適用した結果は、一般に異なる。
|
||||||
|
|
||||||
|
このとき、畳み込みの可換性は成立しない。
|
||||||
|
非線形システムでは、一般に
|
||||||
|
h₁(システム1)の後にh₂(システム2)を適用した結果と、
|
||||||
|
h₂(システム2)の後にh₁(システム1)を適用した結果は、等しくない。
|
||||||
|
|
||||||
|
普遍的な規則は存在しない。
|
||||||
|
各ケースを個別に検討する必要がある。
|
||||||
31
wip/wank.md
31
wip/wank.md
@@ -1,31 +0,0 @@
|
|||||||
# it's not ideal to wank in public spaces, unless publicly
|
|
||||||
|
|
||||||
## outline
|
|
||||||
This song is about why it's probably not ideal to wank in public spaces and why it's probably even a bad idea. Or not.
|
|
||||||
To be less cryptic, I want to try to tackle the glorious problem of how much one should be open about his own unpopular opinion (not as your usual conversation padding) in front of other human beings.
|
|
||||||
My take is that first you ignore other human beings as much as you can. Then voila.
|
|
||||||
|
|
||||||
If I write a song elaborating grand moral doctrines and assertions, it won't be a song no more. It'll be a boring, boring propaganda which will still appeal to those I don't intend on appealing to.
|
|
||||||
So instead of getting the big words out one by one I want to go extremely low on the ground. Half buried in it even.
|
|
||||||
|
|
||||||
## construction area
|
|
||||||
|
|
||||||
browsing through the favourite porn site is your
|
|
||||||
profession, passion, devotion, and chore
|
|
||||||
to reach that perfectly balanced, legally dubious
|
|
||||||
30 seconds of physiological and psychedelic
|
|
||||||
outburst.
|
|
||||||
|
|
||||||
the exhausted materials are not exactly
|
|
||||||
below par once applied and
|
|
||||||
you deeply know that too.
|
|
||||||
still the expedition for more kicks off
|
|
||||||
at the there or thereabouts of the clock
|
|
||||||
most if not all of the days.
|
|
||||||
|
|
||||||
it's the blind faith in encountering
|
|
||||||
something different and in the top bin
|
|
||||||
even when a thousand out of ten times
|
|
||||||
the results are but repetitions and impersonations
|
|
||||||
to an effigy of nonsense that won't even
|
|
||||||
glance the softest of woodworks
|
|
||||||
Reference in New Issue
Block a user