Every transform we have used so far — DTFT, $z$-transform, DFT — analyzes a signal as a whole. The basis functions $e^{j\omega n}$ extend over all time, so a single Fourier coefficient mixes together contributions from the entire signal. That is perfectly adequate for stationary signals(平穩訊號)whose spectral content does not change, but most signals we actually care about — speech, music, radar returns, biomedical signals — are nonstationary(非平穩訊號): their frequency content evolves with time. A melody is precisely a sequence of different frequencies at different times.目前為止我們用過的每一種轉換——DTFT、$z$ 轉換、DFT——都是把訊號當成一個整體來分析。基底函數 $e^{j\omega n}$ 在所有時間上延伸,所以單一個傅立葉係數會把整段訊號的貢獻全部混在一起。對於頻譜內容不隨時間改變的平穩訊號,這樣完全夠用;但我們真正在乎的訊號——語音、音樂、雷達回波、生醫訊號——多半是非平穩的:它們的頻率內容會隨時間演變。一段旋律正是不同的頻率出現在不同的時刻。ここまで使ってきた変換 —— DTFT、$z$ 変換、DFT —— はいずれも信号を全体として解析する。基底関数 $e^{j\omega n}$ は全時間にわたって広がっているので、一つのフーリエ係数には信号全体からの寄与が混ざり合っている。スペクトルの内容が変化しない定常信号であればそれで十分だが、我々が実際に扱いたい信号 —— 音声、音楽、レーダ反射波、生体信号 —— の多くは非定常である。すなわち周波数成分が時間とともに移り変わる。旋律とはまさに、異なる周波数が異なる時刻に並んだ列にほかならない。
The lecture opens with the Fourier transform of an amplitude-modulated sine: the FT shows which frequencies are present, but tells us almost nothing about when they occur. Here is the cleanest demonstration. Take two signals built from the same two tones, played in opposite order:這一講從一個調幅正弦波的傅立葉轉換開始:傅立葉轉換告訴我們有哪些頻率存在,卻幾乎完全不告訴我們它們何時出現。下面是最乾淨的一個示範。取兩個由同樣兩個音調構成、但播放順序相反的訊號:講義は振幅変調された正弦波のフーリエ変換から始まる。フーリエ変換はどの周波数が存在するかは示すが、それがいつ生じたかはほとんど教えてくれない。もっとも明快な実例を挙げよう。同じ二つの純音から作られ、順序だけを入れ替えた二つの信号を考える。
The fix suggested by the slides is intuitive: if the spectrum changes with time, chop the signal into short segments and Fourier-transform each segment separately. Within a segment of a few tens of milliseconds, speech or music is approximately stationary(短時間內近似平穩), so a per-segment spectrum is meaningful. Doing this for every segment position, and stacking the resulting spectra side by side as columns of an image, is exactly the idea of the spectrogram (頻譜圖/聲譜圖), and the underlying transform is the Short-Time Fourier Transform (STFT, 短時傅立葉轉換).投影片給出的解法很直觀:既然頻譜會隨時間改變,那就把訊號切成一段一段的短片段,再對每一段分別做傅立葉轉換。在幾十毫秒的片段之內,語音或音樂近似是平穩的,所以逐段的頻譜就有意義了。對每一個片段位置都這麼做,再把得到的頻譜一欄一欄並排堆成一張影像,這正是頻譜圖(聲譜圖)的想法,而其背後的轉換就是短時傅立葉轉換(Short-Time Fourier Transform, STFT)。スライドが示す対処法は直観的である。スペクトルが時間とともに変わるのなら、信号を短い区間に切り分け、各区間を別々にフーリエ変換すればよい。数十ミリ秒の区間の中であれば、音声や音楽はほぼ定常とみなせるので、区間ごとのスペクトルには意味がある。これをすべての区間位置について行い、得られたスペクトルを画像の列として横に並べたものが、まさにスペクトログラムの考え方であり、その基礎にある変換が短時間フーリエ変換(Short-Time Fourier Transform, STFT)である。
The two sections above state the problem and name the cure. This section works the lecture's own motivating example all the way through, because it answers a question the statement of the problem leaves open: the whole-signal transform does not lose the modulation, so where exactly does the modulation go? The answer turns out to be concrete and checkable, and it is what makes the STFT feel inevitable rather than merely convenient.前面兩小節一個講出問題、一個講出解法。這一小節把講義自己用來引出 STFT 的例子從頭做完一遍,因為問題的陳述留下了一個沒有回答的疑問:整段轉換並沒有把調變弄丟,那麼調變究竟跑到哪裡去了?答案是具體而且可以驗算的,而且正是這個答案讓 STFT 變成非做不可,而不只是比較方便。前の二つの小節は、一方が問題を述べ、他方が処方を名指した。本小節では、講義が STFT を導くのに用いたその例題を最後まで解いてみる。問題の述べ方だけでは答えの出ない疑問が残っているからである。全体を一度に変換しても変調が失われるわけではない。では変調はいったいどこへ行くのか。その答えは具体的で検算もでき、しかも STFT を単に便利なものではなく避けて通れないものに変えるのは、まさにこの答えである。
Take a slowly amplitude-modulated (AM) sine: a fast carrier whose height is scraped up and down by a slow envelope.取一個慢速調幅(AM)的正弦波:一個變化很快的載波,它的高度被一個變化很慢的包絡上下刮動。ゆっくり振幅変調(AM)された正弦波を取る。速く振動する搬送波の高さが、ゆっくりした包絡によって上下に削られている信号である。
The envelope $A[n]$ is $0$ at $n=0$ and at $n=N$, and reaches its maximum $A[N/2]=1-\cos\pi=2$ in the middle, so the waveform is a spindle: pinched at both ends, fattest in the centre. What we would intuitively like the analysis to tell us is one sentence: the frequency stays fixed at $\omega_0$, but the strength grows from nothing, peaks, and dies away again.包絡 $A[n]$ 在 $n=0$ 與 $n=N$ 處為 $0$,在正中間達到最大值 $A[N/2]=1-\cos\pi=2$,所以波形是一個紡錘形:兩端收細、中間最胖。直覺上我們希望分析結果告訴我們的,就是一句話:頻率固定在 $\omega_0$,但強度由無到有、到達頂點、再消失。包絡 $A[n]$ は $n=0$ と $n=N$ で $0$ となり、中央で最大値 $A[N/2]=1-\cos\pi=2$ に達する。したがって波形は紡錘形である。両端がすぼまり、中央がもっとも太い。直観的に解析に言ってほしいのは一文に尽きる。周波数は $\omega_0$ に固定されたまま、強さが無から立ち上がり、頂点を過ぎ、ふたたび消えてゆく。
Expand the product with the product-to-sum identity — the one written in green in the corner of the slide:用和差化積公式把乘積展開——也就是投影片角落用綠字寫的那一條:積和の公式で積を展開する。スライドの隅に緑の字で書かれているあの式である。
Applying it to $\cos\frac{2\pi n}{N}\cos\omega_0 n$ and keeping the leading $\cos\omega_0 n$ untouched turns the one modulated tone into a sum of three unmodulated ones:把它用在 $\cos\frac{2\pi n}{N}\cos\omega_0 n$ 上,前面那一項 $\cos\omega_0 n$ 原封不動,於是一個被調變的音調變成了三個沒有被調變的音調之和:これを $\cos\frac{2\pi n}{N}\cos\omega_0 n$ に適用し、先頭の $\cos\omega_0 n$ はそのまま残すと、変調された一つの音が変調されていない三つの音の和に変わる。
So an $N$-point DFT of the whole record shows three closely spaced lines and nothing else:所以對整段紀錄做 $N$ 點 DFT,看到的就是三根靠得很近的譜線,此外什麼都沒有:したがって全記録に対する $N$ 点 DFT に現れるのは互いに近接した三本の線だけであり、それ以外には何もない。
The sideband-to-centre height ratio is therefore $1:2$, exactly the proportion drawn on the slide. Its two labels $N/2$ and $N$ fix the convention: a bin-centred cosine of amplitude $a$ puts $|X[k]|=aN/2$ into each of the bins $\pm k$, so the plain two-sided magnitudes here are $N/2$ at the carrier and $N/4$ at each sideband, while folding the negative-frequency bin onto the positive one — the one-sided reading the slide uses — doubles both to $N$ and $N/2$. The ratio $2:1$ is the same under either convention; only the absolute heights move.所以側波帶與中間的高度比是 $1:2$,正是投影片圖上畫出來的比例。圖上標的兩個數字 $N/2$ 與 $N$ 把慣例定了下來:一個正好落在頻格中心、振幅為 $a$ 的餘弦,會在 $\pm k$ 兩個頻格各放進 $|X[k]|=aN/2$,所以這裡未經折疊的雙邊振幅是載波處 $N/2$、每個側波帶 $N/4$;而把負頻率那一格折疊到正頻率上——也就是投影片採用的單邊讀法——會讓兩者都加倍成 $N$ 與 $N/2$。$2:1$ 這個比值在兩種慣例下都一樣,動的只是絕對高度。したがって側波帯と中央の高さの比は $1:2$ であり、まさにスライドの図に描かれた比例である。図に添えられた二つの数 $N/2$ と $N$ が流儀を決めている。ビンの中心にぴったり乗った振幅 $a$ の余弦は、$\pm k$ の両方のビンに $|X[k]|=aN/2$ を置く。よってここで折り返しを行わない両側振幅は、搬送波で $N/2$、各側波帯で $N/4$ となる。負の周波数のビンを正の側へ折り返すと——スライドが採る片側の読み方である——どちらも倍になって $N$ と $N/2$ になる。比 $2:1$ はどちらの流儀でも同じであり、動くのは絶対的な高さだけである。
Three static lines are a very odd-looking answer to "the strength grows and dies away". The slide says the spectrum represents the modulation only indirectly, and the mechanism is beating(拍): three sinusoids of almost the same frequency drift in and out of step with one another, and their sum is alternately cancelled and reinforced. Evaluate the three terms at the two instants that matter.三根靜止不動的譜線,拿來回答「強度由小變大再變小」,看起來實在很不對勁。投影片說頻譜只是間接表示調變,而其機制就是拍(beating):三個頻率幾乎相同的正弦波彼此的步調會慢慢錯開又對上,於是它們的和時而互相抵消、時而互相加強。把這三項在兩個關鍵時刻算出來就看得很清楚。静止した三本の線は、「強さが大きくなってまた小さくなる」への答えとしてはいかにも奇妙に見える。スライドはスペクトルが変調を間接的にしか表さないと言う。その仕組みがうなり(beating、拍)である。周波数のほとんど等しい三つの正弦波は、互いの歩調が少しずつずれてはまた揃い、その和は打ち消し合ったり強め合ったりを繰り返す。鍵となる二つの時刻で三項を評価すれば、それがはっきり見える。
At $n=0$ all three cosines are in step, the two negative halves eat the positive whole, and the sum is exactly $0$ — the pinched end of the spindle. By $n=N/2$ each sideband has slipped a half-turn relative to the carrier, so its own sign has flipped; combined with the minus sign it already carried, both sidebands now add, and the sum is $2$ — the fat middle. Nothing in the picture moved: the three amplitudes $1,-\tfrac12,-\tfrac12$ are constants for all time. What changed is only the relative phase of three fixed sinusoids.在 $n=0$ 時三個餘弦步調一致,兩個負的一半把正的一整份吃掉,和恰好是 $0$——紡錘形收細的那一端。到了 $n=N/2$,每個側波帶相對於載波都已經滑過了半圈,自身的正負號因此翻轉;再配上它原本就帶著的負號,兩個側波帶現在變成相加,和是 $2$——紡錘形最胖的中間。圖上什麼都沒有動:三個振幅 $1,-\tfrac12,-\tfrac12$ 對所有時間都是常數。改變的只有三個固定正弦波之間的相對相位。$n=0$ では三つの余弦の歩調が揃っており、負の半分が二つで正の一つ分を食い尽くすので、和はちょうど $0$ になる。紡錘形のすぼまった端である。$n=N/2$ に至ると、各側波帯は搬送波に対して半回転だけずれており、それ自身の符号が反転している。もともと背負っていた負号と合わさって、二つの側波帯はいまや加わる側に回り、和は $2$ となる。紡錘形の太い中央である。図の上では何も動いていない。三つの振幅 $1,-\tfrac12,-\tfrac12$ はすべての時刻について定数である。変わったのは、三つの固定した正弦波どうしの相対位相だけである。
The description we actually want is the one we started from, $x[n]=A[n]\cos\omega_0 n$: one frequency $\omega_0$, with a height $A[n]$ that drifts slowly. §9.1.2 has already named the way to get it — cut the signal up and transform each piece — and this example makes the condition on the cut precise:我們真正想要的描述,就是一開始寫下的那一個:$x[n]=A[n]\cos\omega_0 n$——一個頻率 $\omega_0$,高度 $A[n]$ 隨時間慢慢變化。§9.1.2 已經點出了取得它的辦法——把訊號切開、每段各自轉換——而這個例子把「怎麼切」的條件講得很精確:本当に欲しい記述は、最初に書き下したものそのものである。$x[n]=A[n]\cos\omega_0 n$、すなわち一つの周波数 $\omega_0$ と、ゆっくり動く高さ $A[n]$ である。§9.1.2 はそれを得る手立て——信号を切り、各片を変換する——をすでに名指している。この例題は、その切り方に課される条件を正確にしてくれる。
Written out, frame $m$ starts at $mR$ and its spectrum is寫成式子,第 $m$ 個音框起點在 $mR$,其頻譜為式に書けば、第 $m$ フレームは $mR$ から始まり、そのスペクトルは次のようになる。
— which is §9.2.2's $X_m[k]$ with $L$ written for the frame length and $R$ for the hop. Note what the cutting already costs: chopping a signal into frames is itself a multiplication by a rectangular window, so every leakage problem met in §9.3.1 applies here without exception. In practice one therefore uses a tapered $w[n]$, Hann being the usual choice, and overlaps adjacent frames — $R=L/2$ is the standard setting, the one the figure below uses.——這正是 §9.2.2 的 $X_m[k]$,只是音框長度寫成 $L$、跳距寫成 $R$。注意「切」本身已經有代價:把訊號切成一段一段,本身就是乘上一個矩形窗,所以 §9.3.1 裡遇到的每一個洩漏問題在這裡全部適用,毫無例外。因此實務上會改用有錐度的 $w[n]$,通常選 Hann 窗,並讓相鄰音框重疊——$R=L/2$ 是標準設定,也是下圖採用的設定。——これは §9.2.2 の $X_m[k]$ そのものであり、フレーム長を $L$、ホップ長を $R$ と書き換えただけである。ここで切ることの代償に注意したい。信号をフレームに切り分けること自体が、矩形窓を掛けることにほかならない。したがって §9.3.1 で出会った漏れの問題は、ここでも例外なくすべて当てはまる。だからこそ実務では裾の落ちた $w[n]$——通常は Hann 窓——を用い、隣り合うフレームを重ねる。$R=L/2$ が標準の設定であり、下の図もそれを使っている。
Drag the frame length $L$ and compare the whole-signal DFT with the STFT. The four panels are the three slides, stacked.拖動音框長度 $L$,比較整段 DFT 與 STFT 的結果。四個面板就是三張投影片疊起來。フレーム長 $L$ を動かして、全体の DFT と STFT とを見比べてほしい。四つの面板は三枚のスライドを積み上げたものである。
Reading the four panels against the three slides:把四個面板對回三張投影片:四つの面板を三枚のスライドに対応させて読むと、次のようになる。
Dragging $L$ exercises the STFT's one unavoidable limitation. The general statement of that limitation — $\Delta t\approx L/f_s$ against $\Delta f\approx c\,f_s/L$, the uncertainty product that bounds them, and why no window escapes it — is §9.3.2, and is not repeated here. The table below is narrower on purpose: it is a log of what each setting of this one slider does to this one figure, in numbers that can be read off the panels.拖動 $L$ 就是在操作 STFT 唯一躲不掉的限制。這個限制的一般陳述——$\Delta t\approx L/f_s$ 對上 $\Delta f\approx c\,f_s/L$、約束兩者的不確定性乘積,以及為什麼沒有任何一種窗躲得過它——在 §9.3.2,這裡不重複。下面這張表刻意只講窄的一件事:這一根滑桿的每一個設定對這一張圖做了什麼,而且用面板上讀得出來的數字講。$L$ を動かすことは、STFT が避けて通れない唯一の制約を操作することにほかならない。その制約の一般的な言明——$\Delta t\approx L/f_s$ と $\Delta f\approx c\,f_s/L$ の対立、両者を縛る不確定性の積、そしてどの窓もそれを逃れられない理由——は §9.3.2 にあり、ここでは繰り返さない。下の表はあえて狭い。このつまみの各設定がこの一枚の図に何をするかを、面板から読み取れる数で記録しただけのものである。
| $L$ | frames音框數フレーム数 | main lobe $4/L$主瓣全寬 $4/L$主ローブ全幅 $4/L$ | frame span, as a fraction of the envelope period每段跨越的範圍,佔包絡週期的比例1 フレームが包絡周期に占める割合 | what ③ and ④ show③ 與 ④ 看到什麼③ と ④ に何が見えるか |
|---|---|---|---|---|
| short, $32$短,$32$短い、$32$ | $63$ | $0.125$ | $1/32$ | The band in ③ is thicker than the carrier frequency $0.0996$ it is supposed to mark, so the frequency is badly blurred; ④ is nevertheless the most faithful of all, the dots never more than $0.05$ from $A[n]$.③ 的帶子比它要標示的載波頻率 $0.0996$ 還粗,頻率糊得很厲害;但 ④ 反而是所有設定裡最準的,點與 $A[n]$ 的差從沒超過 $0.05$。③ の帯は、それが示すはずの搬送波周波数 $0.0996$ よりも太く、周波数はひどくぼける。それでも ④ はすべての設定の中でもっとも忠実であり、点と $A[n]$ の差は $0.05$ を超えない。 |
| medium, $128$適中,$128$中くらい、$128$ | $15$ | $0.031$ | $1/8$ | The band in ③ is thin and clearly placed; the dots in ④ follow the envelope to within $0.09$. This is the setting the figure opens on.③ 的帶子又細、位置又清楚;④ 的點貼合包絡,誤差在 $0.09$ 以內。這就是圖一打開時的設定。③ の帯は細く、位置もはっきりしている。④ の点は包絡に $0.09$ 以内で追従する。図を開いたときの既定の設定がこれである。 |
| long, $512$長,$512$長い、$512$ | $3$ | $0.008$ | $1/2$ | Only three dots survive, and one frame now covers half the envelope period, so $A[n]$ is no longer constant across a frame: the middle peak reads $1.85$ where the envelope is $2$. A peak height has stopped standing for any single instant.只剩下三個點,而且一段就跨越包絡週期的一半,$A[n]$ 在一段之內已經不是常數了:中間那個峰讀到 $1.85$,而包絡其實是 $2$。峰高已經不再代表任何單一時刻。点は三つしか残らず、しかも一つのフレームが包絡周期の半分を覆うので、$A[n]$ はフレーム内でもはや定数ではない。中央のピークは $1.85$ と読めるが、包絡は $2$ である。ピーク高は、もはやどの単一の時刻も代表しない。 |
The rule for choosing $L$ is therefore exactly the condition stated above: short enough that the modulation $A[n]$ is near-constant within one frame, long enough that the frequency resolution separates the frequencies you care about. That is the one trade the slider cannot escape, and it is the reason the whole of §9.3 follows: every frame is a windowed DFT, so main-lobe width, sidelobe leakage and the choice of window all apply to the STFT unchanged.所以選 $L$ 的原則就是上面那個條件:要短到讓調變 $A[n]$ 在一段之內近似常數,又要長到頻率解析度足以分辨你關心的那些頻率。這就是滑桿躲不掉的那一個取捨,也是整個 §9.3 接在後面的理由:每一段都是一次加窗的 DFT,所以主瓣寬度、旁瓣洩漏、窗的選擇,在 STFT 中原封不動地全部適用。したがって $L$ を選ぶ原則は、上で述べた条件そのものである。変調 $A[n]$ が一つのフレームの中でほぼ定数とみなせる程度に短く、かつ関心のある周波数を分離できる分解能が得られる程度に長く。これがつまみの逃れられない唯一の取引であり、§9.3 全体がこのあとに続く理由でもある。各フレームは窓かけされた DFT であるから、主ローブ幅、サイドローブの漏れ、窓の選択は、いずれも STFT にそのまま当てはまる。
Let $w[n]$ be a window function(窗函數)of length $L$ — real, nonnegative, concentrated around its center, and zero outside $0\le n\le L-1$. The STFT of $x[n]$ is the DTFT of the windowed signal, with the window slid to time position $n$:設 $w[n]$ 是一個長度為 $L$ 的視窗函數——實數、非負、集中在中心附近,而且在 $0\le n\le L-1$ 之外為零。$x[n]$ 的 STFT 就是加窗後訊號的 DTFT,其中視窗被滑移到時間位置 $n$:$w[n]$ を長さ $L$ の窓関数とする。実数で非負、中心付近に集中し、$0\le n\le L-1$ の外では零であるものとする。$x[n]$ の STFT とは、窓を時刻 $n$ の位置まで滑らせたうえで、窓をかけた信号の DTFT を取ったものである。
For each fixed window position $n$, $X(n,\omega)$ is an ordinary DTFT of the segment $x[m]\,w[m-n]$ — a function of continuous frequency $\omega$, periodic in $2\pi$. As $n$ varies, the window slides along the signal, so the STFT is a two-dimensional function: one time axis, one frequency axis.對每一個固定的視窗位置 $n$,$X(n,\omega)$ 就是片段 $x[m]\,w[m-n]$ 的普通 DTFT——一個連續頻率 $\omega$ 的函數,並以 $2\pi$ 為週期。當 $n$ 變動時,視窗沿著訊號滑移,因此 STFT 是一個二維的函數:一個時間軸、一個頻率軸。窓の位置 $n$ を一つ固定するごとに、$X(n,\omega)$ は区間 $x[m]\,w[m-n]$ の通常の DTFT であり、連続周波数 $\omega$ の関数で $2\pi$ を周期とする。$n$ を変えていくと窓が信号上を滑っていくので、STFT は二次元の関数となる。時間軸が一本、周波数軸が一本である。
The STFT can be grouped two ways, and both matter:STFT 有兩種分組方式,而且兩種都重要:STFT は二通りにまとめることができ、そのどちらも重要である。
In practice we evaluate the STFT only on a grid: time is sampled every $M$ samples (the hop size, 跳距), and frequency is sampled at the $N$ DFT bins. With frame index $m$ and bin index $k$:實務上我們只在一個格點上計算 STFT:時間每 $M$ 個樣本取樣一次(這就是跳距,hop size),頻率則取在 $N$ 個 DFT 頻格上。以音框索引 $m$ 與頻格索引 $k$ 表示:実際には STFT を格子点の上でのみ評価する。時間は $M$ 標本ごとに標本化し(これがホップ長である)、周波数は $N$ 個の DFT ビンで標本化する。フレーム番号 $m$、ビン番号 $k$ を用いると、
In words: take the $N$ samples starting at $mM$, multiply pointwise by the window, and take an $N$-point FFT. Each $m$ produces one frame(音框)— one column of the time–frequency image. For a signal of length $L_x$, the number of complete frames is用文字說:取從 $mM$ 開始的 $N$ 個樣本,與視窗逐點相乘,再做 $N$ 點 FFT。每一個 $m$ 產生一個音框——也就是時頻影像的一欄。對長度為 $L_x$ 的訊號,完整音框的個數為言葉で言えば、$mM$ から始まる $N$ 標本を取り出し、窓と点ごとに掛け合わせ、$N$ 点 FFT を取る。各 $m$ が一つのフレーム、すなわち時間周波数画像の一列を生む。長さ $L_x$ の信号に対して、完全なフレームの個数は
which is precisely the loop bound used in the homework's myspectrogram
function. The frequency spacing between adjacent bins is $f_s/N$ — but as we will see in
Section 9.3.2, the true resolution is set by the window length, not by $N$.這正是作業中 myspectrogram 函式所用的迴圈上界。相鄰頻格之間的頻率間距是 $f_s/N$——但如同 9.3.2 節將看到的,真正的解析度是由窗長決定的,不是由 $N$ 決定。これはまさに課題の myspectrogram 関数で使われているループの上限である。隣り合うビンの周波数間隔は $f_s/N$ である。ただし 9.3.2 節で見るように、本当の分解能を決めるのは窓長であって $N$ ではない。
Two elementary inputs reveal exactly what the STFT can and cannot resolve:兩個最基本的輸入,恰好揭露了 STFT 能分辨什麼、不能分辨什麼:二つの初等的な入力が、STFT に何が分解できて何が分解できないかをそのまま明らかにしてくれる。
So the window $w[n]$ acts as the "point spread function" of the analysis in both axes simultaneously. Choosing $w$ is the entire art of the STFT — which is why the lecture spends four slides on it.所以視窗 $w[n]$ 等於同時在兩個軸上扮演這個分析的「點擴散函數」。選擇 $w$ 就是 STFT 的全部技藝——這也正是講義在它上面花了四張投影片的原因。つまり窓 $w[n]$ は、この解析の「点広がり関数」として両方の軸に同時に効いている。$w$ をどう選ぶかが STFT の技術のすべてであり、だからこそ講義はそこに四枚のスライドを費やしている。
Truncating a signal with a rectangular window(矩形窗)is multiplication in time, hence convolution with the window spectrum in frequency. The rectangular window's spectrum is the periodic sinc (Dirichlet kernel): a narrow mainlobe, but sidelobes(旁瓣) only $-13$ dB down. Those sidelobes cause leakage(頻譜洩漏): a strong tone splatters energy across the whole band and buries weak neighbors. Tapered windows trade a wider mainlobe for far lower sidelobes.用矩形窗把訊號截斷,在時域是相乘,因此在頻域就是與視窗頻譜做摺積。矩形窗的頻譜是週期性 sinc(Dirichlet 核):主瓣很窄,但旁瓣只低了 $-13$ dB。這些旁瓣造成頻譜洩漏:一個強的音調會把能量潑灑到整個頻帶上,把鄰近的弱訊號埋掉。錐形窗則用較寬的主瓣,換得低得多的旁瓣。矩形窓で信号を打ち切ることは時間領域での掛け算であり、したがって周波数領域では窓のスペクトルとの畳み込みになる。矩形窓のスペクトルは周期 sinc(ディリクレ核)であり、主ローブは狭いがサイドローブは $-13$ dB しか下がらない。このサイドローブがスペクトル漏れを引き起こす。強い音のエネルギーが帯域全体にまき散らされ、近くの弱い成分を埋めてしまうのである。テーパ窓は主ローブ幅が広がるのと引き換えに、はるかに低いサイドローブを手に入れる。
| Window視窗窓 | Mainlobe width (null–null)主瓣寬度(零點到零點)主ローブ幅(零点間) | Peak sidelobe旁瓣峰值サイドローブの最大値 | Typical use典型用途典型的な用途 |
|---|---|---|---|
| Rectangular(矩形)矩形窗矩形窓 | $4\pi/L$ | $-13$ dB$-13$ 分貝$-13$ デシベル | maximum resolution, transient analysis解析度最高、暫態分析最高の分解能、過渡現象の解析 |
| Hann(漢恩)Hann(漢恩窗)Hann(ハン窓) | $8\pi/L$ | $-31$ dB$-31$ 分貝$-31$ デシベル | default for spectrograms / STFT頻譜圖/STFT 的預設選擇スペクトログラム/STFT の既定 |
| Hamming(漢明)Hamming(漢明窗)Hamming(ハミング窓) | $8\pi/L$ | $-41$ dB$-41$ 分貝$-41$ デシベル | speech analysis語音分析音声解析 |
| Blackman(布雷克曼)Blackman(布雷克曼窗)Blackman(ブラックマン窓) | $12\pi/L$ | $-57$ dB$-57$ 分貝$-57$ デシベル | large dynamic range大動態範圍大きなダイナミックレンジ |
dsp10.m and virtually
every audio tool default to it.Hann 視窗很平滑(邊緣沒有不連續),旁瓣有不錯的 $-31$ dB,而且還以 $-18$ dB/八度的速率滾降;它的主瓣只有矩形窗的兩倍寬;再加上在 50% 或 75% 重疊下,平移後的各份複本相加恰好等於一個常數——這使得分析—合成中的完美重建變得輕而易舉(9.6 節)。這就是為什麼 dsp10.m 以及幾乎每一個音訊工具都把它當成預設。Hann 窓はなめらかで(端に不連続がない)、$-31$ dB という十分低いサイドローブをもち、しかもそれが $-18$ dB/オクターブで減衰していく。主ローブ幅は矩形窓の二倍にすぎず、さらに 50% または 75% の重なりでずらした複製を足し合わせるとちょうど定数になる。そのおかげで分析—合成における完全再構成がきわめて容易になる(9.6 節)。dsp10.m をはじめ、ほぼすべての音響ツールがこれを既定とするのはそのためである。
Window shape sets the sidelobe behavior; window length $L$ sets the fundamental trade-off. The mainlobe width scales as $1/L$, so in hertz the frequency resolution of a Hann-windowed STFT is approximately視窗的形狀決定旁瓣的行為;視窗的長度 $L$ 則決定那個根本的取捨。主瓣寬度正比於 $1/L$,所以用 Hann 窗做 STFT 時,以赫茲表示的頻率解析度大約是窓の形状がサイドローブの振る舞いを決め、窓の長さ $L$ が根本的なトレードオフを決める。主ローブ幅は $1/L$ に比例するので、Hann 窓を用いた STFT の周波数分解能はヘルツ単位でおよそ
You cannot win on both axes at once. This is the signal-processing form of the uncertainty principle(測不準原理):你沒辦法在兩個軸上同時取勝。這就是不確定性原理在訊號處理中的形式:二つの軸で同時に勝つことはできない。これが不確定性原理の信号処理における形である。
with equality only for the Gaussian window. Improving time resolution by shortening the window necessarily degrades frequency resolution in exact proportion, and vice versa.等號只在高斯窗時成立。把視窗縮短以改善時間解析度,必然會按同樣的比例惡化頻率解析度,反之亦然。等号が成り立つのはガウス窓のときだけである。窓を短くして時間分解能を上げれば、周波数分解能は必ず同じ比率で悪化し、その逆もまた然りである。
The two bullets above are stated as a trade between two kinds of detail. The lecture slide states the same thing a second way, in terms of what the measurement is a measurement of, and that reading is worth having alongside the first because it explains why a long window is not simply a better window. Call the two windows $w_S$ (short) and $w_L$ (long):上面那兩點,是用兩種細節之間的取捨來說的。講義的投影片用第二種方式說同一件事,講的是這個量測到底量到的是什麼;這種讀法值得跟前一種並陳,因為它解釋了為什麼長窗並不是「比較好的窗」而已。把兩個窗分別叫做 $w_S$(短)與 $w_L$(長):上の二つの箇条書きは、二種類の細部のあいだのトレードオフとして述べたものである。講義のスライドは同じことを二通り目の言い方で述べる。すなわちその測定が何の測定なのかという言い方である。この読み方は最初の読み方と並べておく価値がある。長い窓が単に「より良い窓」ではない理由を説明してくれるからである。二つの窓をそれぞれ $w_S$(短い)と $w_L$(長い)と呼ぶことにする。
Hence the slide's one-line summary, which is the sentence to carry away from the whole of §9.3: more time detail means less frequency detail. It is not a statement about an algorithm being imperfect. The average of a quantity over a long span and the value of that quantity at an instant are different quantities, and a single transform cannot return both.於是就有了投影片那句一行的總結,也是整個 §9.3 最該帶走的一句話:時間細節越多,頻率細節越少。這不是在說某個演算法做得不夠好。一個量在一長段時間上的平均,跟那個量在某一個瞬間的值,本來就是兩個不同的量,一次轉換沒辦法同時交出這兩者。そこからスライドの一行の要約が出てくる。これは §9.3 全体から持ち帰るべき一文でもある。時間の細部が増えれば周波数の細部は減る。これはアルゴリズムの出来が悪いという話ではない。ある量の長い区間にわたる平均と、その量のある瞬間における値とは、そもそも別の量であり、一度の変換が両方を返すことはできない。
The slide writes the frequency half of the trade as a formula for where the mainlobe first touches zero, in radians per sample and with the window length called $N_W$:投影片把這個取捨的頻率那一半寫成一條公式,講的是主瓣第一次碰到零的位置,單位是每樣本的弧度,而窗長在那裡叫做 $N_W$:スライドはこのトレードオフの周波数側を、主ローブが最初に零に触れる位置の式として書く。単位は毎標本のラジアンであり、窓長はそこでは $N_W$ と呼ばれる。
This is the same number as the box above, written in the slide's units: null-to-null is twice the first null, so $4f_s/N_W$ is $\Delta f\approx c\,f_s/L$ with $c=4$ and $L=N_W$. The reason the constant is $4\pi$ and not the rectangular window's $2\pi$ is already in §9.3.1: a Hann window is a sum of three shifted Dirichlet kernels, at $0$ and $\pm 2\pi/N_W$, so the outermost of the three carries the first null out to twice the rectangular distance. A short $N_1$-point window therefore has a wide $W_S$ and a long $N_2$-point window a narrow $W_2$ — the shorter the window, the more blurred the spectrum, which is the same word §9.3.4 gives to the mainlobe's half of the damage.這跟上面方框裡的是同一個數字,只是換成投影片的單位來寫:零點到零點是第一個零點的兩倍,所以 $4f_s/N_W$ 就是 $\Delta f\approx c\,f_s/L$ 取 $c=4$、$L=N_W$。常數是 $4\pi$ 而不是矩形窗的 $2\pi$,理由 §9.3.1 已經有了:Hann 窗是三個平移過的 Dirichlet 核之和,位置在 $0$ 與 $\pm 2\pi/N_W$,所以三者之中最外側的那一個把第一個零點推到矩形窗的兩倍遠。因此 $N_1$ 點的短窗有一個寬的 $W_S$,$N_2$ 點的長窗有一個窄的 $W_2$——窗越短,頻譜越模糊(blurred),而這正是 §9.3.4 給主瓣那一半損害取的同一個字。これは上の枠の中と同じ数を、スライドの単位で書いたものである。零点から零点までは第一零点の二倍なので、$4f_s/N_W$ は $c=4$、$L=N_W$ とした $\Delta f\approx c\,f_s/L$ にほかならない。定数が矩形窓の $2\pi$ ではなく $4\pi$ である理由はすでに §9.3.1 にある。Hann 窓は $0$ と $\pm 2\pi/N_W$ に置かれた三つの平行移動した Dirichlet 核の和なので、そのうち最も外側のものが第一零点を矩形窓の二倍の距離まで押し出すのである。したがって $N_1$ 点の短い窓は広い $W_S$ をもち、$N_2$ 点の長い窓は狭い $W_2$ をもつ。窓が短いほどスペクトルはぼける(blurred)。これは §9.3.4 が主ローブ側の損害に与えたのと同じ語である。
A useful mental picture: each STFT coefficient $X_m[k]$ "owns" a cell of the time–frequency plane of width $\Delta t$ and height $\Delta f$, with area bounded below by the uncertainty principle. The window length only decides the aspect ratio of the cells — never their area.一個很有用的心像:每一個 STFT 係數 $X_m[k]$「擁有」時頻平面上一個寬 $\Delta t$、高 $\Delta f$ 的格子,而這個格子的面積有一個由不確定性原理給出的下界。窗長只能決定格子的長寬比——絕對改變不了它們的面積。有用なイメージを一つ。各 STFT 係数 $X_m[k]$ は、時間周波数平面の上で幅 $\Delta t$、高さ $\Delta f$ のセルを一つ「所有」しており、その面積には不確定性原理による下界がある。窓長が決めるのはセルの縦横比だけであって、面積を変えることはできない。
The figure above draws the tiling twice, once per window length. The lecture slide draws a third picture, which is the same idea with the grid taken away: on one empty time–frequency plane it places three blobs, each the cell belonging to a different window analysing the same frequency at a different instant. Underneath each blob it draws the window itself, and to the right it draws the three window spectra on one axis.上面那張圖把鋪磚畫了兩次,一種窗長畫一次。講義的投影片則畫了第三張圖,概念相同,只是把格線拿掉了:在同一張空白的時頻平面上放三個圓斑,每一個都是不同的窗在不同時刻分析同一個頻率時所擁有的那個格子。每個圓斑的下方畫著那個窗本身,右側則把三個窗的頻譜畫在同一條軸上。上の図はタイル分割を、窓長ごとに一度ずつ、計二回描いている。講義のスライドは第三の絵を描く。考え方は同じで、格子を取り払ったものである。一枚の空白の時間周波数平面の上に三つの円斑を置く。それぞれは、異なる窓が異なる時刻に同じ周波数を分析したときに占めるセルである。各円斑の下にはその窓そのものが描かれ、右側には三つの窓のスペクトルが一本の軸の上に重ねて描かれる。
| Position on the slide在投影片上的位置スライド上の位置 | The window drawn below it下方畫的那個窗その下に描かれた窓 | The shape of the blob圓斑的形狀円斑の形 |
|---|---|---|
| $n \approx 60$ | blue: very short藍:很短青:非常に短い | narrow in time, drawn out a long way in frequency — a vertical streak時間上很窄、頻率上拉得很長——一道垂直的條紋時間方向に狭く、周波数方向に長く引き伸ばされた縦の筋 |
| $n \approx 190$ | green: medium綠:中等緑:中くらい | close to round接近圓形ほぼ円形 |
| $n \approx 300$ | red: very long紅:很長赤:非常に長い | wide in time, narrow in frequency — a horizontal streak時間上很寬、頻率上很窄——一道水平的條紋時間方向に広く、周波数方向に狭い横の筋 |
The three curves on the right are the spectra of those three windows, and they say the same thing from the other side: the shorter the window, the wider its spectrum. Nothing in the picture is new — it is Fig. 9-3's two grids with the grid lines removed so that one cell at a time can be looked at — but removing the grid makes one feature impossible to miss, which is that the three blobs have about the same area. That is the uncertainty principle, and it is what the next subsection measures.右邊那三條曲線是那三個窗的頻譜,它們從另一面說著同一件事:窗越短,頻譜越寬。圖裡沒有任何新東西——它就是 圖 9-3 的兩張格子圖把格線拿掉,好讓人一次只看一個格子——但拿掉格線之後有一件事就想忽略也忽略不了,那就是三個圓斑的面積差不多相同。這就是不確定性原理,而下一小節要量的就是它。右側の三本の曲線はその三つの窓のスペクトルであり、同じことを反対側から述べている。窓が短いほどスペクトルは広い。この絵に新しいものは何もない。図 9-3 の二つの格子から格子線を取り去り、セルを一つずつ眺められるようにしただけである。しかし格子線を外すと、見落としようのない特徴が一つ現れる。三つの円斑の面積はほぼ等しいということである。これが不確定性原理であり、次の小節で測るのはこれである。
The argument is two lines. $\delta t$ is proportional to $N_W$ and $\delta f$ is proportional to $1/N_W$, so in the product the window length cancels:論證只有兩行。$\delta t$ 正比於 $N_W$,$\delta f$ 正比於 $1/N_W$,所以兩者相乘時窗長就被約掉了:議論は二行で済む。$\delta t$ は $N_W$ に比例し、$\delta f$ は $1/N_W$ に比例するので、積をとると窓長は打ち消し合う。
You can decide whether the blob is to be flat or tall. You cannot make it smaller in both directions at once. The constants $\alpha$ and $\beta$ depend on the shape of the window and on how $\delta t$ and $\delta f$ are defined, and the value of $\alpha\beta$ is therefore not a universal number — which is worth saying out loud, because the literature quotes several different ones for the same window. What does not depend on the definition is that the product is free of $N_W$. Measured on windows from $N_W=32$ to $N_W=1024$, a span of a factor of $32$:你可以決定圓斑要扁還是要高。你沒辦法讓它在兩個方向上同時變小。常數 $\alpha$ 與 $\beta$ 取決於窗的形狀,也取決於 $\delta t$ 與 $\delta f$ 是怎麼定義的,所以 $\alpha\beta$ 的值並不是一個普世的數字——這件事值得講明白,因為文獻上對同一個窗會引用好幾個不同的數字。不隨定義而變的是:這個乘積裡沒有 $N_W$。在 $N_W=32$ 到 $N_W=1024$(相差 $32$ 倍)的範圍上量:円斑を扁平にするか縦長にするかは選べる。しかし両方向で同時に小さくすることはできない。定数 $\alpha$ と $\beta$ は窓の形状と、$\delta t$・$\delta f$ の定義の仕方とに依存する。したがって $\alpha\beta$ の値は普遍的な数ではない。これははっきり言っておく価値がある。文献は同じ窓に対して複数の異なる値を引用しているからである。定義に依らないのは、この積に $N_W$ が含まれないという点である。$N_W=32$ から $N_W=1024$ まで、$32$ 倍の範囲で測った結果は次のとおりである。
| Definition of $\delta t$ and $\delta f$$\delta t$ 與 $\delta f$ 的定義$\delta t$ と $\delta f$ の定義 | HannHann 窗Hann 窓 | Rectangular矩形窗矩形窓 |
|---|---|---|
| RMS (second-moment) spread in each domain兩個域各自的均方根(二階動差)展幅各領域における二乗平均(二次モーメント)の広がり | $0.08167$ at every length每一個長度都是 $0.08167$どの長さでも $0.08167$ | $0.43$ to $2.45$ — not constant$0.43$ 到 $2.45$——不是常數$0.43$ から $2.45$——定数ではない |
| RMS duration $\times$ equivalent noise bandwidth均方根持續時間 $\times$ 等效雜訊頻寬二乗平均の継続時間 $\times$ 等価雑音帯域幅 | $0.21217$ at every length每一個長度都是 $0.21217$どの長さでも $0.21217$ | $0.28867$ at every length每一個長度都是 $0.28867$どの長さでも $0.28867$ |
| RMS duration $\times$ $-3$ dB mainlobe width均方根持續時間 $\times$ $-3$ dB 主瓣寬度二乗平均の継続時間 $\times$ $-3$ dB 主ローブ幅 | $0.20377$ at every length每一個長度都是 $0.20377$どの長さでも $0.20377$ | $0.25573$ at every length每一個長度都是 $0.25573$どの長さでも $0.25573$ |
Three different constants for the same Hann window, all three of them constant in $N_W$ to five figures. The one entry that misbehaves is instructive rather than embarrassing: the rectangular window's second-moment bandwidth is dominated by the $1/\omega$ tails that its two jump discontinuities produce, and in continuous time that integral does not converge at all. In discrete time it is finite only because the band stops at $\pm\pi$, and the longer the window the more of the fixed band those tails occupy, so the product creeps upward. A window that goes smoothly to zero at both ends has no such tails and no such drift, which is one more entry in §9.3.4's ledger for using a tapered window. Nothing above changes the trade itself: on the other two definitions the rectangular product is as rigidly constant as the Hann one.同一個 Hann 窗有三個不同的常數,而三個都在 $N_W$ 上常到小數第五位。唯一不守規矩的那一格與其說尷尬,不如說有教育意義:矩形窗的二階動差頻寬被它兩個跳躍不連續點所產生的 $1/\omega$ 尾巴主宰,而在連續時間裡那個積分根本不收斂。在離散時間裡它之所以有限,只是因為頻帶到 $\pm\pi$ 就停了;窗越長,那些尾巴在這個固定頻帶中佔的比例就越大,所以乘積會往上爬。兩端平滑降到零的窗沒有這種尾巴,也就沒有這種漂移,這又是 §9.3.4 那本「該用漸縮窗」的帳上的一筆。以上沒有任何一點改變了取捨本身:在另外兩種定義下,矩形窗的乘積跟 Hann 窗的一樣死守著常數。同じ Hann 窓に対して三つの異なる定数が出るが、三つとも $N_W$ について五桁まで一定である。唯一ふるまいの悪い欄は、恥ずかしいというより教育的である。矩形窓の二次モーメント帯域幅は、二つの跳躍不連続が生む $1/\omega$ の裾に支配されており、連続時間ではその積分はそもそも収束しない。離散時間で有限なのは帯域が $\pm\pi$ で止まるからにすぎず、窓が長いほどその裾が固定の帯域に占める割合が増えるので、積は少しずつ上がっていく。両端がなめらかに零へ落ちる窓にはそのような裾がなく、そのような漂動もない。これは §9.3.4 の「テーパ窓を使う」という差引勘定に加わるもう一項である。以上はトレードオフそのものを何も変えない。他の二つの定義では、矩形窓の積も Hann 窓の積と同じく厳密に一定である。
There is one step in the slide's pair of tilings that is easy to read past. Going from the left grid to the right one, the window length is halved — and so, the slide says, is the number of DFT samples. That is not a second, independent choice. A frame of $N_W$ samples has $N_W$ numbers in it and a DFT of length $N_W$ returns $N_W$ of them; taking a longer DFT is the zero-padding of §9.3.2's warning, which interpolates the picture without adding anything to it. So halving the window halves the number of rows in the grid at the same moment as it doubles the number of columns.投影片那一對鋪磚圖裡有一步很容易看過去。從左邊的格子走到右邊的格子,窗長減了一半——而投影片說,DFT 的樣本數也減了一半。這並不是第二個獨立的選擇。一個 $N_W$ 點的音框裡就是 $N_W$ 個數字,長度 $N_W$ 的 DFT 也就還你 $N_W$ 個;用更長的 DFT,就是 §9.3.2 那個警告裡的補零,它只把圖內插得更細,不會多加任何東西進去。所以窗長減半的同時,格子的列數減半、欄數加倍。スライドの二つのタイル分割には、読み飛ばしやすい一歩がある。左の格子から右の格子へ移るとき、窓長が半分になる——そしてスライドによれば DFT の標本数も半分になる。これは第二の独立な選択ではない。$N_W$ 標本のフレームの中には $N_W$ 個の数しかなく、長さ $N_W$ の DFT が返すのも $N_W$ 個である。より長い DFT を取ることは §9.3.2 の注意にあるゼロ詰めであり、絵を内挿するだけで何かを足すわけではない。したがって窓を半分にすると、格子の行数が半分になるのと同時に列数が倍になる。
Count the cells. A signal of $L_x$ samples analysed with window $N_W$, DFT length $N_W$ and a hop equal to the window gives $L_x/N_W$ columns and $N_W$ rows, which is $L_x$ cells however $N_W$ was chosen. The plane being covered has not changed size either: it is $L_x/f_s$ seconds by $f_s$ hertz, so each cell has area $(N_W/f_s)\times(f_s/N_W)=1$ in those units, again whatever $N_W$ was. The two grids of Fig. 9-3 therefore hold the same number of tiles of the same area, cut differently — which is exactly the sentence that figure's caption already carries, now with the count behind it. It is also the picture the lecture reuses when it compares the STFT with wavelets: "the STFT's cells are all one size" is the property a wavelet basis deliberately gives up so that its cells can be short at high frequencies and long at low ones. That comparison is not worked out in this chapter.數一數格子。一段 $L_x$ 個樣本的訊號,用窗長 $N_W$、DFT 長度 $N_W$、跳距等於窗長來分析,會得到 $L_x/N_W$ 欄與 $N_W$ 列,也就是 $L_x$ 個格子,不管 $N_W$ 怎麼選都一樣。被覆蓋的那個平面也沒有變大變小:它是 $L_x/f_s$ 秒乘上 $f_s$ 赫茲,所以每個格子的面積是 $(N_W/f_s)\times(f_s/N_W)=1$(在這組單位下),同樣跟 $N_W$ 無關。所以 圖 9-3 的兩張格子圖裝的是數目相同、面積也相同的磚,只是切法不同——這正是那張圖的圖說早就寫著的那句話,只是現在後面多了數字。這也正是講義拿 STFT 跟小波做比較時重複使用的那張圖:「STFT 的格子大小全部一樣」正是小波基底刻意放棄的性質,好讓它的格子在高頻處短、在低頻處長。那個比較本章沒有展開。セルを数えてみよう。$L_x$ 標本の信号を、窓長 $N_W$、DFT 長 $N_W$、ホップを窓長に等しく取って分析すると、$L_x/N_W$ 列と $N_W$ 行が得られる。すなわち $N_W$ をどう選んでも $L_x$ 個のセルである。覆われる平面の大きさも変わらない。$L_x/f_s$ 秒かける $f_s$ ヘルツであるから、各セルの面積はその単位で $(N_W/f_s)\times(f_s/N_W)=1$ であり、これもまた $N_W$ に依らない。したがって 図 9-3 の二つの格子は、同じ面積のタイルを同じ枚数だけ、違う切り方で並べたものである。これはその図の説明文がすでに述べている一文そのものであり、いま数がその裏づけとして加わった。これは講義が STFT とウェーブレットを比較するときに再び使う絵でもある。「STFT のセルはすべて同じ大きさである」という性質こそ、ウェーブレット基底が意図的に手放すものである。高い周波数では短く、低い周波数では長いセルを得るためである。その比較は本章では展開しない。
§9.3.1 and §9.3.2 settled window shape and window length one at a time. The lecture puts both sides of the same window on a single slide: $w[n]$ is the only reason the STFT can localize anything in time, and it is also the one thing that spoils the frequency axis — by exactly the mechanism §9.3.1 opens with. This subsection writes that ledger out in full: the two-step derivation behind the convolution, the name the lecture gives to the object being convolved, the two names it gives to the damage, and what each kind of damage looks like on a spectrogram.§9.3.1 與 §9.3.2 分別處理了窗的形狀與窗的長度。講義則把同一個窗的兩面放進同一張投影片:$w[n]$ 是 STFT 之所以能在時間上定位的唯一原因,同時也是毀掉頻率軸的唯一元兇——而且正是 §9.3.1 開頭所說的那個機制。本小節把這本帳完整寫出來:卷積背後的兩步推導、講義給被卷積的那個對象取的名字、講義給兩種損害取的兩個名字,以及每一種損害在頻譜圖上長什麼樣子。§9.3.1 と §9.3.2 では窓の形状と窓長を一つずつ片付けた。講義は同じ窓の両面を一枚のスライドに載せる。$w[n]$ は STFT が時間方向で位置を特定できる唯一の理由であり、同時に周波数軸を台無しにする唯一の原因でもある。しかもそれは §9.3.1 の冒頭で述べた機構そのものである。本小節ではその差引勘定を余さず書き下す。畳み込みの背後にある二段階の導出、畳み込まれる対象に講義が与えた呼び名、二種類の損害に与えた二つの呼び名、そしてそれぞれの損害がスペクトログラム上でどう見えるかである。
The slide writes the window length $N_W$; that is §9.2.1's $L$ under another letter. Because $w[n]$ is nonzero only for $0 \le n \le N_W-1$, the product $x[n_0+n]\,w[n]$ keeps only the stretch $n_0 \le n \le n_0+N_W-1$ of the signal and throws everything else away. That is the whole purchase: the shorter the window, the more sharply the STFT can say when a given frequency was present. Everything from here on is the bill.投影片把窗長寫成 $N_W$,那就是 §9.2.1 的 $L$ 換了一個字母。因為 $w[n]$ 只在 $0 \le n \le N_W-1$ 上非零,乘積 $x[n_0+n]\,w[n]$ 就只保留訊號中 $n_0 \le n \le n_0+N_W-1$ 的那一段,其餘全部丟掉。這就是買到的全部:窗越短,STFT 越能明確指出某個頻率是在什麼時候出現的。從這裡往下,都是帳單。スライドは窓長を $N_W$ と書く。これは §9.2.1 の $L$ を別の文字にしたものにすぎない。$w[n]$ は $0 \le n \le N_W-1$ でしか零でないので、積 $x[n_0+n]\,w[n]$ は信号のうち $n_0 \le n \le n_0+N_W-1$ の区間だけを残し、他はすべて捨てる。買えるものはこれだけである。窓が短いほど、ある周波数がいつ現れたのかを STFT は鋭く言い当てられる。ここから先はすべて請求書である。
Write the STFT of the frame that starts at $n_0$ in DTFT form, so that frequency is continuous rather than sampled at the DFT bins of §9.2.2:把從 $n_0$ 開始的那一段的 STFT 寫成 DTFT 的形式,讓頻率是連續的,而不是像 §9.2.2 那樣取在 DFT 的頻格上:$n_0$ から始まるフレームの STFT を DTFT の形で書く。周波数は §9.2.2 のように DFT のビンで標本化せず、連続のままとする。
The slide drops the $\tfrac{1}{2\pi}$; it is written back in here. The derivation is two steps, and both of them are standard DTFT properties:投影片省略了 $\tfrac{1}{2\pi}$,這裡把它補回來。推導只有兩步,而且兩步都是標準的 DTFT 性質:スライドでは $\tfrac{1}{2\pi}$ が省かれているが、ここでは書き戻してある。導出は二段階で、どちらも DTFT の標準的な性質である。
The factor that the integral convolves $W$ against is $e^{j\theta n_0}X(e^{j\theta})$, and the slide calls it the twisted parent spectrum. The parent is $X(e^{j\theta})$ — the spectrum of the whole original signal, one and the same for every frame. The twist is the linear phase $e^{j\theta n_0}$, which turns with the frame position $n_0$. That factor has magnitude $1$ at every $\theta$, so $|X|$ is unchanged: nothing is added to the parent and nothing is taken from it, and each of its frequency components merely has its phase rotated by an amount proportional to both $\theta$ and $n_0$.積分裡被拿去跟 $W$ 做卷積的那一項是 $e^{j\theta n_0}X(e^{j\theta})$,投影片把它叫做被扭轉的母頻譜。母指的是 $X(e^{j\theta})$——原訊號整段的頻譜,對每一段音框都是同一個。扭轉指的是那個線性相位 $e^{j\theta n_0}$,它隨著音框位置 $n_0$ 而轉動。這個因子在每個 $\theta$ 上的大小都是 $1$,所以 $|X|$ 完全沒變:母頻譜沒有被加進什麼,也沒有被拿走什麼,只是它的每一個頻率成分的相位,依照與 $\theta$ 和 $n_0$ 都成正比的量旋轉了而已。積分のなかで $W$ と畳み込まれる相手は $e^{j\theta n_0}X(e^{j\theta})$ であり、スライドはこれをねじられた親スペクトルと呼ぶ。親とは $X(e^{j\theta})$、すなわち元の信号全体のスペクトルであり、どのフレームでも同一のものである。ねじれとは線形位相 $e^{j\theta n_0}$ のことで、フレーム位置 $n_0$ とともに回転する。この因子はどの $\theta$ でも振幅が $1$ なので $|X|$ は変わらない。親スペクトルに何かが加わるのでも、何かが失われるのでもなく、各周波数成分の位相が $\theta$ と $n_0$ の両方に比例する量だけ回されるだけである。
Read that way, every column of a spectrogram is the same parent spectrum — twisted by a phase that depends on where its frame sits, and then smeared by $W$. The twist is what makes the columns differ from one another in phase; the smearing by $W$ is what makes every one of them worse than $X$ itself.這樣讀的話,頻譜圖的每一欄都是同一個母頻譜——先被一個隨音框位置而定的相位扭轉過,再被 $W$ 抹開。扭轉是各欄彼此在相位上不同的原因;被 $W$ 抹開,才是每一欄都比 $X$ 本身更糟的原因。こう読めば、スペクトログラムのどの列も同じ親スペクトルである。フレームの位置で決まる位相にねじられ、そのうえで $W$ によって抹消されたものにすぎない。ねじれは各列どうしの位相の違いを生むだけであり、$W$ による抹消こそが、どの列をも $X$ 自身より劣化させている原因である。
The slide's own label for this is same problems as windowing for FIR design, and it is meant literally. In the window method of FIR design one takes an ideal impulse response that is infinitely long, multiplies it by a window to make it finite, and therefore convolves the ideal frequency response with $W$ — which is what produces a transition band where the ideal response had a jump, and ripples where it was flat: the Gibbs phenomenon. It is the same equation; only the object being windowed changes, from a filter's impulse response to a stretch of a signal. Chapter 14 works that side out in detail: §14.2.2 for the design steps, §14.3.2 for where Gibbs comes from, and §14.3.3 for which feature of the window controls which defect.投影片在這裡的標題就是 same problems as windowing for FIR design,而且這句話是照字面講的。用窗函數法設計 FIR 濾波器時,是把無限長的理想脈衝響應乘上一個窗讓它變成有限長,於是理想的頻率響應就被 $W$ 卷積——這就是為什麼本來是跳變的地方出現過渡帶、本來平坦的地方出現漣波:也就是 Gibbs 現象。式子完全一樣,只是被加窗的對象從「濾波器的脈衝響應」換成了「訊號的一段」。第 14 章把那一邊講得很細:§14.2.2 是設計步驟,§14.3.2 是 Gibbs 現象的來源,§14.3.3 則說明窗的哪一個特徵負責哪一種缺陷。スライドがここに付けている見出しがまさに same problems as windowing for FIR design であり、これは文字どおりの意味である。窓関数法で FIR フィルタを設計するときは、無限に長い理想インパルス応答に窓を掛けて有限長にする。そのため理想の周波数応答は $W$ と畳み込まれ、跳びのあったところに遷移帯域が、平坦だったところに漣波が生じる。これが Gibbs 現象である。式はまったく同じで、窓を掛けられる対象が「フィルタのインパルス応答」から「信号のある区間」に変わるだけである。第 14 章はその側を詳しく扱っている。§14.2.2 が設計手順、§14.3.2 が Gibbs 現象の出どころ、§14.3.3 が窓のどの特徴がどの欠陥を支配するかである。
Let $x[n]$ be a pure sinusoid at frequency $\omega_0$. Then $X$ is a single impulse, and convolving anything with an impulse only moves it, so設 $x[n]$ 是頻率為 $\omega_0$ 的純正弦波。那麼 $X$ 就是一根脈衝,而任何東西跟脈衝做卷積都只是把它搬個位置,於是$x[n]$ を周波数 $\omega_0$ の純正弦波とする。このとき $X$ は一本のインパルスであり、何であれインパルスと畳み込めば位置が移るだけなので、
— the window's own spectrum transplanted intact to $\omega_0$, which is the result §9.2.3 already quotes for the pure-tone limiting slice. The slide gives the two defects of that picture two names:——窗自己的頻譜原封不動地被搬到 $\omega_0$ 上,這正是 §9.2.3 在純音那個極限切片中已經寫過的結果。投影片給這張圖的兩個缺陷各取了一個名字:つまり窓自身のスペクトルがそっくりそのまま $\omega_0$ に移植されたものであり、これは §9.2.3 が純音の極限的な切り口としてすでに挙げている結果である。スライドはこの図の二つの欠陥に、それぞれ名前を与えている。
| The slide's term用語用語 | What it corresponds to對應対応するもの | What it does現象現象 |
|---|---|---|
| blurring(模糊)blurring(模糊)blurring(ぼけ) | mainlobe width(主瓣寬度)主瓣寬度主ローブ幅 | A single frequency is spread into a peak of finite width, so two frequencies close together cannot be told apart.單一頻率被抹成一個有寬度的峰,靠得近的兩個頻率就分不開了。一つの周波数が幅をもつ峰に広げられてしまい、近接した二つの周波数を区別できなくなる。 |
| ghosting(鬼影)ghosting(鬼影)ghosting(ゴースト) | sidelobes(旁瓣)旁瓣サイドローブ | False small peaks appear away from the true frequency. They can be mistaken for other signals, or can bury a genuinely weak one.在真實頻率以外的地方冒出假的小峰,可能被誤認成別的訊號,也可能蓋過真正微弱的訊號。本当の周波数から離れたところに偽の小さな峰が現れる。別の信号と取り違えられたり、本当に弱い信号を覆い隠してしまったりする。 |
On a spectrogram the two look quite different. Blurring makes the horizontal band of a steady tone thicker; ghosting puts faint stripes above and below that band, parallel to it and present at the same times. A thick band is a resolution problem; faint parallel stripes are leakage, and the lower the sidelobes, the fainter they get.在頻譜圖上,這兩者看起來很不一樣。blurring 讓一個穩定音調的水平帶變粗;ghosting 則讓那條帶子的上下出現淡淡的條紋,與它平行,而且出現在同樣的時間上。帶子變粗是解析度的問題;淡淡的平行條紋則是洩漏,旁瓣壓得越低,它們就越淡。スペクトログラム上では、この二つはまったく違って見える。blurring は定常な音の水平な帯を太くする。ghosting はその帯の上下に淡い縞を生じさせる。縞は帯と平行で、同じ時刻に現れる。帯が太いのは分解能の問題であり、淡い平行な縞は漏れである。サイドローブを低くするほど縞は淡くなる。
Use a window that falls gradually to near zero at both ends instead of one that stops dead. Hamming, for instance, written with the index centred on $0$:改用一個兩端逐漸降到接近 $0$ 的窗,而不是說斷就斷的那種。例如 Hamming 窗,把索引寫成以 $0$ 為中心:両端で急に切れる窓ではなく、両端がなだらかに $0$ 近くまで落ちていく窓を使う。たとえば Hamming 窓を、索引を $0$ 中心にして書くと、
The sign in front of the cosine is a plus, and that is not a misprint. With the index centred on $0$ the cosine equals $+1$ in the middle of the window, so it has to be added to make $w[0]=1$ the largest value. A window table indexed from the left edge instead, over $0 \le n \le L-1$, writes the very same window with a minus: that is the generalized-Hanning row of §8.7.2 in Chapter 8, $\alpha-(1-\alpha)\cos\frac{2\pi n}{L-1}$ with $\alpha=0.54$. There the cosine equals $+1$ at the edge, where the window has to be small, so it must be subtracted. The sign simply records where the origin was put, and nothing more.餘弦前面的符號是加號,而且這不是印錯。索引以 $0$ 為中心時,餘弦在窗的正中央等於 $+1$,所以必須加上去,才會讓 $w[0]=1$ 成為最大值。若改成從左端起算、在 $0 \le n \le L-1$ 上列表,同一個窗就要寫成減號:那就是第 8 章 §8.7.2 的廣義漢寧窗那一列,$\alpha-(1-\alpha)\cos\frac{2\pi n}{L-1}$,其中 $\alpha=0.54$。在那裡,餘弦在邊緣等於 $+1$,而邊緣正是窗必須很小的地方,所以要減掉。符號只是在記錄原點被放在哪裡,如此而已。余弦の前の符号はプラスであり、これは誤植ではない。索引を $0$ 中心に取ると、余弦は窓の中央で $+1$ になるので、$w[0]=1$ を最大値にするには足さなければならない。これに対し左端から数えて $0 \le n \le L-1$ の上で表にすると、まったく同じ窓がマイナスで書かれる。第 8 章 §8.7.2 の一般化ハニング窓の行、$\alpha-(1-\alpha)\cos\frac{2\pi n}{L-1}$、$\alpha=0.54$ がそれである。そちらでは余弦が端で $+1$ になり、端こそ窓が小さくなければならない場所なので、引く必要がある。符号は原点をどこに置いたかを記録しているにすぎない。
The effect is the one §9.3.1's table records. Hamming's sidelobes drop below about $-40$ dB, so ghosting all but disappears; the price is a mainlobe about twice the rectangular width, so blurring gets somewhat worse. Measured directly on the two windows: the rectangular null-to-null mainlobe is $4\pi/L$ with a peak sidelobe of $-13.3$ dB, while Hamming's mainlobe comes out between $4.09$ and $4.33$ times $2\pi/L$ — that is, $\approx 8\pi/L$, the table's value — with a peak sidelobe between $-41.7$ and $-42.6$ dB, for $L=31$, $64$ and $101$. The whole trade in one line: some $29$ dB of ghosting bought with a factor of two of blurring.效果就是 §9.3.1 表中記錄的那些。Hamming 窗的旁瓣掉到大約 $-40$ dB 以下,ghosting 幾乎消失;代價是主瓣大約變成矩形窗的兩倍寬,所以 blurring 稍微變嚴重。直接對這兩個窗量過:矩形窗零點到零點的主瓣寬度是 $4\pi/L$,旁瓣峰值 $-13.3$ dB;而在 $L=31$、$64$、$101$ 時,Hamming 窗的主瓣落在 $2\pi/L$ 的 $4.09$ 到 $4.33$ 倍之間——也就是 $\approx 8\pi/L$,正是表中的值——旁瓣峰值則在 $-41.7$ 到 $-42.6$ dB 之間。整筆交易可以寫成一句話:用兩倍的 blurring,買到大約 $29$ dB 的 ghosting。効果は §9.3.1 の表が記録しているとおりである。Hamming 窓のサイドローブはおよそ $-40$ dB より下まで落ち、ghosting はほぼ消える。代償として主ローブは矩形窓のおよそ二倍の幅になり、blurring は少し悪くなる。二つの窓を直接測ってみた。矩形窓の零点間の主ローブ幅は $4\pi/L$、サイドローブの最大値は $-13.3$ dB である。$L=31$、$64$、$101$ について Hamming 窓の主ローブは $2\pi/L$ の $4.09$ 倍から $4.33$ 倍、すなわち表の値どおり $\approx 8\pi/L$ であり、サイドローブの最大値は $-41.7$ dB から $-42.6$ dB のあいだに収まる。取引の全体は一行で言える。二倍の blurring と引き換えに、およそ $29$ dB の ghosting を買うのである。
Three figures already in place are these two slides, drawn:前面已經有三張圖,其實就是這兩張投影片畫出來的樣子:すでに置かれている三つの図が、この二枚のスライドを絵にしたものである。
The spectrogram(頻譜圖)is the squared magnitude of the STFT, almost always displayed in decibels as an image: horizontal axis time, vertical axis frequency, color/brightness $=$ energy. It discards the STFT phase and keeps the part the eye can read.頻譜圖是 STFT 振幅的平方,而且幾乎總是以分貝為單位畫成一張影像:橫軸為時間,縱軸為頻率,顏色/亮度 $=$ 能量。它捨棄了 STFT 的相位,只留下眼睛讀得出來的那一部分。スペクトログラムとは STFT の振幅の二乗であり、ほとんどの場合デシベル表示の画像として描かれる。横軸が時間、縦軸が周波数、色や明るさ $=$ エネルギーである。STFT の位相は捨て、目で読める部分だけを残す。
Axis calibration for sampling rate $f_s$, hop $M$, DFT length $N$ (exactly the axes
constructed in dsp10.m):在取樣率 $f_s$、跳距 $M$、DFT 長度 $N$ 之下的座標軸刻度(正是 dsp10.m 中所建構的那兩條軸):標本化レート $f_s$、ホップ $M$、DFT 長 $N$ のときの軸の目盛り(まさに dsp10.m で構成している軸である):
For real signals only bins $0\le k< N/2$ are kept ($f$ up to $f_s/2$); the upper half is the mirror image. The dB scale matters: audio features of interest (harmonics, formants, reverb tails) span 60–80 dB of dynamic range and would be invisible on a linear scale.對實數訊號只保留 $0\le k< N/2$ 這些頻格($f$ 到 $f_s/2$ 為止);上半部是鏡像。dB 刻度很重要:我們關心的音訊特徵(諧波、共振峰、殘響尾音)橫跨 60–80 dB 的動態範圍,在線性刻度上根本看不見。実信号では $0\le k< N/2$ のビンだけを残す($f$ は $f_s/2$ まで)。上半分は鏡像である。dB 目盛りであることが効いてくる。注目したい音響的特徴(高調波、フォルマント、残響の尾)は 60–80 dB のダイナミックレンジにわたっており、線形目盛りではまったく見えないからである。
The formulas above define $S[m,k]$ as a two-dimensional array of numbers. The lecture earns the right to call it an image by drawing one recording of speech three times on a single slide, and the three pictures differ in nothing but how much of it is shown at once.上面那幾條式子把 $S[m,k]$ 定義成一個二維的數字陣列。講義則用一張投影片把同一段語音錄音畫了三次,才取得把它叫做「影像」的資格;而這三張圖之間唯一的差別,只是一次看多少。上の式は $S[m,k]$ を二次元の数の配列として定義している。講義は一枚のスライドに同じ音声録音を三度描くことで、それを「画像」と呼ぶ資格を得る。三つの絵の違いは、一度にどれだけを見せているかだけである。
No property of the data changes between the second picture and the third. What each column is was settled in §9.2.2 and is looked at from both directions in §9.5.1, and nothing is added here. The only thing that changes is the number of columns per unit of display width, and that is arithmetic. Columns are $M/f_s$ seconds apart, so a picture $P$ pixels wide covering $T$ seconds puts $P\,M/(T f_s)$ pixels between neighbouring columns: they are separately visible while that is above $1$, and fuse once it drops below.第二張圖與第三張圖之間,資料的任何性質都沒有改變。每一欄到底是什麼,§9.2.2 已經定下來,§9.5.1 又從兩個方向各看了一次,這裡不再添一個字。唯一改變的是每單位顯示寬度上有多少欄,而那是算術。相鄰兩欄相距 $M/f_s$ 秒,所以一張寬 $P$ 個像素、涵蓋 $T$ 秒的圖,在相鄰兩欄之間放了 $P\,M/(T f_s)$ 個像素:這個數大於 $1$ 時欄是分得開的,掉到 $1$ 以下就融在一起了。二枚目と三枚目のあいだで、データの性質は何も変わっていない。各列が何であるかは §9.2.2 で定まっており、§9.5.1 が二つの方向から眺めている。ここで付け加えることは何もない。変わるのは表示幅あたりの列数だけであり、それは算術である。隣り合う列は $M/f_s$ 秒離れているので、幅 $P$ 画素で $T$ 秒を覆う絵は、隣り合う列のあいだに $P\,M/(T f_s)$ 画素を置くことになる。この数が $1$ より大きいあいだ列は見分けられ、$1$ を下回ると融合する。
The classic test signal for time–frequency analysis is the linear chirp (線性掃頻訊號), whose instantaneous frequency rises linearly:時頻分析的經典測試訊號是線性掃頻訊號,它的瞬時頻率隨時間線性上升:時間周波数解析の古典的なテスト信号は線形チャープであり、その瞬時周波数は時間に対して線形に上昇する。
stft, 87.5% overlap, 60 dB display range). Left, $L=64$ (32 ms): the ridge is thick in frequency but time events would be sharp — wideband. Right, $L=1024$ (512 ms): the ridge is spectrally thin, but the line blurs along time and bends at the edges because the chirp sweeps ~77 Hz within each window — narrowband.(同一訊號、同一不確定性原理:短窗時間準、頻率糊;長窗頻率準、時間糊。)圖 9-5 — 掃頻訊號的 Hann 窗頻譜圖(scipy stft,87.5% 重疊,顯示範圍 60 dB)。左,$L=64$(32 ms):脊在頻率上很粗,但時間上的事件會很銳利——寬帶。右,$L=1024$(512 ms):脊在頻譜上很細,但線條沿時間方向糊開,兩端還彎了,因為掃頻訊號在每一個視窗之內就已經掃過約 77 Hz——窄帶。(同一訊號、同一不確定性原理:短窗時間準、頻率糊;長窗頻率準、時間糊。)図 9-5 — チャープの Hann 窓スペクトログラム(scipy stft、87.5% の重なり、表示レンジ 60 dB)。左、$L=64$(32 ms):尾根は周波数方向に太いが、時間的な事象は鋭く出る——広帯域。右、$L=1024$(512 ms):尾根はスペクトル的に細いが、線は時間方向ににじみ、両端で曲がっている。チャープが一つの窓の内側ですでに約 77 Hz も掃引してしまうからである——狭帯域。(同じ信号、同じ不確定性原理である。短い窓は時間が正確で周波数がぼけ、長い窓は周波数が正確で時間がぼける。)The lecture's slide "Narrowband vs. Wideband" summarizes the effect of varying window length on real sounds (speech is the standard example):講義中「Narrowband vs. Wideband」那張投影片,整理了改變窗長對真實聲音所造成的影響(語音是標準的例子):講義のスライド「Narrowband vs. Wideband」は、窓長を変えたときに実際の音へ現れる効果をまとめている(音声が標準的な例である):
| Narrowband spectrogram(窄帶)窄帶頻譜圖狭帯域スペクトログラム | Wideband spectrogram(寬帶)寬帶頻譜圖広帯域スペクトログラム | |
|---|---|---|
| Window length窗長窓長 | long (e.g. > 20 ms for speech)長(語音約 > 20 ms)長い(音声なら例えば > 20 ms) | short (e.g. < 5 ms)短(例如 < 5 ms)短い(例えば < 5 ms) |
| Filter bandwidth濾波器頻寬フィルタの帯域幅 | narrow → fine $\Delta f$窄 → $\Delta f$ 精細狭い → $\Delta f$ が細かい | wide → fine $\Delta t$寬 → $\Delta t$ 精細広い → $\Delta t$ が細かい |
| What you see看得見什麼何が見えるか | individual pitch harmonics as horizontal lines(諧波線)一條條水平線,是個別的音高諧波個々のピッチの高調波が水平線として見える | individual glottal pulses as vertical striations(聲門脈衝直紋)一道道垂直紋路,是個別的聲門脈衝個々の声門パルスが縦縞として見える |
| What blurs什麼會糊掉何がぼけるか | onsets, plosives, fast transitions起音、爆破音、快速的轉換立ち上がり、破裂音、速い遷移 | closely spaced harmonics merge; formant envelopes(共振峰)stand out靠得很近的諧波會合併;共振峰的包絡則凸顯出來近接した高調波は融合し、フォルマントの包絡が際立つ |
The table above is qualitative; the lecture's own version of the slide carries numbers, and they are worth writing down because they are the ones that decide which picture a given window length produces. Both pictures on that slide have a $4000$ Hz frequency axis, so the sampling rate is $f_s=8$ kHz, and the two standard window lengths are $256$ and $48$ points.上面那張表是定性的;講義自己的那張投影片則帶著數字,而這些數字值得寫下來,因為真正決定某個窗長會畫出哪一種圖的就是它們。那張投影片上的兩張圖,頻率軸都到 $4000$ Hz,所以取樣率是 $f_s=8$ kHz,而兩個標準窗長分別是 $256$ 點與 $48$ 點。上の表は定性的なものである。講義のスライドそのものには数値が入っており、ある窓長がどちらの絵を生むかを実際に決めているのはその数値なので、書き留めておく価値がある。そのスライドの二枚の図はどちらも周波数軸が $4000$ Hz までなので標本化レートは $f_s=8$ kHz であり、二つの標準的な窓長は $256$ 点と $48$ 点である。
| At $f_s=8$ kHz在 $f_s=8$ kHz 之下$f_s=8$ kHz のとき | Narrowband(窄帶)窄帶(也寫作窄頻,narrowband)狭帯域(narrowband) | Wideband(寬帶)寬帶(也寫作寬頻,wideband)広帯域(wideband) |
|---|---|---|
| Window length $N_W$窗長 $N_W$窓長 $N_W$ | $256$ points $=32$ ms$256$ 點 $=32$ ms$256$ 点 $=32$ ms | $48$ points $=6$ ms$48$ 點 $=6$ ms$48$ 点 $=6$ ms |
| Hann mainlobe, null to nullHann 主瓣寬度(零點到零點)Hann 主ローブ幅(零点から零点まで) | about $125$ Hz約 $125$ Hzおよそ $125$ Hz | about $670$ Hz約 $670$ Hzおよそ $670$ Hz |
| What it is compared against拿來比較的基準何と比べるのか | the mainlobe is narrower than the pitch $F_0$(about $100$ to $250$ Hz)主瓣比基頻 $F_0$ 還窄(約 $100$ 至 $250$ Hz)主ローブが基本周波数 $F_0$ より狭い(およそ $100$ から $250$ Hz) | the window is shorter than one glottal period(about $4$ to $10$ ms)窗長比一個聲門週期還短(約 $4$ 至 $10$ ms)窓が声門周期一つより短い(およそ $4$ から $10$ ms) |
| What you see看得到的是見えるもの | the harmonics $F_0, 2F_0, 3F_0,\dots$ as separate horizontal lines諧波 $F_0, 2F_0, 3F_0,\dots$,一條條分開的水平線高調波 $F_0, 2F_0, 3F_0,\dots$ が、分かれた水平線として | the glottal pulses, one vertical line per closure of the vocal folds聲門脈衝,聲帶每振動一次就是一條垂直線声門パルス、声帯が一度閉じるごとに一本の垂直線 |
| What stays unclear看不清楚的是はっきり見えないもの | where in time each pulse falls每一個脈衝落在時間軸的什麼位置各パルスが時間軸のどこに落ちるか | the individual harmonics — they merge into one another個別的諧波——它們融合在一起了個々の高調波——互いに融合してしまう |
| What it is good for適合用來觀察何を見るのに向くか | pitch(音高)and how it moves音高(pitch)及其變化ピッチ(音高)とその動き | formants(共振峰)— broad dark horizontal bands共振峰(formant)——寬而深色的水平帶フォルマント(formant)——幅の広い濃い水平の帯 |
Both comparison rules can be turned into a condition on the window length alone, and when that is done they say something memorable. Narrowband wants the mainlobe below $F_0$, that is $c\,f_s/N_W \le F_0$ with $c=4$; wideband wants the window no longer than one glottal period, that is $N_W/f_s \le 1/F_0$:兩條比較規則都可以整理成只關於窗長的條件,整理完之後它們說的是一件很好記的事。窄帶要主瓣低於 $F_0$,也就是 $c\,f_s/N_W \le F_0$(取 $c=4$);寬帶要窗長不超過一個聲門週期,也就是 $N_W/f_s \le 1/F_0$:二つの比較規則は、どちらも窓長だけについての条件に書き直せる。書き直してみると、覚えやすいことを述べていることがわかる。狭帯域は主ローブが $F_0$ より下であることを要求する。すなわち $c=4$ として $c\,f_s/N_W \le F_0$ である。広帯域は窓が声門周期一つを超えないことを要求する。すなわち $N_W/f_s \le 1/F_0$ である。
So the whole of the slide is one sentence: a narrowband window spans at least four pitch periods, a wideband window at most one. Check it against the numbers in the table. At $F_0=150$ Hz the pitch period is $6.7$ ms, so narrowband needs at least $26.7$ ms and $32$ ms clears it; wideband is allowed up to $6.7$ ms and $6$ ms clears it. At the bottom of the male range, $F_0=100$ Hz, narrowband needs $40$ ms $=320$ points, and the slide's $256$-point window would no longer resolve the harmonics — the rule, not the number $256$, is what to remember.所以整張投影片就是一句話:窄帶的窗至少跨過四個音高週期,寬帶的窗最多跨過一個。拿表裡的數字對一下。$F_0=150$ Hz 時音高週期是 $6.7$ ms,窄帶至少要 $26.7$ ms,$32$ ms 過關;寬帶最多 $6.7$ ms,$6$ ms 也過關。到了男聲的低端 $F_0=100$ Hz,窄帶需要 $40$ ms $=320$ 點,投影片那個 $256$ 點的窗就已經分不開諧波了——要記住的是這條規則,不是 $256$ 這個數字。つまりスライド全体は一文に要約できる。狭帯域の窓は少なくとも四つのピッチ周期にまたがり、広帯域の窓はせいぜい一つである。表の数値と突き合わせてみよう。$F_0=150$ Hz ならピッチ周期は $6.7$ ms なので、狭帯域には最低 $26.7$ ms が必要であり、$32$ ms はこれを満たす。広帯域は $6.7$ ms までが許され、$6$ ms もこれを満たす。男声の低い側 $F_0=100$ Hz では狭帯域に $40$ ms $=320$ 点が必要になり、スライドの $256$ 点の窓ではもはや高調波を分離できない。覚えるべきは $256$ という数ではなく、この規則のほうである。
Nothing in either name refers to the picture. They are named after the bandwidth of the analysis filter, which is §9.5's reading of the STFT: every bin is a bandpass filter whose frequency response is the window spectrum moved to that bin, so the filter's bandwidth is the mainlobe width. A long window gives each filter a narrow band — hence narrowband — and a short window a wide one. The names therefore describe the analyser, not the sound and not the image, which is why the narrowband picture is the one full of fine horizontal detail and the wideband one the coarse-looking picture: the adjective has been applied to the opposite end of the trade from the one the eye notices.這兩個名字跟圖長什麼樣子都沒有關係。它們是依照分析濾波器的頻寬來命名的,也就是 §9.5 對 STFT 的那種讀法:每一個 bin 都是一個帶通濾波器,其頻率響應就是窗的頻譜平移到該 bin,所以濾波器的頻寬就是主瓣寬度。長窗讓每個濾波器的頻帶變窄——所以叫窄帶——短窗則讓它變寬。因此這兩個名字描述的是分析器,不是聲音,也不是影像;這也正是為什麼窄帶的圖反而是細節密密麻麻的那一張,而寬帶的圖看起來反而粗——形容詞被貼在這個取捨中、跟眼睛注意到的那一端相反的那一端上。どちらの名前も、絵の見た目を指してはいない。名前の由来は分析フィルタの帯域幅であり、これは §9.5 による STFT の読み方である。各ビンは帯域通過フィルタであり、その周波数応答は窓のスペクトルをそのビンへ平行移動したものだから、フィルタの帯域幅は主ローブ幅そのものである。長い窓は各フィルタの帯域を狭くし——だから狭帯域という——短い窓は広くする。したがってこの二つの名前が述べているのは分析器であって、音でも画像でもない。狭帯域の図のほうが細かい横縞で埋め尽くされ、広帯域の図のほうが粗く見えるのはそのためである。形容詞は、目が気づく側とは逆の端に貼られているのである。
The figure below runs the whole of this subsection on one synthetic signal. It is speech-like rather than speech: a vowel with rising pitch from $0$ to $0.25$ s, silence to $0.3$ s, a high-frequency fricative hiss like "s" to $0.4$ s, and a second vowel with falling pitch to $0.6$ s. The source is a glottal impulse train (or noise, in the fricative) through three resonators standing for the first three formants, at $f_s=8$ kHz. Choose a window length and watch which of the two pictures appears. The white rectangle is one time–frequency cell, $\delta t\times\delta f$, drawn to scale.下圖把本小節的全部內容跑在同一段合成訊號上。它是「類語音」而不是語音:$0$ 到 $0.25$ 秒是音高上升的母音,到 $0.3$ 秒是靜音,到 $0.4$ 秒是像「ㄙ」那樣的高頻摩擦噪音,到 $0.6$ 秒是另一個音高下降的母音。訊源是聲門脈衝列(摩擦音段則是噪音),通過三個代表前三個共振峰的諧振器,取樣率 $f_s=8$ kHz。選一個窗長,看看出現的是兩張圖中的哪一張。白色矩形是一個時頻格子 $\delta t\times\delta f$,按實際比例畫出。下の図は、本小節の内容全体を一つの合成信号の上で走らせたものである。音声そのものではなく音声風の信号である。$0$ から $0.25$ 秒はピッチが上昇する母音、$0.3$ 秒まで無音、$0.4$ 秒まで「ス」のような高域の摩擦雑音、$0.6$ 秒までピッチが下降するもう一つの母音である。音源は声門パルス列(摩擦音の区間では雑音)であり、第一から第三フォルマントを表す三つの共振器を通してある。標本化レートは $f_s=8$ kHz である。窓長を選び、二枚の絵のどちらが現れるかを見てほしい。白い長方形は一つの時間周波数セル $\delta t\times\delta f$ であり、実寸で描いてある。
What to step through, in order:建議依序這樣看:順に追っていくとよい点は次のとおりである。
The hop size $M$ (frame advance) controls how densely the time axis is sampled.
Overlap(重疊)is $L-M$ samples, i.e. overlap fraction $1-M/L$. Typical
choices are 50% ($M=L/2$) or 75% ($M=L/4$ — the choice in dsp10.m, where
$M=N/4$).跳距 $M$(音框的前進量)控制時間軸被取樣得多密。重疊為 $L-M$ 個樣本,也就是重疊比例 $1-M/L$。典型的選擇是 50%($M=L/2$)或 75%($M=L/4$——dsp10.m 採用的正是後者,其中 $M=N/4$)。ホップ長 $M$(フレームの前進量)は、時間軸をどれだけ密に標本化するかを決める。重なりは $L-M$ 標本、すなわち重なり率は $1-M/L$ である。典型的な選択は 50%($M=L/2$)か 75%($M=L/4$。dsp10.m が採るのはこちらで、そこでは $M=N/4$ である)。
MATLAB's Signal Processing Toolbox provides spectrogram directly; the
homework instead builds it from first principles (frame → window → FFT → magnitude
squared). Both in one place:MATLAB 的 Signal Processing Toolbox 直接提供了 spectrogram;而作業要求的則是從頭自己做(切音框 → 加窗 → FFT → 取振幅平方)。兩者並列如下:MATLAB の Signal Processing Toolbox には spectrogram が直接用意されている。一方で課題では、それを第一原理から組み立てる(フレーム化 → 窓かけ → FFT → 振幅の二乗)。両者を並べると次のようになる。
% Toolbox one-liner: Hann window, length N, 75% overlap, N-point DFT
N = 1024; M = N/4;
spectrogram(x, hann(N), N-M, N, Fs, 'yaxis'); % draws dB image directly
% Equivalent from scratch (the dsp10.m approach)
w = 0.5*(1 - cos(2*pi*(0:N-1)'/N)); % Hann window
num_frames = floor((length(x)-N)/M) + 1;
X = zeros(N, num_frames);
for m = 1:num_frames
seg = x((m-1)*M+1 : (m-1)*M+N) .* w; % frame x window
X(:, m) = abs(fft(seg)).^2; % power spectrum
end
t = (0:num_frames-1)*M/Fs; f = (0:N/2-1)*Fs/N;
image(t, f, 10*log10(X(1:N/2,:))); axis xy; colormap(hot(256)); colorbar;
spectrogram(x, window, noverlap, nfft, fs) takes the overlap
(samples shared between consecutive frames), not the hop size. For hop
$M$ pass noverlap = N - M. Passing the hop by mistake silently produces a
spectrogram with the wrong time density. Also remember axis xy when using
image — otherwise the frequency axis is upside-down.spectrogram(x, window, noverlap, nfft, fs) 收的是重疊量(相鄰兩個音框共用的樣本數),不是跳距。若跳距為 $M$,要傳入的是 noverlap = N - M。不小心傳成跳距,會悄無聲息地產生一張時間密度錯誤的頻譜圖。另外,用 image 畫圖時別忘了 axis xy——否則頻率軸會上下顛倒。spectrogram(x, window, noverlap, nfft, fs) が受け取るのは重なり量(隣り合うフレームが共有する標本数)であって、ホップ長ではない。ホップが $M$ なら noverlap = N - M を渡す。誤ってホップを渡すと、時間密度の誤ったスペクトログラムが黙って出来上がる。また image を使うときは axis xy を忘れないこと。さもないと周波数軸が上下逆になる。
The lecture draws its spectrograms with four lines of its own, and they are worth seeing because every line of them maps onto something above:講義用它自己的四行指令畫頻譜圖,那四行值得看一下,因為每一行都能對應到上面的某個東西:講義は自前の四行でスペクトログラムを描いている。その四行は一見の価値がある。どの行も上で述べた何かに対応しているからである。
% the lecture slide, as printed
[d, sr] = wavread('mpgr1_sx419.wav'); % d = samples, sr = sampling rate
Nw = 256; % window length (Hann by default)
specgram(d, Nw, sr) % draw it; sr calibrates both axes
caxis([-80 0]) % colour scale from -80 dB to 0 dB
colorbar % show the colour bar
It will not run on a current MATLAB. wavread and specgram have both been removed from the product — wavread in favour of audioread, and specgram in favour of spectrogram, whose argument list is the one the one-liner above uses. Written out in the modern functions, the slide becomes:它在現在的 MATLAB 上跑不起來。wavread 與 specgram 兩個都已經從產品中移除了——wavread 被 audioread 取代,specgram 被 spectrogram 取代,而後者的參數表就是上面那行指令用的那一套。用現在的函式寫出來,這張投影片就變成:これは現在の MATLAB では動かない。wavread も specgram も製品から削除されており、wavread は audioread に、specgram は spectrogram に置き換えられている。後者の引数の並びは上の一行命令が使っているものである。現在の関数で書き直すと、このスライドは次のようになる。
% the same slide in the functions that exist today
[d, sr] = audioread('mpgr1_sx419.wav');
Nw = 256;
spectrogram(d, hann(Nw), round(Nw*3/4), Nw, sr, 'yaxis'); % window, overlap, nfft, rate
clim([-80 0]); % before R2022a this function was called caxis
colorbar;
Nothing above needs changing: the listing at the head of this subsection is already in the current form, with audioread and spectrogram and no sign of the two withdrawn names. The two listings differ only in the choices they make, and the differences are worth naming rather than smoothing over:上面沒有任何東西需要改:本小節開頭那段程式本來就是現在的寫法,用的是 audioread 與 spectrogram,那兩個被撤掉的名字一個都沒出現。兩段程式的差別只在各自做了不同的選擇,而這些差別值得講明白,而不是含糊帶過:上のものを直す必要はない。本小節の冒頭の listing はすでに現在の形であり、audioread と spectrogram を使っていて、撤回された二つの名前はどこにも出てこない。二つの listing の違いは、それぞれが行っている選択だけである。その違いはぼかさずに名指ししておく価値がある。
round(Nw*3/4) is a $75\%$ overlap, and so is N-M with M = N/4; both pass the window length as nfft, so neither zero-pads. Both end with 'yaxis', which puts frequency up the vertical axis instead of along the horizontal one.重疊量與 DFT 長度完全一致。round(Nw*3/4) 就是 $75\%$ 的重疊,而 M = N/4 時的 N-M 也是;兩者都把窗長當作 nfft 傳進去,所以都沒有補零。兩者也都以 'yaxis' 結尾,把頻率放到縱軸而不是橫軸。重なりと DFT 長はぴたりと一致する。round(Nw*3/4) は $75\%$ の重なりであり、M = N/4 のときの N-M も同じである。どちらも窓長を nfft として渡すのでゼロ詰めはしない。どちらも 'yaxis' で終わり、周波数を横軸ではなく縦軸に置く。caxis([-80 0]), now clim, fixes the displayed range at $80$ dB below the loudest point. The listing above sets no limit and lets MATLAB choose, which on a quiet recording spends much of the scale on the noise floor. §9.4.1 gives the reason a limit is usually wanted: the features of interest span $60$ to $80$ dB, so clamping to that range is what makes them visible rather than what hides them. The interactive figure in §9.4.3 does the same thing with a $55$ dB floor.只有投影片把色階夾住。caxis([-80 0])(現在叫 clim)把顯示範圍固定在最大值以下 $80$ dB。上面那段沒有設限,交給 MATLAB 自己決定,而在一段很安靜的錄音上,那會把大半個色階花在噪音底層上。§9.4.1 已經給了通常要設限的理由:我們關心的特徵橫跨 $60$ 到 $80$ dB,所以夾到那個範圍是讓它們現形,而不是把它們藏起來。§9.4.3 的互動圖做的是同一件事,底線設在 $55$ dB。色の尺度を固定しているのはスライドだけである。caxis([-80 0])、いまの clim は、表示範囲を最大値の $80$ dB 下までに固定する。上の listing は上限も下限も設けず MATLAB に任せるので、静かな録音では尺度の大半を雑音の底に費やすことになる。§9.4.1 に、通常は制限を設けたい理由が述べてある。注目したい特徴は $60$ から $80$ dB にわたるので、その範囲に固定することこそがそれらを見えるようにするのであって、隠すのではない。§9.4.3 のインタラクティブ図も同じことを $55$ dB の下限で行っている。scipy.signal.spectrogram, or from matplotlib.pyplot.specgram if the drawing is wanted in the same call.在 Python 裡,同一張圖來自 scipy.signal.spectrogram;如果希望同一個呼叫就把圖畫出來,則是 matplotlib.pyplot.specgram。Python では同じ絵が scipy.signal.spectrogram から得られる。描画まで同じ呼び出しで済ませたいなら matplotlib.pyplot.specgram である。Nw = 256 is therefore $256/16000 = 16$ ms here, not $32$ ms — right between the narrowband $32$ ms and the wideband $6$ ms, and so neither. Expect that picture to show harmonics and pulses both half-resolved, which is what the $128$-point setting of the interactive figure looks like at $8$ kHz, that being the same $16$ ms. This is the whole content of §9.3.2's warning in one example: $256$ is not a duration, and the only safe way to read a window length off a slide is to find the sampling rate first — here, by reading it off the frequency axis.那張投影片上的圖,頻率軸一路到 $8000$ Hz。軸停在 $f_s/2$,所以那段錄音是 $f_s=16$ kHz,而不是 §9.4.3 那兩個有名字的設定所用的 $8$ kHz。於是同樣的 Nw = 256 在這裡是 $256/16000 = 16$ ms,而不是 $32$ ms——正好卡在窄帶的 $32$ ms 與寬帶的 $6$ ms 中間,所以兩者都不是。可以預期那張圖上諧波與脈衝都只解析到一半,也就是互動圖在 $8$ kHz 下 $128$ 點那個設定的樣子,因為那同樣是 $16$ ms。這就是 §9.3.2 那則警告的全部內容,濃縮成一個例子:$256$ 不是一個時間長度,而要從投影片上把窗長讀對,唯一安全的辦法是先找出取樣率——在這裡,就是從頻率軸上讀出來。そのスライドの図は周波数軸が $8000$ Hz まで伸びている。軸は $f_s/2$ で止まるので、録音は $f_s=16$ kHz であり、§9.4.3 の名前のついた二つの設定が使う $8$ kHz ではない。したがって同じ Nw = 256 はここでは $256/16000 = 16$ ms であって $32$ ms ではない。狭帯域の $32$ ms と広帯域の $6$ ms のちょうど中間であり、どちらでもない。その図では高調波もパルスも中途半端にしか分解されていないはずである。$8$ kHz におけるインタラクティブ図の $128$ 点の設定と同じ姿であり、そちらも同じ $16$ ms だからである。これが §9.3.2 の注意の内容そのものを一つの例にしたものである。$256$ は時間の長さではない。スライドから窓長を正しく読み取る唯一安全な方法は、まず標本化レートを突き止めることであり、ここではそれを周波数軸から読み取るのである。
Fix one frequency $\omega_k$ and watch $X(n,\omega_k)$ evolve with $n$. Rearranging the STFT definition (with the window treated as a filter impulse response):固定一個頻率 $\omega_k$,然後看 $X(n,\omega_k)$ 如何隨 $n$ 演變。把 STFT 的定義重新整理(並把視窗當成一個濾波器的脈衝響應):周波数を一つ $\omega_k$ に固定し、$X(n,\omega_k)$ が $n$ とともにどう変化するかを見る。STFT の定義を並べ替えると(窓をフィルタのインパルス応答とみなす)、
So each STFT frequency row is produced by: (1) heterodyne(混頻)— multiply by $e^{-j\omega_k n}$ to shift the band around $\omega_k$ down to DC; (2) lowpass filter with $\tilde w[n]$, whose bandwidth is the window mainlobe; (3) keep every $M$-th output sample (the hop). The STFT is therefore a uniform filterbank(濾波器組)of $N$ bandpass channels, each of bandwidth $\approx c\,f_s/L$, spaced $f_s/N$ apart, downsampled by $M$.所以 STFT 的每一條頻率列都是這樣產生的:(1) 混頻——乘上 $e^{-j\omega_k n}$,把 $\omega_k$ 附近的頻帶搬到直流;(2) 用 $\tilde w[n]$ 做低通濾波,其頻寬就是視窗的主瓣;(3) 每 $M$ 個輸出樣本保留一個(也就是跳距)。因此 STFT 就是一個均勻的濾波器組,由 $N$ 個帶通通道組成,每個通道的頻寬約為 $\approx c\,f_s/L$,彼此間隔 $f_s/N$,並且降取樣 $M$ 倍。つまり STFT の各周波数行は次の三段で作られる。(1) ヘテロダイン——$e^{-j\omega_k n}$ を掛けて $\omega_k$ 付近の帯域を直流へ移す。(2) $\tilde w[n]$ による低域通過濾波。その帯域幅は窓の主ローブで決まる。(3) 出力標本を $M$ 個ごとに一つ残す(これがホップである)。したがって STFT は、帯域幅がそれぞれ $\approx c\,f_s/L$、間隔が $f_s/N$、$M$ で間引かれた $N$ 本の帯域通過チャネルからなる一様フィルタバンクにほかならない。
This view explains the vocabulary of Section 9.4.3: a long window is a narrow lowpass filter — hence "narrowband" spectrogram — and a short window is a wide one. It also connects the STFT to Chapter 8: a DFT of one windowed frame is just this filterbank evaluated at a single time instant.這個觀點解釋了 9.4.3 節的術語:長窗就是一個窄的低通濾波器——所以才叫「窄帶」頻譜圖——而短窗則是寬的那一種。它也把 STFT 接回了第 8 章:對單一個加窗音框做 DFT,不過就是把這組濾波器組在某一個時刻上求值而已。この見方は 9.4.3 節の用語を説明してくれる。長い窓とは狭い低域通過フィルタであり、だからこそ「狭帯域」スペクトログラムと呼ばれる。短い窓は広い低域通過フィルタである。さらにこの見方は STFT を第 8 章へつなぐ。窓をかけた一つのフレームの DFT とは、このフィルタバンクをある一時刻で評価したものにほかならない。
The opening line of this section did the rearrangement in a single move. It is worth doing slowly, and starting from the frame form of §9.2.2 — the one §9.5.1 writes out term by term — because the whole of it is one change of variable, after which the convolution is simply there to be read off. The $N$ below is that section's DFT length, which is also the number of channels in the bank; $n_0$ is the sample the frame starts at, and the row being computed is the one at bin $k$.本節開頭那一行,是一口氣把定義重新整理完的。值得放慢來做一次,而且從 §9.2.2 的音框形式出發——也就是 §9.5.1 逐項寫出來的那一個——因為整件事只是一次換變數,換完之後,卷積的形式就擺在那裡等人認出來。下面的 $N$ 就是那一節的 DFT 長度,也就是濾波器組的通道數;$n_0$ 是這一段音框的起點,而正在計算的那一列是第 $k$ 個 bin 的那一列。本節の冒頭の一行は、定義を一息で並べ替えたものである。これを §9.2.2 のフレーム形式から——§9.5.1 が項ごとに書き出したあの形から——ゆっくりやり直す価値がある。全体がただ一度の変数変換であり、それが済めば畳み込みの形はそこに読み取られるのを待っているだけだからである。以下の $N$ はその節の DFT 長であり、フィルタバンクのチャネル数でもある。$n_0$ はこのフレームが始まる標本であり、いま計算している行は第 $k$ ビンの行である。
Step 1 — the sum as it stands. Fix the frequency index $k$, and the only variable left is the time $n_0$:第 1 步——原本的式子。把頻率索引 $k$ 固定住,剩下的變數就只有時間 $n_0$:第 1 歩——もとの式。周波数の索引 $k$ を固定すれば、残る変数は時間 $n_0$ だけである。
Step 2 — put $m = -n$. Replace every $n$ in that sum by $-m$: factor by factor, and the limits with them.第 2 步——令 $m = -n$。把式子裡每一個 $n$ 都換成 $-m$:一項一項換,上下限也一起換。第 2 歩——$m = -n$ と置く。その和の中のすべての $n$ を $-m$ に置き換える。因子ごとに、そして上下限もともに置き換える。
| As it stands原本もとの形 | After $n = -m$代入 $n = -m$ 後$n = -m$ を代入した後 |
|---|---|
| $x[n_0 + n]$ | $x[n_0 - m]$ |
| $w[n]$ | $w[-m]$ |
| $e^{-j\frac{2\pi kn}{N}}$ | $e^{-j\frac{2\pi k(-m)}{N}} = e^{+j\frac{2\pi km}{N}}$ (two minus signs make a plus)(負負得正)(負と負で正になる) |
| lower limit $n = 0$下限 $n = 0$下限 $n = 0$ | $m = 0$ |
| upper limit $n = N-1$上限 $n = N-1$上限 $n = N-1$ | $m = -(N-1)$ |
So the sum becomes於是式子變成したがって式は次のようになる。
Two small things about that sum, both entitled to look alarming the first time. Running $m$ "from $0$ to $-(N-1)$" is the same list of terms as $\sum_{m=-(N-1)}^{0}$, written backwards; addition does not care in what order it is handed them. And $m$, exactly like $n$, is a dummy index — whichever letter it is given never reaches the answer.關於那個和式有兩件小事,第一次看到時都有權嚇人一跳。$m$「從 $0$ 跑到 $-(N-1)$」,跟 $\sum_{m=-(N-1)}^{0}$ 是同一串項,只是倒著寫;加法不在乎別人用什麼順序把項交給它。而 $m$ 和 $n$ 一樣,只是一個虛擬指標——給它取什麼名字,都傳不到答案裡去。この和については、最初は面食らってよい小さな点が二つある。$m$ が「$0$ から $-(N-1)$ まで」走るのは、$\sum_{m=-(N-1)}^{0}$ と同じ項の並びを逆向きに書いただけである。加法はどの順序で項を渡されるかを気にしない。また $m$ は $n$ と同じくダミーの添字であり、どの文字を当てても答えには届かない。
Step 3 — recognise the convolution. The discrete convolution is defined as第 3 步——認出卷積。離散卷積的定義是第 3 歩——畳み込みを見分ける。離散畳み込みの定義は次のものである。
Give the braced factor a name, $h_k[m] = w[-m]\,e^{\,j2\pi km/N}$, and step 2 reads $\sum_m h_k[m]\,x[n_0-m]$ — that definition exactly, but for the limits. The limits cost nothing. $w[-m]$ is zero unless $0 \le -m \le N-1$, so $h_k[m]$ vanishes everywhere outside $-(N-1) \le m \le 0$, and letting $m$ run over every integer adds only terms that were already zero. Hence給大括號底下那一團取個名字,$h_k[m] = w[-m]\,e^{\,j2\pi km/N}$,第 2 步就讀成 $\sum_m h_k[m]\,x[n_0-m]$——除了上下限之外,正是那個定義。而上下限不花任何代價:除非 $0 \le -m \le N-1$,否則 $w[-m]$ 是 $0$,所以 $h_k[m]$ 在 $-(N-1) \le m \le 0$ 以外全部為零,把 $m$ 放到所有整數上去跑,加進來的都是本來就是零的項。於是波括弧でくくった因子に名前を付けよう。$h_k[m] = w[-m]\,e^{\,j2\pi km/N}$ とすれば、第 2 歩は $\sum_m h_k[m]\,x[n_0-m]$ と読める。上下限を除けば定義そのものである。その上下限は何の代償も伴わない。$0 \le -m \le N-1$ でないかぎり $w[-m]$ は $0$ なので、$h_k[m]$ は $-(N-1) \le m \le 0$ の外ではすべて消える。$m$ をすべての整数にわたらせても、もともと零であった項が加わるだけである。したがって
and nothing in that line was borrowed from a block diagram: it came out of §9.2.2's own sum, by one change of variable. The paragraphs below reach the same $h_k$ along a different road — by carrying the heterodyne of Fig. 9-6 past the filter instead of ahead of it — and it is there, in the box that follows, that the frequency response $|H_k(e^{j\omega})| = |W(e^{j(\omega-\omega_k)})|$ gets added to it.這一行裡沒有任何東西是從方塊圖借來的:它就是從 §9.2.2 自己那個和式,經過一次換變數得到的。下面幾段會沿另一條路走到同一個 $h_k$——把圖 9-6 的混頻從濾波器前面搬到後面——而頻率響應 $|H_k(e^{j\omega})| = |W(e^{j(\omega-\omega_k)})|$ 是在後面那個方框裡才補上去的。この一行には、ブロック図から借りてきたものは何もない。§9.2.2 自身の和から、一度の変数変換で出てきただけである。以下の段落は別の道をたどって同じ $h_k$ に着く。図 9-6 のヘテロダインをフィルタの前ではなく後ろへ運ぶ道である。周波数応答 $|H_k(e^{j\omega})| = |W(e^{j(\omega-\omega_k)})|$ が加わるのは、そのあとに来る枠においてである。
$N = 3$, written out. Three terms are few enough to put both forms side by side. The sum of step 1 is用 $N = 3$ 攤開來看。三項夠少,可以把兩個式子並排寫出來。第 1 步的和是$N = 3$ で書き下す。三項なら少ないので、両方の式を並べて書ける。第 1 歩の和は次のものである。
and the convolution runs over $m = 0, -1, -2$, which are the only three places $h_k$ is not zero:而卷積式跑的是 $m = 0, -1, -2$,也就是 $h_k$ 唯三不為零的位置:一方、畳み込みは $m = 0, -1, -2$ を走る。$h_k$ が零でないのはこの三箇所だけである。
| $m$ | $h_k[m] = w[-m]\,e^{\,j2\pi km/3}$ | $x[n_0 - m]$ | product乘積積 |
|---|---|---|---|
| $0$ | $w[0]$ | $x[n_0]$ | $x[n_0]\,w[0]$ |
| $-1$ | $w[1]\,e^{-j\frac{2\pi k}{3}}$ | $x[n_0+1]$ | $x[n_0+1]\,w[1]\,e^{-j\frac{2\pi k}{3}}$ |
| $-2$ | $w[2]\,e^{-j\frac{4\pi k}{3}}$ | $x[n_0+2]$ | $x[n_0+2]\,w[2]\,e^{-j\frac{4\pi k}{3}}$ |
The three products are the three terms above, in the same order. The sign that looked as though it had been flipped in step 2 has flipped back: $h_k$ does carry $e^{+j2\pi km/N}$, but it is only ever evaluated at negative $m$, and the two minus signs cancel.這三個乘積,就是上面那三項,連順序都一樣。第 2 步裡那個看起來被翻掉的符號,現在翻了回來:$h_k$ 身上帶的確實是 $e^{+j2\pi km/N}$,但它求值的位置永遠是負的 $m$,兩個負號互相抵消。この三つの積は、上の三項とそのまま、順序まで同じである。第 2 歩で裏返ったように見えた符号は、ここで裏返り直している。$h_k$ が持つのは確かに $e^{+j2\pi km/N}$ だが、評価される $m$ はつねに負であり、二つの負号が打ち消し合うからである。
Checked outside the page as well: for every $N$ from $3$ to $32$, every $k$, several starting points $n_0$ and all three windows this chapter uses, the two sums agree to about $5\times10^{-15}$ of their own size — and sweeping $m$ over a range far wider than $-(N-1) \le m \le 0$ changes the answer by nothing at all, which is the support claim measured rather than asserted.頁面之外也查過:對從 $3$ 到 $32$ 的每一個 $N$、每一個 $k$、若干個起點 $n_0$,以及本章用到的三種視窗,兩個和式相符到自身大小的 $5\times10^{-15}$ 左右——而且把 $m$ 掃過一個比 $-(N-1) \le m \le 0$ 寬得多的範圍,答案一點也沒有變,這就是把那個支撐區間的說法量出來,而不是只是宣稱。ページの外でも確かめてある。$3$ から $32$ までのすべての $N$、すべての $k$、いくつかの起点 $n_0$、および本章で用いる三種類の窓関数について、二つの和は自身の大きさのおよそ $5\times10^{-15}$ まで一致する。さらに $m$ を $-(N-1) \le m \le 0$ よりはるかに広い範囲で走らせても答えはまったく変わらない。台についての主張を、言い張るのではなく測ったものである。
Why rewrite it at all. The two forms give the same numbers; what differs is what they invite one to say. Step 1 reads take a stretch, window it, take a DFT, and it makes the STFT something that happens to a frame. Step 3 reads send the signal through the filter $h_k$, and it makes the STFT something that happens to a signal, continuously, with the hop left to decide only which outputs are kept. That second sentence is what lets everything already known about filters — passbands, mainlobes, stopbands, aliasing on decimation — be spent on the STFT without being derived again. Set side by side, the two readings are §9.5.1's table, which carries the contrast row by row, including what the window is doing in each.為什麼要這樣改寫。兩個形式算出來是同一批數字;不同的是它們邀請你說出什麼樣的話。第 1 步讀起來是取一段、加窗、做 DFT,它把 STFT 變成發生在一個音框身上的事。第 3 步讀起來是讓訊號通過濾波器 $h_k$,它把 STFT 變成發生在一段訊號身上、而且連續發生的事,跳距只剩下決定哪些輸出被留下來這一件任務。有了後面這句話,所有已經知道的關於濾波器的事——通帶、主瓣、止帶、降取樣時的混疊——都可以直接花在 STFT 上,不必重新推導一遍。把兩種讀法並排對照,就是 §9.5.1 的那張表,它一列一列地寫著兩者的差別,也包括視窗在各自的讀法裡在做什麼。なぜ書き換えるのか。二つの形が与える数値は同一である。違うのは、それぞれが何を言わせてくれるかである。第 1 歩は区間を取り、窓をかけ、DFT を取ると読め、STFT を一つのフレームに起こる出来事にする。第 3 歩は信号をフィルタ $h_k$ に通すと読め、STFT を信号に連続して起こる出来事にする。ホップに残る仕事は、どの出力を残すかを決めることだけになる。この後者の一文があるからこそ、フィルタについてすでに知っていること——通過帯域、主ローブ、阻止帯域、間引きのときの折り返し——を、導き直すことなくそのまま STFT に使える。二つの読み方を並べて対照させたものが §9.5.1 の表であり、そこには両者の違いが行ごとに、それぞれの読み方で窓が何をしているかも含めて書かれている。
The hop, seen from the filterbank side. The row at bin $k$ is a bandpass signal, and heterodyning it down to baseband leaves an envelope no wider than half the channel's mainlobe — one bin either side for the rectangular window, two for the Hann. Keeping one output sample in every $R$ is sampling that envelope, so $R$ may not exceed $N$ divided by the mainlobe width in bins: $R \le N/2$ rectangular, $R \le N/4$ Hann. Those are the numbers the figure's readout prints, and they are §9.4.4's 50% and 75% overlap arriving from the other direction — §9.4.4 argued from tapered frame edges and missed transients, the bank argues from aliasing, and the two land on the same hops. §9.6.2's COLA condition then picks out, among the hops that are short enough, those at which the shifted windows also add to a constant.跳距,從濾波器組這一邊看。第 $k$ 個 bin 的那一列是一個帶通訊號,把它混頻回基頻之後,剩下的包絡不會比該通道主瓣的一半更寬——矩形窗左右各一個 bin,Hann 窗各兩個。每 $R$ 點保留一個輸出樣本,就是在對這個包絡取樣,所以 $R$ 不能超過 $N$ 除以主瓣寬度(以 bin 計):矩形窗 $R \le N/2$,Hann 窗 $R \le N/4$。這正是互動圖讀數裡印出來的數字,也正是 §9.4.4 的 50% 與 75% 重疊,只是從另一個方向走過來的——§9.4.4 的理由是錐形窗的音框邊緣與被漏掉的暫態,濾波器組的理由是混疊,兩者落在同一組跳距上。至於 §9.6.2 的 COLA 條件,則是在這些夠短的跳距裡,再挑出那些讓平移後的視窗也剛好相加為常數的。ホップを、フィルタバンクの側から見る。第 $k$ ビンの行は帯域通過信号であり、それを基底帯域へヘテロダインすると、残る包絡はそのチャネルの主ローブの半分より広くならない。矩形窓なら左右に一ビンずつ、Hann 窓なら二ビンずつである。$R$ 標本ごとに出力を一つ残すことは、この包絡を標本化することであるから、$R$ は $N$ を主ローブ幅(ビン単位)で割った値を超えられない。矩形窓では $R \le N/2$、Hann 窓では $R \le N/4$ である。これはインタラクティブ図の読み出しが印字している数そのものであり、§9.4.4 の 50% と 75% の重なりに別の方向から到達したものでもある。§9.4.4 はテーパ窓のフレーム端と見落とされる過渡現象を理由とし、フィルタバンクは折り返しを理由とするが、二つは同じホップに落ち着く。§9.6.2 の COLA 条件は、その十分に短いホップのうち、ずらした窓の和も定数になるものをさらに選び出す。
What else the filterbank reading buys, and where this chapter already spends it. Three further consequences usually travel with this rewriting, and all three are already somewhere else in the chapter rather than here. That a channel's selectivity is the window's selectivity — wide mainlobe, neighbouring frequencies unresolved; high sidelobes, neighbouring bands leaking in — is the paragraph under the channel filter below, where §9.3.4's blurring and ghosting change into passband width and stopband rejection. That the undecimated bank adds back up to its input, $\sum_k H_k(e^{j\omega})$ being constant at $N\,w[0]$ — filterbank summation, one of the proofs that the STFT is invertible — is the last of the figure's bullets, and it is measured in the callout under them, where the Hann window's near-zero $w[0]$ turns out to be a trap worth knowing about. And that the STFT's channels are all one width, where a wavelet basis spends its octaves on channels that widen with frequency, is §9.3.3's tiling picture said in filterbank words; that comparison is not worked out in this chapter in either language.濾波器組這個讀法還買到了什麼,以及本章把它花在哪裡。跟著這個改寫一起來的,通常還有三個結論,而這三個在本章裡都已經有別的地方了,不在這裡。一個通道的選擇性就是視窗的選擇性——主瓣寬,鄰近頻率分不開;旁瓣高,鄰近頻帶漏得進來——那是下面通道濾波器底下那一段,§9.3.4 的 blurring 與 ghosting 在那裡換成了通帶寬度與止帶抑制。沒有降取樣的濾波器組會把輸入原樣加回來,$\sum_k H_k(e^{j\omega})$ 是常數 $N\,w[0]$——也就是 filterbank summation,證明 STFT 可逆的做法之一——那是互動圖最後一個項目,而且在那些項目底下的合理性驗証裡量過,順帶量出 Hann 窗那個幾乎為零的 $w[0]$ 是個值得知道的陷阱。至於 STFT 的通道寬度全部一樣,而小波基底把它的倍頻程花在越高頻越寬的通道上,那是 §9.3.3 的鋪磚圖用濾波器組的話再說一次;那個比較本章用哪一種話都沒有展開。フィルタバンクという読み方が他に何を買い、本章はそれをどこで使っているか。この書き換えには通常さらに三つの帰結が伴うが、三つとも本章の別の場所に既にあり、ここにはない。一本のチャネルの選択度が窓の選択度そのものであること——主ローブが広ければ隣り合う周波数は分離できず、サイドローブが高ければ隣の帯域から漏れ込む——は、下のチャネルフィルタの下の段落である。そこで §9.3.4 の blurring と ghosting は、通過帯域の幅と阻止帯域の減衰に言い換わっている。間引く前のフィルタバンクが入力をそのまま足し戻すこと、すなわち $\sum_k H_k(e^{j\omega})$ が定数 $N\,w[0]$ であること——フィルタバンク総和であり、STFT が可逆であることの一つの証明である——は図の最後の項目であり、その下の妥当性の検証で測ってある。そこでは Hann 窓の $w[0]$ がほとんど零であることが、知っておく価値のある罠でもあると分かる。そして STFT のチャネルの幅がすべて等しいこと、対してウェーブレット基底はオクターブを、周波数が高いほど広がるチャネルに費やすことは、§9.3.3 のタイル分割の絵をフィルタバンクの言葉で言い直したものである。その比較は、どちらの言葉でも本章では展開しない。
Fig. 9-6 draws the bank one channel to a row, and leaves each channel as a box marked $\tilde w[n]$. The figure below opens one of those boxes. It plots a single channel twice over — its impulse response in time, and its frequency response among all the others — with $k$ and $N$ under the reader's hand, so that every channel is the same filter moved to a different centre frequency becomes something to step through rather than something to take on trust.圖 9-6 把濾波器組畫成一列一個通道,而每個通道本身只是一個標著 $\tilde w[n]$ 的方塊。下面這張圖把其中一個方塊打開。它把同一個通道畫兩次——時域的脈衝響應,以及它擺在其他所有通道之間的頻率響應——而且 $k$ 與 $N$ 都在讀者手上,於是每個通道都是同一個濾波器、只是搬到不同的中心頻率這句話,就從一句要相信的話,變成一件可以一格一格走過去的事。図 9-6 はフィルタバンクを一行に一チャネルずつ描き、チャネル自身は $\tilde w[n]$ と書かれた箱のままにしてある。下の図はその箱の一つを開けたものである。同じ一本のチャネルを二度描く。時間領域のインパルス応答と、他のすべてと並べた周波数応答である。$k$ と $N$ は読者の手にあるので、どのチャネルも同じフィルタを別の中心周波数へ移しただけであるという一文が、信じるべき主張ではなく、一つずつたどれるものになる。
Carrying the heterodyne past the filter instead of ahead of it collapses the first two stages of that diagram into one bandpass filter, and it is that filter the figure draws:把混頻搬到濾波器後面、而不是擺在前面,就能把那張方塊圖的前兩段併成一個帶通濾波器,而下圖畫的正是這個濾波器:ヘテロダインをフィルタの前ではなく後ろへ移すと、あの図の最初の二段は一つの帯域通過フィルタにまとまる。下の図が描くのはそのフィルタである。
The right-hand equality is §9.3.4's $|W|$ read the other way round. There a pure tone at $\omega_0$ painted the window's own spectrum onto the analysis; here a fixed channel carries that same spectrum around as its own passband. The two defects §9.3.4 named change their names accordingly: blurring is the width of this channel's mainlobe, and ghosting is what leaks in through its sidelobes from the channels either side.右邊那個等式,就是 §9.3.4 的 $|W|$ 反過來讀。在那裡,位於 $\omega_0$ 的純正弦波把視窗自己的頻譜畫到分析結果上;在這裡,一個固定的通道把同一個頻譜當成自己的通帶帶著走。§9.3.4 替兩個缺陷取的名字,也跟著換了說法:blurring 就是這個通道主瓣的寬度,ghosting 就是從旁瓣漏進來的、來自左右鄰居的東西。右側の等式は、§9.3.4 の $|W|$ を逆向きに読んだものである。あちらでは $\omega_0$ にある純正弦波が窓自身のスペクトルを分析結果の上に描いた。こちらでは、固定した一本のチャネルが同じスペクトルを自分の通過帯域として持ち歩く。§9.3.4 が二つの欠陥に付けた名前も、それに応じて言い換わる。blurring はこのチャネルの主ローブの幅であり、ghosting は左右のチャネルからサイドローブを通って漏れ込むものである。
What to look at, in order:建議依序這樣看:順に見ていくとよい点は次のとおりである。
Every number below was recomputed from the definitions, outside the figure, over every $k$ and every even $N$ from $8$ to $32$ in both windows. The first row is the one that matters: the frequency responses the figure plots are the transforms of the stems it plots above them, and they land on $|W|$ shifted to $\omega_k$ to within floating-point noise.下面每一個數字都是在圖之外、直接從定義重算出來的,涵蓋兩種視窗下從 $8$ 到 $32$ 的每一個偶數 $N$ 與每一個 $k$。第一列是關鍵:圖上畫的那些頻率響應,就是它上面那些桿子的轉換,而它們落在平移到 $\omega_k$ 的 $|W|$ 上,誤差只到浮點數的雜訊等級。以下の数値はすべて、図の外で定義から計算し直したものであり、両方の窓について $8$ から $32$ までのすべての偶数 $N$ とすべての $k$ を対象としている。重要なのは第一行である。図が描く周波数応答はその上に描かれた棒の変換そのものであり、$\omega_k$ へ平行移動した $|W|$ の上に、浮動小数点の雑音の範囲で乗る。
| Measured量到的量測った量 | Result結果結果 |
|---|---|
| worst gap between $|H_k(e^{j\omega})|$ taken from $h_k$ and $|W(e^{j(\omega-\omega_k)})|$, relative to the peak gain, over $401$ frequencies由 $h_k$ 算出的 $|H_k(e^{j\omega})|$ 與 $|W(e^{j(\omega-\omega_k)})|$ 的最大差距(除以峰值增益,掃 $401$ 個頻率)$h_k$ から求めた $|H_k(e^{j\omega})|$ と $|W(e^{j(\omega-\omega_k)})|$ との最大の差(ピーク利得で割り、$401$ 点の周波数で走査) | $5.5\times10^{-15}$ |
| mainlobe, null to null, in every channel主瓣寬度(零點到零點),每一個通道主ローブ幅(零点から零点)、どのチャネルでも | $2.000$ bins (rectangular), $4.000$ bins (Hann)$2.000$ 個 bin(矩形),$4.000$ 個 bin(Hann)$2.000$ ビン(矩形)、$4.000$ ビン(Hann) |
| distance from the peak of $|H_k|$ to $\omega_k$; spread of the peak gain across the $N$ channels$|H_k|$ 的峰值離 $\omega_k$ 多遠;$N$ 個通道之間峰值增益的落差$|H_k|$ のピークと $\omega_k$ との隔たり、および $N$ 本のチャネル間でのピーク利得のばらつき | $\le 2.3\times10^{-15}$ bins; $0$ exactly$\le 2.3\times10^{-15}$ 個 bin;落差恰為 $0$$\le 2.3\times10^{-15}$ ビン、ばらつきはちょうど $0$ |
| highest sidelobe at $N=32$$N=32$ 時最高的旁瓣$N=32$ における最大サイドローブ | $-13.23$ dB (rectangular), $-31.47$ dB (Hann)$-13.23$ dB(矩形),$-31.47$ dB(Hann)$-13.23$ dB(矩形)、$-31.47$ dB(Hann) |
| ripple of $\bigl|\sum_k H_k(e^{j\omega})\bigr|$ across $\omega$, against the predicted $N\,w[0]$$\bigl|\sum_k H_k(e^{j\omega})\bigr|$ 隨 $\omega$ 的起伏,與預測值 $N\,w[0]$ 相比$\bigl|\sum_k H_k(e^{j\omega})\bigr|$ の $\omega$ 方向のリップル、予測値 $N\,w[0]$ との比較 | $\le 3.3\times10^{-11}$ dB; the level matches $N\,w[0]$ to all digits shown$\le 3.3\times10^{-11}$ dB;高度與 $N\,w[0]$ 在所有顯示位數上相符$\le 3.3\times10^{-11}$ dB、高さは表示されるすべての桁で $N\,w[0]$ と一致 |
The last row has a trap in it that is worth naming. The Hann window of this figure is the half-sample-shifted one, $w[n]=\tfrac12-\tfrac12\cos\bigl(2\pi(n+\tfrac12)/N\bigr)$, for which $w[0]$ is small but never zero — $N\,w[0]=0.154$ at $N=16$, so the flat sum sits some $34$ dB below one channel's peak and needs the dB scale to be seen properly. Use the unshifted periodic Hann instead and $w[0]=0$ exactly, so $\sum_k H_k\equiv 0$: the bank would still be a perfectly good set of bandpass filters, and adding its channels would give back nothing at all. Measured, $\max_\omega\bigl|\sum_k H_k\bigr|$ falls from $0.154$ to $4.6\times10^{-14}$ at $N=16$.最後一列裡藏著一個值得點名的陷阱。這張圖用的 Hann 窗是平移了半個樣本的那一種,$w[n]=\tfrac12-\tfrac12\cos\bigl(2\pi(n+\tfrac12)/N\bigr)$,它的 $w[0]$ 很小但絕不為零——$N=16$ 時 $N\,w[0]=0.154$,所以那條平坦的和大約落在單一通道峰值以下 $34$ dB,非得用 dB 刻度才看得清楚。換成沒有平移的週期型 Hann,$w[0]$ 就恰好是 $0$,於是 $\sum_k H_k\equiv 0$:這組濾波器依然是一組完全合格的帶通濾波器,但把各通道加起來什麼也拿不回來。實際量出來,$N=16$ 時 $\max_\omega\bigl|\sum_k H_k\bigr|$ 由 $0.154$ 掉到 $4.6\times10^{-14}$。最後の行には、名指ししておく価値のある罠がある。この図の Hann 窓は半標本ずらした形 $w[n]=\tfrac12-\tfrac12\cos\bigl(2\pi(n+\tfrac12)/N\bigr)$ であり、その $w[0]$ は小さいが決して零ではない。$N=16$ では $N\,w[0]=0.154$ であり、平坦な和は一本のチャネルのピークからおよそ $34$ dB 下に来るので、きちんと見るには dB 目盛が要る。ずらさない周期的な Hann に替えると $w[0]$ はちょうど $0$ になり、$\sum_k H_k\equiv 0$ となる。フィルタバンクとしては依然として申し分のない帯域通過フィルタの組だが、チャネルを足しても何も戻らない。実測では $N=16$ のとき $\max_\omega\bigl|\sum_k H_k\bigr|$ は $0.154$ から $4.6\times10^{-14}$ へ落ちる。
Panel ① above draws $h_k[n]$ twice over, in red and in blue, because the page has one height axis to spend and the taps of the filter are complex. Give the complex value a plane of its own — real part up, imaginary part across — and the two stem plots become one object: a helix wound along the $n$ axis, whose radius at each $n$ is $w[-n]$ and whose phase turns by $\omega_k$ from one sample to the next. The figure below draws that, and it is the same $h_k[n]=w[-n]e^{\,j\omega_k n}$ as before, with nothing added to it and nothing taken out.上面的面板 ① 把 $h_k[n]$ 畫了兩次,一紅一藍,因為紙面只有一根高度軸可用,而濾波器的係數是複數。給複數值自己一個平面——實部向上、虛部橫向——那兩張桿圖就合成同一個東西:一條沿著 $n$ 軸繞行的螺旋線,它在每個 $n$ 處的半徑就是 $w[-n]$,相位則每過一個樣本轉 $\omega_k$。下圖畫的就是這個,而它正是剛才那個 $h_k[n]=w[-n]e^{\,j\omega_k n}$,既沒有多添什麼,也沒有少掉什麼。上のパネル ① は $h_k[n]$ を赤と青の二度に分けて描いている。紙面の高さ軸は一本しかなく、フィルタの係数は複素数だからである。複素数の値に専用の平面を与え——実部を上へ、虚部を横へ——れば、二枚の棒グラフは一つの対象になる。$n$ 軸に沿って巻く螺旋であり、各 $n$ における半径はちょうど $w[-n]$、位相は標本一つごとに $\omega_k$ ずつ回る。下の図が描くのはこれであり、先ほどと同じ $h_k[n]=w[-n]e^{\,j\omega_k n}$ にほかならない。何も加えておらず、何も落としていない。
The justification for drawing it a second time is a narrow one, and worth stating. Panel ① is the better place to read a value off: a stem has a height, and heights can be compared. What it cannot show is that the red sequence and the blue sequence are one motion, because it has had to cut that motion into two plots at right angles to one another. Here the motion is the picture, and the sentence a complex sinusoid inside a window envelope has a single shape to point at. Everything else the two renderings say is the same, so the envelope that stays put while the oscillation speeds up, the real-only channel $0$, and the support lying entirely at $n\le 0$ are left to the bullets above rather than said twice.再畫一次的理由很窄,但值得說清楚。要讀出一個數值,面板 ① 比較好用:桿子有高度,而高度可以互相比較。它做不到的,是讓人看出紅色那一串與藍色那一串其實是同一個運動,因為它必須把這個運動切成互相垂直的兩張圖。在這裡,運動本身就是整張圖,一個複數正弦波被裝在視窗包絡裡這句話,有一個單一的形狀可以指。其餘兩種畫法講的是同一件事,所以包絡不動而振盪越轉越快、第 $0$ 個通道只有實部、支撐整個落在 $n\le 0$ 這幾點,都留給上面那幾條項目,不在這裡說第二遍。二度目を描く理由は狭いが、述べておく価値がある。値を読み取るにはパネル ① のほうがよい。棒には高さがあり、高さは互いに比べられる。パネル ① にできないのは、赤の列と青の列が一つの運動であると見せることである。その運動を、互いに直交する二枚の図へ切り分けざるをえなかったからである。ここでは運動そのものが図であり、窓関数の包絡の中に入った複素正弦波という一文に、指させる一つの形がある。それ以外に二つの描き方が言うことは同じなので、振動が速くなっても包絡が動かないこと、第 $0$ チャネルが実数だけであること、台がすべて $n\le 0$ にあることは、上の項目に任せ、ここで二度言うことはしない。
What the third dimension adds, and what it only repeats:第三個維度多給了什麼,又有哪些只是重複:三つ目の次元が何を足し、何を繰り返すにすぎないか。
Measured, not asserted. The readout under the figure recomputes, on every move, three of the things the picture claims: the largest gap between $|h_k[n]|$ and $w[-n]$ over the $N$ taps, the largest departure of the phase step from one tap to the next from $\omega_k$, and the turning number of the curve as actually drawn, got by adding up the angle it sweeps from one of its own points to the next. Checked outside the page as well, over every even $N$ from $8$ to $64$, every $k$ from $0$ to $N-1$ and both windows: the radius agrees with $w[-n]$ to $3.3\times10^{-16}$, the phase step with $\omega_k$ to $9.1\times10^{-14}$ radians, the turning counted along the drawn curve between the first tap and the last agrees with $k(N-1)/N$ to $1.3\times10^{-12}$ turns — that is $k$ turns to the window's $N$ samples — the beads on their own turn $k-N$ times whenever $k$ is above $N/2$, $h_0$ has imaginary part exactly $0$ at every tap, and $h_{N-k}$ equals the conjugate of $h_k$ to $6.1\times10^{-14}$.量出來的,不是宣稱的。圖下的讀數每動一次就重算三件這張圖所主張的事:$|h_k[n]|$ 與 $w[-n]$ 在 $N$ 個係數上的最大差距、相鄰兩個係數之間的相位步進與 $\omega_k$ 的最大差距,以及曲線實際畫出來的繞圈數——把它從自己的一個點掃到下一個點的角度加總得到。頁面之外也查過,涵蓋從 $8$ 到 $64$ 的每一個偶數 $N$、從 $0$ 到 $N-1$ 的每一個 $k$,以及兩種視窗:半徑與 $w[-n]$ 相符到 $3.3\times10^{-16}$,相位步進與 $\omega_k$ 相符到 $9.1\times10^{-14}$ 弧度,沿著所畫曲線從第一個係數數到最後一個係數的圈數,與 $k(N-1)/N$ 相符到 $1.3\times10^{-12}$ 圈——換算成視窗的 $N$ 個樣本就是 $k$ 圈——只要 $k$ 在 $N/2$ 之上,單看珠子繞的圈數就是 $k-N$,$h_0$ 在每一個係數上的虛部恰為 $0$,而 $h_{N-k}$ 與 $h_k$ 的共軛相符到 $6.1\times10^{-14}$。言い張るのではなく、測る。図の下の読み出しは、操作のたびにこの図の主張のうち三つを計算し直す。$N$ 個の係数にわたる $|h_k[n]|$ と $w[-n]$ との最大の差、隣り合う係数のあいだの位相の進みと $\omega_k$ との最大の差、そして実際に描かれた曲線の回転数——曲線が自身のある点から次の点まで掃く角度を足し合わせて得たものである。ページの外でも確かめてある。$8$ から $64$ までのすべての偶数 $N$、$0$ から $N-1$ までのすべての $k$、および両方の窓関数について、半径は $w[-n]$ と $3.3\times10^{-16}$ まで、位相の進みは $\omega_k$ と $9.1\times10^{-14}$ ラジアンまで一致する。描かれた曲線に沿って最初の係数から最後の係数まで数えた回転数は $k(N-1)/N$ と $1.3\times10^{-12}$ 回転まで一致し——窓の $N$ 標本に換算すれば $k$ 回転である——$k$ が $N/2$ より上にあるかぎり、珠だけの回転数は $k-N$ になる。$h_0$ の虚部はどの係数でもちょうど $0$ であり、$h_{N-k}$ は $h_k$ の共役と $6.1\times10^{-14}$ まで一致する。
What each term of the STFT formula means has already been said, in §9.2.1 and §9.2.2. What follows adds two deeper readings of that same formula, and then draws "the magnitude is a function of time and of frequency" directly, as a 3-D surface.STFT 公式裡每一項的意義,§9.2.1 與 §9.2.2 已經介紹過。這裡補充兩個更深入的看法,並用 3D 圖把「強度是時間和頻率的函數」直接畫出來。STFT の式の各項が何を意味するかは、§9.2.1 と §9.2.2 ですでに述べた。ここではその同じ式について、より踏み込んだ読み方を二つ補い、さらに「強度は時間と周波数の関数である」ことを 3 次元の曲面として直接描いてみる。
The slide writes the transform as $X[k,n_0]$, with $N_{FT}$ for the DFT length and $n_0$ for the sample the frame starts at. Those are §9.2.2's letters renamed and nothing else: $N_{FT}$ is that section's $N$, $n_0$ is its $mM$, and the hop written $R$ here is its $M$ — the same $R$ that §9.1.3 already uses for the hop.投影片把這個轉換寫成 $X[k,n_0]$,其中 $N_{FT}$ 是 DFT 長度,$n_0$ 是這一段音框的起始樣本。這只是把 §9.2.2 的符號換個名字而已:$N_{FT}$ 就是該節的 $N$,$n_0$ 就是該節的 $mM$,而這裡寫成 $R$ 的跳距就是該節的 $M$——也就是 §9.1.3 已經拿來表示跳距的那個 $R$。スライドはこの変換を $X[k,n_0]$ と書き、$N_{FT}$ を DFT 長、$n_0$ をフレームの開始標本とする。これは §9.2.2 の記号を言い換えただけである。$N_{FT}$ は同節の $N$、$n_0$ は同節の $mM$ であり、ここで $R$ と書くホップは同節の $M$、すなわち §9.1.3 がすでにホップに使っている $R$ そのものである。
| Term項項 | What it is是什麼何であるか |
|---|---|
| $(1)\;x[n_0+n]$ | the $N_{FT}$ samples taken from $n_0$ onwards從 $n_0$ 起取 $N_{FT}$ 點$n_0$ から取った $N_{FT}$ 点 |
| $(2)\;w[n]$ | the window窗窓 |
| $(3)\;e^{-j2\pi kn/N_{FT}}$ | the DFT kernelDFT 核心DFT の核 |
The STFT is a two-dimensional array, and it can be cut along either direction:STFT 是一個二維的陣列,可以沿兩個方向切:STFT は二次元の配列であり、二つの方向のどちらにも切ることができる。
| Cut切法切り方 | Fix $n_0$ (a vertical cut)固定 $n_0$(縱切)$n_0$ を固定(縦に切る) | Fix $k$ (a horizontal cut)固定 $k$(橫切)$k$ を固定(横に切る) |
|---|---|---|
| What you get得到什麼何が得られるか | the spectrum of one stretch of time一段時間的頻譜ある時間区間のスペクトル | one frequency band's output as time goes by一個頻帶的輸出隨時間的變化ある周波数帯の出力が時間とともに変わるようす |
| How it is computed怎麼算どう計算するか | take a stretch of data, window it, take the DFT取一段資料、加窗、做 DFT区間を切り出し、窓をかけ、DFT を取る | heterodyne, lowpass filter, keep one sample every $R$混頻、低通濾波、每 $R$ 點取一個樣本ヘテロダイン、低域通過濾波、$R$ 点ごとに一標本を残す |
| What the window is doing視窗在做什麼窓が何をしているか | cutting out the stretch of time截出那一段時間その時間区間を切り出す | setting the shape of the filter's frequency response決定濾波器頻率響應的形狀フィルタの周波数応答の形を決める |
| On the spectrogram在頻譜圖上スペクトログラム上では | one column一欄一列 | one row一列一行 |
| Where it is developed本書何處講過本書のどこで扱ったか | §9.2.2 and §9.4.1§9.2.2 與 §9.4.1§9.2.2 と §9.4.1 | §9.5, in full, above本節(§9.5)上方,完整推導本節(§9.5)の上方に完全な導出がある |
| In the figure below在下圖中下の図では | the orange line橘線オレンジの線 | the green line綠線緑の線 |
Fix $n_0$ (a vertical cut): the spectrum of one stretch of time. This is the way it has been done so far: take a stretch of data, window it, take the DFT. Every column of the spectrogram is one such spectrum.固定 $n_0$(縱切):一段時間的頻譜。這就是前面的做法:取一段資料、加窗、做 DFT。頻譜圖中的每一欄就是一個這樣的頻譜。$n_0$ を固定する(縦に切る):ある時間区間のスペクトル。これはこれまでやってきたとおりである。区間を切り出し、窓をかけ、DFT を取る。スペクトログラムの各列が、そうしたスペクトルの一つである。
Fix $k$ (a horizontal cut): one band's output as time goes by. Rewriting the formula as a convolution shows that, for a fixed $k$, $X[k,n_0]$ is what comes out of a bandpass filter centred on $\omega_k$, sampled once every $R$ points. The filter's frequency response is the window spectrum $W$ moved to $\omega_k$. So the STFT can equally be seen as a filterbank built from $N_{FT}$ equal-bandwidth bandpass filters, and every row of the spectrogram is one filter's output envelope.固定 $k$(橫切):一個頻帶的輸出隨時間的變化。把公式改寫成卷積的形式可以看出,對固定的 $k$,$X[k,n_0]$ 就是訊號通過一個中心在 $\omega_k$ 的帶通濾波器後,每隔 $R$ 點取一個樣本的結果。濾波器的頻率響應就是窗頻譜 $W$ 平移到 $\omega_k$。所以 STFT 也可以看成一個由 $N_{FT}$ 個等頻寬帶通濾波器組成的濾波器組,頻譜圖中的每一列就是一個濾波器的輸出包絡。$k$ を固定する(横に切る):ある帯域の出力が時間とともに変わるようす。式を畳み込みの形に書き直せば、$k$ を固定したときの $X[k,n_0]$ とは、信号を$\omega_k$ を中心とする帯域通過フィルタに通し、$R$ 点ごとに一標本を取り出した結果にほかならないと分かる。フィルタの周波数応答は、窓のスペクトル $W$ を $\omega_k$ へ平行移動したものである。したがって STFT は、$N_{FT}$ 本の等帯域幅の帯域通過フィルタからなるフィルタバンクと見ることもでき、スペクトログラムの各行が一つのフィルタの出力包絡である。
That rewriting is the whole subject of §9.5 above — the heterodyne by $e^{-j\omega_k n}$, the lowpass filter $\tilde w[n]$ and the decimation by the hop are worked out there, and Fig. 9-6 draws the bank channel by channel — so none of it is repeated here. The only thing added in this subsection is that the two cuts are cuts of one object.這個改寫正是上方 §9.5 的全部主題——以 $e^{-j\omega_k n}$ 混頻、用 $\tilde w[n]$ 低通、再依跳距降取樣,都已經在那裡推導完畢,圖 9-6 也把整組通道畫了出來——所以這裡一個字都不重複。本小節唯一新增的,是把兩道切口看成同一個東西的切口。この書き直しこそ上方の §9.5 の主題そのものである。$e^{-j\omega_k n}$ によるヘテロダイン、$\tilde w[n]$ による低域通過、ホップによる間引きはいずれもそこで導出済みであり、図 9-6 がチャネルごとにフィルタバンクを描いている。したがってここでは何一つ繰り返さない。本小節が付け加えるのは、二つの切り口が一つの対象の切り口である、という一点だけである。
For an AM sinusoid, the row at $k=k_0$ — the bin the carrier sits in — is precisely the envelope $A[n]$. That is exactly the quantity panel ④ of §9.1.3's interactive figure already measures: the per-frame peak height near the carrier, laid against the true $A[n]$. Panel ④ draws it as a curve on a flat plot; below it is the green cut across a surface, and the numbers are the same numbers.對 AM 正弦波而言,固定 $k = k_0$(載波所在的 bin)那一列,正好就是包絡 $A[n]$。這恰好就是 §9.1.3 互動圖的面板 ④ 已經量過的那個量:各音框在載波附近的峰高,對上真實的 $A[n]$。面板 ④ 把它畫成平面圖上的一條曲線;下面則把它畫成曲面上的綠色切口,而數字是同一批數字。AM 正弦波については、$k = k_0$(搬送波が乗っているビン)に固定した行が、まさに包絡 $A[n]$ そのものである。これは §9.1.3 のインタラクティブ図の面板 ④ がすでに測っている量にほかならない。すなわち、各フレームの搬送波付近のピーク高を真の $A[n]$ と並べたものである。面板 ④ はそれを平面上の曲線として描いたが、以下では曲面を横切る緑の切り口として描く。数値はまったく同じものである。
The figure below draws $|X[k,n_0]|$ as a surface: the two horizontal axes are time $n_0$ and frequency $k$, and the height is the magnitude. The spectrogram is the top view of this surface, with colour standing in for height. Drag to rotate, use the wheel to zoom, and move the sliders to choose where the vertical and the horizontal cut are taken.下圖把 $|X[k,n_0]|$ 畫成曲面:兩個水平軸是時間 $n_0$ 和頻率 $k$,高度是大小。頻譜圖就是這個曲面的俯視圖(以顏色代替高度)。可拖曳旋轉、滾輪縮放,用滑桿選擇縱切與橫切的位置。下の図は $|X[k,n_0]|$ を曲面として描いたものである。二つの水平軸は時間 $n_0$ と周波数 $k$ であり、高さが大きさを表す。スペクトログラムとは、この曲面を真上から見た図であって、高さの代わりに色を使ったものである。ドラッグで回転、ホイールで拡大縮小ができ、つまみで縦の切り口と横の切り口の位置を選べる。
The signal is the one from §9.1.3: a carrier at $f_0/f_s = 102/1024 = 0.0996$ under the slow envelope $A[n] = 1-\cos(2\pi n/N)$, with $N = 2048$ here instead of $1024$ so that there are enough frames to make a surface out of. The hop is $R = N_{FT}/4$ and the band drawn is $k = 0,\dots,N_{FT}/4$, that is $f/f_s$ up to $0.25$ — the same band as panel ③ there.訊號就是 §9.1.3 的那一個:載波在 $f_0/f_s = 102/1024 = 0.0996$,底下是慢變包絡 $A[n] = 1-\cos(2\pi n/N)$,只是這裡取 $N = 2048$ 而非 $1024$,好讓音框數量足夠撐成一個曲面。跳距為 $R = N_{FT}/4$,畫出的頻帶是 $k = 0,\dots,N_{FT}/4$,也就是 $f/f_s$ 到 $0.25$ 為止——與該處面板 ③ 的頻帶相同。信号は §9.1.3 のものである。搬送波は $f_0/f_s = 102/1024 = 0.0996$ にあり、その下にゆっくりした包絡 $A[n] = 1-\cos(2\pi n/N)$ が乗る。ただしここでは曲面を張れるだけのフレーム数を得るため、$N = 1024$ ではなく $N = 2048$ とした。ホップは $R = N_{FT}/4$、描かれる帯域は $k = 0,\dots,N_{FT}/4$、すなわち $f/f_s$ が $0.25$ までであり、同節の面板 ③ と同じ帯域である。
What the figure shows:圖中可以看到:図から読み取れることは次のとおりである。
Every statement above was computed from the same arithmetic the figure runs, not read off the picture. The carrier does not land on a bin exactly — it sits at $6.375$ bins when $N_{FT}=64$ and at $25.5$ bins when $N_{FT}=256$ — which is the ordinary case and the reason the rectangular window's ripples are visible at all.上面每一句話都是用圖所執行的同一套算術算出來的,不是從圖上目測的。載波並不剛好落在某個 bin 上——$N_{FT}=64$ 時它在第 $6.375$ 個 bin,$N_{FT}=256$ 時在第 $25.5$ 個——這才是一般的情形,也正是矩形窗的波紋看得見的原因。上のどの主張も、図が実行しているのと同じ算術で計算したものであり、絵から目測したものではない。搬送波はビンの上にちょうどは乗らない。$N_{FT}=64$ では $6.375$ 番目、$N_{FT}=256$ では $25.5$ 番目のビンに位置する。これが普通の場合であり、矩形窓の波紋が見えるのもそのためである。
| Measured量到的量測った量 | $N_{FT}=64$ | $N_{FT}=256$ |
|---|---|---|
| frames drawn, hop $R=N_{FT}/4$畫出的音框數,跳距 $R=N_{FT}/4$描かれるフレーム数、ホップ $R=N_{FT}/4$ | 125 | 29 |
| green row at $k_0$ vs. true $A[n]$, Hann, both peak-normalised綠線在 $k_0$ 與真實 $A[n]$ 之差(Hann,兩者各除以自己的峰值)$k_0$ の緑の行と真の $A[n]$ との差(Hann 窓、双方を自分のピークで正規化) | $0.0004$ | $0.0066$ |
| green row three / six bins off the carrier, Hann, relative to the carrier row綠線移離載波三/六個 bin 時的高度(Hann,相對於載波那一列)搬送波から 3/6 ビン離した緑の行(Hann 窓、搬送波の行に対する比) | $-33.6/-54.4\;\text{dB}$ | $-40.7/-57.4\;\text{dB}$ |
| orange column vs. $\tfrac{A}{2}\,|W|$ shifted to $\omega_0$, Hann, worst error as a fraction of the column peak橘線與平移到 $\omega_0$ 的 $\tfrac{A}{2}\,|W|$ 之差(Hann,取最大誤差佔該欄峰值的比例)オレンジの列と $\omega_0$ へ移した $\tfrac{A}{2}\,|W|$ との差(Hann 窓、列のピークに対する最大誤差の割合) | $0.13\%$ | $0.38\%$ |
| main-lobe width, rectangular / Hann, null to null主瓣寬度,矩形/Hann,零點到零點主ローブの幅、矩形/Hann、零点から零点まで | $2/4$ bins $=0.0313/0.0625$ in $f/f_s$$2/4$ 個 bin $=0.0313/0.0625$($f/f_s$)$2/4$ ビン $=0.0313/0.0625$($f/f_s$) | $2/4$ bins $=0.0078/0.0156$ in $f/f_s$$2/4$ 個 bin $=0.0078/0.0156$($f/f_s$)$2/4$ ビン $=0.0078/0.0156$($f/f_s$) |
| worst ripple at least three bins from the carrier, rectangular / Hann離載波至少三個 bin 處最大的波紋,矩形/Hann搬送波から 3 ビン以上離れた位置の最大の波紋、矩形/Hann | $-16.8/-40.4\;\text{dB}$ | $-16.9/-40.7\;\text{dB}$ |
Read the last two rows together. The main lobe is $2/N_{FT}$ wide for the rectangular window and $4/N_{FT}$ wide for Hann, so the ridge width really does go as $c/N_{FT}$: going from $N_{FT}=64$ to $256$ divides it by exactly $4$, whichever window is chosen. Rectangular wins on width by a factor of two and loses on flanks by $24$ dB — the same bargain as §9.3.1, now visible as the shape of a ridge.最後兩列要合起來看。主瓣寬度對矩形窗是 $2/N_{FT}$,對 Hann 窗是 $4/N_{FT}$,所以山脊寬度確實按 $c/N_{FT}$ 變化:從 $N_{FT}=64$ 換到 $256$,不論用哪一種窗,寬度都恰好變成四分之一。矩形窗在寬度上贏兩倍,在兩側乾淨度上輸 $24$ dB——這正是 §9.3.1 的那筆交易,只是現在以一道山脊的形狀呈現出來。最後の二行は合わせて読むとよい。主ローブの幅は矩形窓で $2/N_{FT}$、Hann 窓で $4/N_{FT}$ である。したがって尾根の幅は確かに $c/N_{FT}$ に従う。$N_{FT}=64$ から $256$ へ移せば、どちらの窓でも幅はちょうど四分の一になる。矩形窓は幅で二倍勝ち、裾のきれいさで $24$ dB 負ける。これは §9.3.1 と同じ取引であり、いまそれが一本の尾根の形として見えているのである。
The STFT is not just for pictures — because it is invertible (when sampled densely enough), we can modify a signal in the time–frequency domain and resynthesize: noise suppression, time stretching, pitch shifting, equalization. The standard synthesis is overlap-add (OLA, 重疊相加): inverse-FFT each (possibly modified) frame, then add the frames back at their original positions:STFT 不只是用來畫圖的——因為它是可逆的(只要取樣夠密),我們可以在時頻域裡修改訊號再重新合成:雜訊抑制、時間伸縮、音高位移、等化。標準的合成方式是重疊相加(overlap-add, OLA):把每一個(可能已被修改的)音框做反 FFT,再把這些音框加回它們原本的位置上:STFT は絵を描くためだけのものではない。十分に密に標本化してあれば可逆なので、時間周波数領域で信号を加工してから再合成できる。雑音抑圧、時間伸縮、ピッチシフト、等化などである。標準的な合成は重畳加算(overlap-add, OLA)である。(場合によっては加工された)各フレームを逆 FFT し、それらを元の位置に戻して足し合わせる。
If the frames are unmodified, each IFFT returns exactly $x[n+mM]\,w[n]$, so the OLA sum gives $y[n]=x[n]\sum_m w[n-mM]$. Perfect reconstruction (up to a constant) therefore requires the shifted windows to add to a constant — the COLA (constant-overlap-add) condition(恆定重疊相加條件):如果音框沒有被修改,每一次 IFFT 恰好還原出 $x[n+mM]\,w[n]$,所以 OLA 的總和給出 $y[n]=x[n]\sum_m w[n-mM]$。因此(差一個常數的)完美重建,要求平移後的各個視窗相加等於一個常數——這就是 COLA(constant-overlap-add,恆定重疊相加)條件:フレームを加工しない場合、各 IFFT はちょうど $x[n+mM]\,w[n]$ を返すので、OLA の和は $y[n]=x[n]\sum_m w[n-mM]$ となる。したがって(定数倍を除いた)完全再構成のためには、ずらした窓の和が定数になることが必要である。これが COLA(constant-overlap-add、定数重畳加算)条件である。
For the length-$L$ periodic Hann window, COLA holds at hop $M=L/2$ (with $C=1$) and at $M=L/4$ (with $C=2$) — one reason the Hann window dominates analysis–synthesis practice. The four "STFT Analysis-Synthesis" slides walk this chain: window → FFT → modify → IFFT → overlap-add, with COLA guaranteeing transparency when nothing is modified.對長度為 $L$ 的週期性 Hann 窗,COLA 在跳距 $M=L/2$(此時 $C=1$)與 $M=L/4$(此時 $C=2$)時成立——這也是 Hann 窗在分析—合成實務上獨大的原因之一。那四張「STFT Analysis-Synthesis」投影片走的正是這條鏈:加窗 → FFT → 修改 → IFFT → 重疊相加,而 COLA 保證在什麼都不改時整條鏈是透明的。長さ $L$ の周期 Hann 窓では、ホップ $M=L/2$(このとき $C=1$)および $M=L/4$(このとき $C=2$)で COLA が成り立つ。Hann 窓が分析—合成の実務を支配している理由の一つがこれである。四枚の「STFT Analysis-Synthesis」スライドはこの流れをたどる。窓かけ → FFT → 加工 → IFFT → 重畳加算であり、何も加工しなければ COLA が透過性を保証する。
Both of the sentences above are easy to believe and neither is visible. §9.6.1 says the frames add back up to the signal; §9.6.2 says the price of that is one line of algebra, $\sum_m w[n-mM]=C$. The figure below does the addition in front of the reader instead: one frame at a time, from the first window that hangs off the left end of the signal to the last, with the running sum drawn against the original underneath it and the running $\sum_m w[n-mM]$ drawn under that. Then the hop slider takes the condition away. At $M=L/2$ and $M=L/4$ the orange curve is a straight line and the blue reconstruction lies on top of the grey original; at $M=3L/8$ it grows a visible scallop and the reconstruction follows the scallop; at $M=L$ with a Hann window it falls to zero at every seam and what comes back is the signal chopped into bulges.上面那兩句話都不難相信,而兩句都看不見。§9.6.1 說那些音框會加回成原訊號;§9.6.2 說代價是一行代數,$\sum_m w[n-mM]=C$。下面這張圖改成把這個加法當著讀者的面做一遍:一次加一個音框,從第一個懸在訊號左端外面的視窗一路加到最後一個,底下畫出目前的累加結果與原訊號的對照,再底下畫出目前的 $\sum_m w[n-mM]$。接著,跳距滑桿會把這個條件拿掉。$M=L/2$ 與 $M=L/4$ 時橘線是一條直線,藍色的重建結果就疊在灰色的原訊號上;$M=3L/8$ 時橘線長出看得見的扇貝紋,重建結果就跟著那串扇貝走;$M=L$ 配 Hann 窗時橘線在每一道接縫處掉到零,拿回來的是被切成一團一團的訊號。上の二つの文はどちらも信じるのは易しく、どちらも目には見えない。§9.6.1 はフレームを足すと信号が戻ると言い、§9.6.2 はその代償が一行の代数 $\sum_m w[n-mM]=C$ だと言う。下の図は、代わりにその足し算を読者の目の前で実行する。一度に一フレームずつ、信号の左端からはみ出した最初の窓から最後の窓まで加えていき、その下に現在の累積和を原信号と重ねて描き、さらにその下に現在の $\sum_m w[n-mM]$ を描く。そのうえでホップのつまみが条件を取り上げる。$M=L/2$ と $M=L/4$ では橙の曲線は直線であり、青い再構成は灰色の原信号にそのまま重なる。$M=3L/8$ では橙に目に見えるホタテ模様が生じ、再構成はその模様に従う。$M=L$ で Hann 窓を使えば、橙は継ぎ目ごとに零まで落ち、戻ってくるのは膨らみに刻まれた信号である。
It is worth being explicit that this is the chapter's second proof that the STFT is invertible, and not the first one told again. §9.5's last bullet added the $N$ filterbank channels at one frequency and found $\sum_k H_k(e^{j\omega})$ flat at $N\,w[0]$: the signal came back because nothing had been thrown away, every channel there still running at the full sample rate. The sum below runs the other way — along time rather than across frequency — and it is the sum the hop makes necessary, because hopping by $M$ is decimating each of those channels by $M$. §9.5's bullet says exactly this where it stops: what makes reconstruction a real question is the one stage it does not draw, the hop. COLA is the condition on that stage. The two sums are the two directions of the same time–frequency plane, both end at $y=Cx$, and the chapter needs both because the practical STFT does both.值得講明白的是:這是本章證明 STFT 可逆的第二個證明,不是把第一個再講一次。§9.5 最後一條把 $N$ 個濾波器組通道在同一個頻率上加起來,得到 $\sum_k H_k(e^{j\omega})$ 平坦在 $N\,w[0]$:訊號會回來,是因為什麼都沒有被丟掉——那裡的每一個通道都還跑在完整的取樣率上。下面這個和走的是另一個方向——沿著時間,而不是橫跨頻率——而它正是跳距逼出來的那個和,因為每隔 $M$ 跳一次,就是把那些通道每一個都降取樣 $M$ 倍。§9.5 那一條在收尾處講的就是這件事:真正讓重建變成一個問題的,是它沒有畫的那一段——跳距。COLA 就是加在那一段上的條件。這兩個和是同一個時頻平面的兩個方向,兩個都終止於 $y=Cx$,而本章兩個都要,因為實務上的 STFT 兩件事都做。これが本章における STFT の可逆性の二番目の証明であり、一番目を言い直したものではないことは、はっきりさせておく価値がある。§9.5 の最後の項目は $N$ 本のフィルタバンクのチャネルを一つの周波数で足し、$\sum_k H_k(e^{j\omega})$ が $N\,w[0]$ で平坦になることを見た。信号が戻ったのは何も捨てていなかったからであり、あそこではどのチャネルも完全な標本化率のまま動いていた。下の和は逆向きに走る。周波数を横切るのではなく時間に沿って走るのであり、これこそホップが必要にする和である。$M$ ずつ跳ぶことは、それらのチャネルを一本ずつ $M$ 倍に間引くことだからである。§9.5 のその項目は、終わり際にまさにこれを述べている。再構成を本当の問題にするのは、その図が描かない一段、すなわちホップである。COLA はその段に掛かる条件である。二つの和は同じ時間周波数平面の二つの向きであり、どちらも $y=Cx$ に行き着く。実際の STFT は両方を行うので、本章には両方が要る。
The walkthrough below keeps the figure's own notation: the hop is written $H$, which is this chapter's $M$; the segment index is written $r$, which is the $m$ the panels carry; and a "segment" is this chapter's frame. The same three substitutions govern the proof at the end of this subsection.下面這段說明沿用圖本身的寫法:跳距寫作 $H$,就是本章其他地方的 $M$;段的編號寫作 $r$,就是各面板上的 $m$;而「段」就是本章的「音框」。本節末尾那個證明也沿用同樣的三組對應。以下の説明は図そのものの表記に従う。ホップは $H$ と書くが本章の $M$ と同じ量であり、セグメント番号は $r$ と書くが各パネルの $m$ である。そして「セグメント」は本章の「フレーム」である。本節末尾の証明も同じ三つの対応に従う。
This figure breaks the overlapping STFT and ISTFT into four steps, each segment marked in its own colour, which makes it easy to follow one and the same segment from analysis through to synthesis.這張圖把重疊式 STFT 與 ISTFT 拆成四步,每一段用自己的顏色標示,方便追蹤同一段從分析到合成的過程。この図は重なりを持つ STFT と ISTFT を四つの段階に分け、各セグメントを自身の色で示すことで、同じセグメントを分析から合成まで追いやすくしたものである。
STFT (analysis)STFT(分析)STFT(分析)
ISTFT (synthesis)ISTFT(合成)ISTFT(合成)
Things to try:操作建議:操作の勧め:
What to look at, in order:建議依序這樣看:順に見ていくとよい点は次のとおりである。
Recomputed outside the figure, in double precision, with $L=64$ and the $384$-sample signal: the ripple of $\sum_m w[n-mM]$ as a fraction of $C$, and the worst reconstruction error $\max_n\lvert\hat y[n]/C-x[n]\rvert$ as a percentage of the signal's own peak, with every frame present and the round trip through DFT and IDFT actually performed.在圖之外用雙精度重算,$L=64$,訊號長 $384$ 點:$\sum_m w[n-mM]$ 的起伏(除以 $C$),以及最大的重建誤差 $\max_n\lvert\hat y[n]/C-x[n]\rvert$(除以訊號自己的峰值),所有音框都在場,而且 DFT 與 IDFT 這趟來回是真的跑過的。図の外で倍精度により計算し直した値である。$L=64$、信号は $384$ 標本。$\sum_m w[n-mM]$ のリップル($C$ に対する比)と、最大の再構成誤差 $\max_n\lvert\hat y[n]/C-x[n]\rvert$(信号自身のピークに対する比)を示す。すべてのフレームが揃っており、DFT と IDFT の往復も実際に行っている。
| hop跳距ホップ | Hann: $C$, ripple, errorHann 窗:$C$、起伏、誤差Hann 窓:$C$、リップル、誤差 | rectangular: $C$, ripple, error矩形窗:$C$、起伏、誤差矩形窓:$C$、リップル、誤差 |
|---|---|---|
| $M=L$ (0%) | $0.5$, $200\%$, $96.8\%$ | $1$, $0$, $1.2\times10^{-12}\%$ |
| $M=3L/4$ (25%) | $0.667$, $106\%$, $47.9\%$ | $1.333$, $75\%$, $50.0\%$ |
| $M=L/2$ (50%) | $1$, $4.4\times10^{-16}$, $8.7\times10^{-13}\%$ | $2$, $0$, $7.8\times10^{-13}\%$ |
| $M=3L/8$ (62.5%) | $1.333$, $6.73\%$, $2.94\%$ | $2.667$, $37.5\%$, $23.3\%$ |
| $M=L/4$ (75%) | $2$, $4.4\times10^{-16}$, $6.0\times10^{-13}\%$ | $4$, $0$, $5.9\times10^{-13}\%$ |
Two things in that table are worth saying out loud. First, §9.6.2's claim is confirmed exactly and is also narrower than the truth: the periodic Hann window satisfies COLA not only at $M=L/2$ and $M=L/4$ but at $M=L/k$ for every integer $k\ge 2$ that divides $L$, with $C=k/2$ — measured at $k=2,4,8,16$ for this figure's $L=64$, and, because a power of two admits no other integer hop, at $k=3,5,6,9,11$ as well by repeating the sweep at $L=48,60,66,72,120$; ripple $\le 2.7\times10^{-15}$ and $C=k/2$ exact every time. Every hop in between fails, and the failure grows as $L/M$ moves away from an integer. Second, the rectangular window satisfies COLA wherever $L/M$ is an integer too, including $M=L$, where it is the one window in this figure that reconstructs perfectly with no overlap at all. Perfect reconstruction and a useful analysis are different questions, and §9.4.4's first bullet is where the rectangular window loses the second one.表裡有兩件事值得講出來。第一,§9.6.2 的說法完全被驗証,而且它比事實窄:週期型 Hann 窗滿足 COLA 的,不只是 $M=L/2$ 與 $M=L/4$,而是每一個整除 $L$ 的整數 $k\ge 2$ 所對應的 $M=L/k$,此時 $C=k/2$——在本圖的 $L=64$ 上量了 $k=2,4,8,16$;而因為 2 的冪次再給不出別的整數跳距,又在 $L=48,60,66,72,120$ 上重跑一次,量到 $k=3,5,6,9,11$。起伏每次都 $\le 2.7\times10^{-15}$,$C=k/2$ 每次都準確。中間每一個跳距都不成立,而且 $L/M$ 離整數越遠就壞得越厲害。第二,矩形窗同樣在 $L/M$ 是整數的地方滿足 COLA,連 $M=L$ 也算,它是這張圖裡唯一一個完全不重疊也能完美重建的視窗。完美重建與有用的分析是兩個不同的問題,而矩形窗輸掉第二個問題的地方,就在 §9.4.4 的第一條。この表には声に出して言う価値のあることが二つある。第一に、§9.6.2 の主張はそのまま確認されたが、同時に事実より狭い。周期 Hann 窓が COLA を満たすのは $M=L/2$ と $M=L/4$ だけではなく、$L$ を割り切る $k\ge 2$ のすべての整数に対する $M=L/k$ であり、そのとき $C=k/2$ である。本図の $L=64$ では $k=2,4,8,16$ を測った。2 の冪はそれ以外の整数ホップを与えないため、$L=48,60,66,72,120$ で掃引をやり直し、$k=3,5,6,9,11$ も測った。リップルは毎回 $\le 2.7\times10^{-15}$、$C=k/2$ も毎回正確であった。その間のホップはどれも成り立たず、$L/M$ が整数から離れるほど破綻は大きくなる。第二に、矩形窓もまた $L/M$ が整数であればどこでも COLA を満たす。$M=L$ も含まれ、この図で重なり無しに完全再構成できる唯一の窓である。完全再構成と有用な分析は別の問題であり、矩形窓が後者を失うのは §9.4.4 の第一項においてである。
The figure above performs the sum; what follows proves it, on a sequence short enough to check by hand.上面那張圖把這個和做了出來;底下這一段則是把它證明出來,用一段短到可以用手驗算的序列。上の図はその和を実行してみせた。以下はそれを、手で検算できるほど短い系列の上で証明する。
There are only two points. Each segment's IDFT recovers the windowed segment exactly, and the Hann windows of a 50% overlap add to 1 everywhere. Put together, the sum is the original sequence, and no division is needed at all.關鍵只有兩點:每段的 IDFT 能精確取回加窗後的那一段,以及 50% 重疊的 Hann 窗加起來處處等於 1。兩者合起來,相加的結果就是原序列,完全不需要除法。要点は二つだけである。各セグメントの IDFT は窓を掛けたそのセグメントを正確に取り戻すこと、そして 50% 重なる Hann 窓は至るところで和が 1 になることである。両者を合わせれば、加え合わせた結果が原系列そのものになり、割り算はまったく要らない。
Take the periodic Hann window with $N = 4$ and hopsize $H = 2$ (50% overlap):取 $N = 4$ 的週期型 Hann 窗,hopsize $H = 2$(50% 重疊):$N = 4$ の周期 Hann 窓をとり、hopsize は $H = 2$(50% の重なり)とする。
The original sequence is $x = [3, 5, 2, 7, 4, 6, 1, 8]$ (zero outside that range). The segments start at $s = -2, 0, 2, 4, 6$.原序列 $x = [3, 5, 2, 7, 4, 6, 1, 8]$(範圍外補 0)。每段從 $s = -2, 0, 2, 4, 6$ 開始。原系列は $x = [3, 5, 2, 7, 4, 6, 1, 8]$(範囲外は 0 とする)。各セグメントは $s = -2, 0, 2, 4, 6$ から始まる。
Step 1: STFT then IDFT, recovering each segment's $x[n]\,w[n-s]$ (the DFT is invertible, so nothing at all is lost at this step)步驟 1:STFT 再 IDFT,取回每段的 $x[n]\,w[n-s]$(DFT 可逆,所以這一步沒有任何損失)手順 1:STFT のあと IDFT を行い、各セグメントの $x[n]\,w[n-s]$ を取り戻す(DFT は可逆なので、この段階では何も失われない)
| segment start $s$段起點 $s$セグメント開始位置 $s$ | $n=0$ | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| $-2$ (weights)(權重)(重み) | 1 | 0.5 | ||||||
| $0$ | 0 | 0.5 | 1 | 0.5 | ||||
| $2$ | 0 | 0.5 | 1 | 0.5 | ||||
| $4$ | 0 | 0.5 | 1 | 0.5 | ||||
| $6$ | 0 | 0.5 | ||||||
| weight sum權重總和重みの総和 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
Every position is covered by two segments: one gives it 1 and the other 0, or the two give 0.5 each. The sum is always 1.每個位置都被兩段涵蓋:一段給它 1、另一段給它 0,或兩段各給 0.5。總和永遠是 1。どの位置も二つのセグメントに覆われる。一方が 1 を、他方が 0 を与えるか、二つが 0.5 ずつを与えるかである。総和はつねに 1 である。
Step 2: put each segment back where it was and add步驟 2:把各段放回原位相加手順 2:各セグメントを元の位置に戻して足し合わせる
| $n$ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| $x[n]$ | 3 | 5 | 2 | 7 | 4 | 6 | 1 | 8 |
| contribution of the first covering segment第一個覆蓋段的貢獻一つめに覆うセグメントの寄与 | 3×1 | 5×0.5 | 2×1 | 7×0.5 | 4×1 | 6×0.5 | 1×1 | 8×0.5 |
| contribution of the second covering segment第二個覆蓋段的貢獻二つめに覆うセグメントの寄与 | 3×0 | 5×0.5 | 2×0 | 7×0.5 | 4×0 | 6×0.5 | 1×0 | 8×0.5 |
| sum相加総和 | 3 | 5 | 2 | 7 | 4 | 6 | 1 | 8 |
The sum is exactly the original sequence.相加結果和原序列完全相同。加え合わせた結果は原系列とまったく同じである。
Each segment's IDFT gives $x[n]\,w[n - rH]$; adding all of them,每段 IDFT 得到 $x[n]\,w[n - rH]$,全部相加:各セグメントの IDFT は $x[n]\,w[n - rH]$ を与える。すべてを足すと、
$x[n]$ does not depend on $r$ and can be taken outside, so the reconstruction is exact as soon as the windows sum to 1.$x[n]$ 和 $r$ 無關,可以提出來,所以只要窗的總和為 1 就完全還原。$x[n]$ は $r$ に依存しないので外へ括り出せる。したがって窓の総和が 1 でありさえすれば完全に復元される。
Why is the Hann 50% sum 1? Every position is covered by exactly two segments, and the two windows are half a period out of phase:為什麼 Hann 50% 的總和是 1?任何位置都恰好被兩段涵蓋,兩段窗的相位差半個週期:なぜ Hann の 50% で総和が 1 になるのか。どの位置もちょうど二つのセグメントに覆われ、二つの窓の位相は半周期ずれている。
Because $\cos(\theta - \pi) = -\cos\theta$, the two cosine terms cancel each other.因為 $\cos(\theta - \pi) = -\cos\theta$,兩個餘弦項互相抵消。$\cos(\theta - \pi) = -\cos\theta$ であるから、二つの余弦項は互いに打ち消し合う。
The window "shares out" each sample among the segments that cover it: this one gets $w_a$, that one gets $w_b$. As long as $w_a + w_b = 1$, adding them collects the sample back whole, with nothing over and nothing missing. Even where one segment's weight at that position is 0 (the segment $s = 0$ at $n = 0$ in the table above, for instance), the other is certain to give it 1, so no information is lost.窗把每個樣本「分配」給涵蓋它的幾段:這段分到 $w_a$,那段分到 $w_b$。只要 $w_a + w_b = 1$,相加時就把它完整地收回來,沒有多也沒有少。即使某段在這個位置的權重是 0(例如上表中 $n = 0$ 對 $s = 0$ 那段),另一段一定給它 1,所以不會有資訊遺失。窓は各標本を、それを覆うセグメントのあいだに「配分」する。こちらのセグメントには $w_a$、あちらには $w_b$ が渡る。$w_a + w_b = 1$ でありさえすれば、足し合わせたときにその標本は過不足なく丸ごと戻ってくる。ある位置でのあるセグメントの重みが 0 であっても(たとえば上の表の $n = 0$ における $s = 0$ のセグメント)、他方が必ず 1 を与えるので、情報が失われることはない。
This also explains the two premises.這也說明了兩個前提:ここから二つの前提も説明される。
The callout above ends the argument where most treatments end it: modification breaks the algebra, use a synthesis window. It leaves one question unanswered, and it is the question a reader who has just worked the hop slider in the figure above will ask. If the algebra is gone the moment anything is edited, why does a modifying system still insist on a tapered window and fifty percent overlap? COLA was the reason for the overlap, and COLA no longer applies.上面那段提示把話停在大多數教材停下來的地方:一旦修改,代數就不成立,所以要加合成視窗。它留下一個沒有回答的問題,而這正是剛剛玩過上面那張圖的跳距滑桿的讀者會問的問題。如果只要動了東西,那套代數就失效了,那麼一個會修改係數的系統為什麼還要堅持用漸縮的視窗、堅持五成的重疊?重疊原本的理由是 COLA,而 COLA 已經不適用了。上の注意書きは、多くの教科書が議論を止めるところで止めている。加工すれば代数は崩れる、だから合成窓を使え、である。そこには答えられていない問いが一つ残る。上の図のホップのつまみを動かしたばかりの読者が抱くのは、まさにその問いである。何かを編集した瞬間に代数が消えるのなら、係数を加工する系がなお漸減する窓と五割の重なりに固執するのはなぜか。重ねる理由は COLA であったのに、その COLA はもう効かないのである。
The answer is that the two things are not one thing. COLA buys exact reconstruction of a signal nobody has touched. Tapered overlap buys survivable modification, which is a separate property with a separate proof, and neither implies the other. The cleanest way to see that they are separate is to find a setting that has the first and not the second — and one is sitting in plain sight. A rectangular window at zero overlap, $M=L$, satisfies COLA perfectly: the shifted windows tile the axis end to end, their sum is the constant $1$ with no rounding error at all, and an unmodified signal comes back to the last bit. It is the one setting where the reconstruction proof is so trivial it needs no window theory. And it is the worst setting in this chapter for modifying anything.答案是:這兩件事本來就不是同一件事。COLA 買到的是完美重建——針對沒有人動過的訊號。漸縮加重疊買到的是「改得下去」,那是另一個性質、另一個證明,兩者互不蘊含。要看出它們是分開的,最乾淨的辦法是找一個只有前者、沒有後者的設定——而這個設定就擺在眼前。矩形窗配零重疊($M=L$)完美滿足 COLA:平移後的視窗把時間軸首尾相接地鋪滿,總和就是常數 $1$,連捨入誤差都沒有,未經修改的訊號會一位不差地回來。那是全章裡重建證明最不費力的一個設定,也是全章裡最不適合拿來修改任何東西的一個設定。答えは、その二つがもともと一つではない、ということである。COLA が買うのは、誰も触っていない信号の完全再構成である。漸減と重なりが買うのは、加工に耐えることであり、これは別の性質、別の証明であって、どちらも互いを含意しない。両者が別物だと見抜くいちばん清潔な方法は、前者だけを持ち後者を持たない設定を一つ見つけることであり、それは目の前にある。矩形窓で重なり零、すなわち $M=L$ は COLA を完全に満たす。ずらした窓が時間軸を端から端まで敷き詰め、その和は定数 $1$ で丸め誤差すらなく、加工していない信号は最下位ビットまで戻る。再構成の証明がこれほど軽くて済む設定は本章に他になく、そして何かを加工するには本章でいちばん悪い設定である。
The figure below runs both settings on the same signal with the same edit and measures the difference. The edit is applied to the coefficients, exactly as §9.6.1 describes — a block of frames attenuated, or a per-bin spectral gate — and every frame really goes through the DFT and the IDFT, so nothing here is assumed. Panel ① is the premise: $\sum_m w[n-mM]$ for both settings, and both are flat. Panel ② is the point. It plots how much of each frame survives the edit, blended by the windows exactly as the frames themselves are: $G[n]=\sum_m a_m\,w[n-mM]/C$, with $a_m$ the surviving fraction of frame $m$ — the factor $g$ itself for the block attenuation, and the fraction of bins the gate keeps for the gate. For an edit that is one number per frame this curve is the gain the signal sees, exactly. With the rectangular window at zero overlap that curve is a staircase with vertical risers; with Hann at half overlap it is the same total change spread over $M$ samples.下面這張圖把兩個設定放在同一段訊號上、施加同一個修改,然後把差別量出來。修改是加在係數上的,正如 §9.6.1 所述——把一段音框整體衰減,或是逐頻格的頻譜閘門——而且每一個音框都真的走過 DFT 與 IDFT,這裡沒有任何假設。面板 ① 是前提:兩個設定的 $\sum_m w[n-mM]$,兩條都是平的。面板 ② 才是重點。它畫出每一個音框在這個修改下存活了多少,而且用跟音框本身一模一樣的方式被視窗混合起來:$G[n]=\sum_m a_m\,w[n-mM]/C$,其中 $a_m$ 是第 $m$ 個音框存活下來的比例——對整塊衰減而言就是 $g$ 本身,對門檻而言則是被保留下來的頻格比例。對於「每個音框一個數」的修改而言,這條曲線就是訊號所看到的增益,分毫不差。矩形窗配零重疊時,那條曲線是一道道垂直立面的階梯;Hann 配半重疊時,同樣的總變化量被攤在 $M$ 個取樣點上。下の図は、同じ信号に同じ編集を加えた二つの設定を並べて走らせ、その差を測る。編集は §9.6.1 の述べるとおり係数に対して加えられる。フレームの一塊をまとめて減衰させるか、ビンごとのスペクトルゲートをかけるかである。そしてどのフレームも実際に DFT と IDFT を通るので、ここに仮定はない。パネル ① は前提である。両設定の $\sum_m w[n-mM]$ であり、どちらも平坦である。パネル ② が要点である。各フレームがこの加工をどれだけ生き残るかを、フレーム自身とまったく同じやり方で窓によって混ぜて描く。$G[n]=\sum_m a_m\,w[n-mM]/C$ であり、$a_m$ はフレーム $m$ の生き残った割合である。一塊の減衰なら $g$ そのもの、ゲートなら残したビンの割合である。フレームあたり一つの数で済む加工に対しては、この曲線がそのまま信号の見る利得である。矩形窓で重なり零なら、その曲線は垂直な立ち上がりを持つ階段であり、Hann で半分重ねれば、同じ総変化量が $M$ 標本にわたって引き伸ばされる。
What to look at, in order:建議依序這樣看:順に見ていくとよい点は次のとおりである。
One consequence is worth stating because it is the bridge to the standard fix the callout names. If what tapering buys is a blend at every output sample, then the analysis window alone provides it only while the edit is a scalar per frame. A per-bin edit changes each frame's time-domain shape, and the frames can then disagree inside the overlap in ways the analysis taper does not smooth, which is exactly the regime panel ⑤ enters under the spectral gate. Applying a second taper on the way out — the synthesis window of weighted overlap-add, with $\sum_m w_a[n-mM]\,w_s[n-mM]=C$ in place of the plain COLA sum — forces every frame's contribution to fade to zero at its own edges no matter what was done to it in between. That is why WOLA, not COLA, is the condition quoted in modification systems; §9.7 picks the thread up from there.有一個推論值得講出來,因為它正是通往上面那段提示所說的標準解法的橋。如果漸縮買到的是「每一個輸出取樣點都是一個混合」,那麼只靠分析視窗提供這個混合,前提是修改必須是「每個音框一個純量」。逐頻格的修改會改變每個音框在時域裡的形狀,於是各個音框可能在重疊區內以分析端的漸縮平不掉的方式彼此矛盾——那正是面板 ⑤ 在頻譜閘門下進入的狀態。在輸出的路上再加一層漸縮——也就是加權重疊相加的合成視窗,把條件從單純的 COLA 和換成 $\sum_m w_a[n-mM]\,w_s[n-mM]=C$——就能強迫每一個音框的貢獻在自己的兩端淡到零,不管中間對它做了什麼。這就是為什麼在會修改係數的系統裡,被引用的條件是 WOLA 而不是 COLA;§9.7 從這裡接下去。述べておく価値のある帰結が一つある。上の注意書きが名を挙げた標準的な対処への橋がそれだからである。漸減が買うものが各出力標本における混合であるならば、分析窓だけでそれを供給できるのは、加工がフレームごとのスカラーである間に限られる。ビン単位の加工は各フレームの時間領域の形そのものを変えるので、フレームどうしが重なりの内部で、分析側の漸減では均せない形に食い違いうる。スペクトルゲートの下でパネル ⑤ が入っていくのは、まさにその領域である。出口側にもう一枚の漸減を掛けること、すなわち重み付き重畳加算の合成窓を置き、素の COLA の和の代わりに $\sum_m w_a[n-mM]\,w_s[n-mM]=C$ を課すことは、途中で何をされたかに関わらず、各フレームの寄与を自分の両端で零まで落とすことを強制する。加工を行う系で引かれる条件が COLA ではなく WOLA である理由はこれである。§9.7 はここから話を引き継ぐ。
The callout above refused the slide's sentence, and the figure above measured how much worse the untapered setting is. Neither says why the taper works, and that is one short derivation: the curve panel ② plots turns out to be a weighted average, and a weighted average taken with a Hann window is a crossfade. What follows derives it. Nothing below re-measures what the figure above already measured.上面那段提示拒絕了投影片的那句話,上面那張圖則量出了沒有漸縮的設定差多少。兩者都沒有說漸縮為什麼有用,而那只是一小段推導:面板 ② 畫的那條曲線,其實是一個加權平均,而用 Hann 窗取的加權平均就是一次交叉淡化。底下把它推出來;上面那張圖已經量過的東西,底下不再量一次。上の注意書きはスライドのあの一文を退け、上の図は漸減しない設定がどれだけ悪いかを測った。どちらも、漸減がなぜ効くのかは述べていない。それは短い導出一つで済む。パネル ② が描くあの曲線は、実は重み付き平均であり、Hann 窓で取る重み付き平均とは一回のクロスフェードにほかならない。以下はそれを導く。上の図がすでに測ったことを、以下で測り直すことはしない。
"tapered overlap makes things OK" means this: the window tapering to 0 at both ends (tapered), together with neighbouring segments overlapping (overlap) — the two of them together let the signal we reconstruct stay smooth and natural after we have modified each segment's spectrum.「tapered overlap makes things OK」的意思是:窗兩端漸縮到 0(tapered),再加上相鄰段重疊(overlap),這兩者合在一起,讓我們修改每一段的頻譜後,還原出來的訊號仍然平滑自然。「tapered overlap makes things OK」の意味はこうである。窓が両端で 0 まで漸減し(tapered)、さらに隣り合うセグメントが重なる(overlap)。この二つが合わさることで、各セグメントのスペクトルを加工したあとでも、復元される信号は滑らかで自然なままでいられる。
Without modification, each segment's IFFT returns exactly $x[n]\,w[n - rH]$, and the overlap-add reconstructs perfectly. But once some segments have been modified (multiplying certain bins by 0 during denoising, say, or giving each segment a different gain), each segment's result is no longer a piece of the original signal, and the values of two neighbouring segments need not join up where they meet.不修改時,每段 IFFT 得到的正是 $x[n]\,w[n - rH]$,重疊相加後完全還原。但若修改了某些段(例如降噪時把某些格子乘上 0,或每段的增益不同),每段的結果就不再是原訊號的一部分,相鄰兩段在交界處的值不一定接得起來。加工しなければ、各セグメントの IFFT が返すのはまさに $x[n]\,w[n - rH]$ であり、重畳加算すれば完全に復元される。しかし一部のセグメントを加工すると(たとえば雑音除去である種のビンに 0 を掛ける、あるいはセグメントごとに利得を変える)、各セグメントの結果はもはや原信号の一部ではなくなり、隣り合う二つのセグメントの値は境目で必ずしもつながらない。
At synthesis time the output at each sample $n$ is the sum of the segments that cover it. If each segment has been modified by "multiply by a gain $g_r$", the output becomes合成時,每個樣本 $n$ 的輸出是覆蓋它的那幾段相加。若每段做了「乘上增益 $g_r$」這種修改,輸出變成合成時、各標本 $n$ の出力は、そこを覆うセグメントの和である。各セグメントに「利得 $g_r$ を掛ける」という加工を施したとすると、出力は次のようになる。
Because $\sum_r w[n - rH] = 1$, the quantity $\sum_r g_r\,w[n - rH]$ is a weighted average of the segment gains, weighted by the shape of the window. The Hann window falls smoothly from 1 to 0 while the next one rises smoothly from 0 to 1, so the gain that actually acts on the signal passes smoothly from $g_r$ to $g_{r+1}$, just like a crossfade in audio editing.因為 $\sum_r w[n - rH] = 1$,所以 $\sum_r g_r\,w[n - rH]$ 就是各段增益的加權平均,權重是窗的形狀。Hann 窗平滑地從 1 降到 0、下一段平滑地從 0 升到 1,所以實際作用在訊號上的增益會平滑地從 $g_r$ 過渡到 $g_{r+1}$,就像音訊剪輯中的交叉淡化(crossfade)。$\sum_r w[n - rH] = 1$ であるから、$\sum_r g_r\,w[n - rH]$ は各セグメントの利得の重み付き平均であり、重みは窓の形そのものである。Hann 窓は 1 から 0 へなめらかに下がり、次の窓は 0 から 1 へなめらかに上がるので、信号に実際に作用する利得は $g_r$ から $g_{r+1}$ へなめらかに移り変わる。音声編集でいうクロスフェードそのものである。
That $\sum_r w[n - rH] = 1$ is the Hann-at-50% case, which is the case this derivation is about. At 75% overlap the window sum is $C = 2$ — measured as $2.000000000000000$, flat to the last digit — so the gain that acts is $\sum_r g_r\,w / \sum_r w$, still the same weighted average, now normalised by $C$. The $G[n]=\sum_m a_m\,w[n-mM]/C$ that panel ② of the figure above plots is this same curve written that way.那個 $\sum_r w[n - rH] = 1$ 是 Hann 配 50% 重疊的情形,也就是這段推導所談的情形。在 75% 重疊下視窗總和是 $C = 2$——量到 $2.000000000000000$,平到最後一位——實際作用的增益因此是 $\sum_r g_r\,w / \sum_r w$,仍然是同一個加權平均,只是再除以 $C$。上面那張圖的面板 ② 畫的 $G[n]=\sum_m a_m\,w[n-mM]/C$,正是寫成這個樣子的同一條曲線。その $\sum_r w[n - rH] = 1$ は Hann と 50% の重なりの場合であり、この導出が扱っているのはまさにその場合である。75% の重なりでは窓の総和は $C = 2$ であり($2.000000000000000$ と実測され、最下位の桁まで平坦である)、実際に作用する利得は $\sum_r g_r\,w / \sum_r w$ となる。やはり同じ重み付き平均であり、$C$ で正規化されるだけである。上の図のパネル ② が描く $G[n]=\sum_m a_m\,w[n-mM]/C$ は、この同じ曲線をその形に書いたものである。
Besides, the window's weight is small at both ends, so the flaws a modification creates at each segment's edges — the wrap-around of a circular convolution, for instance — are also pressed down small, and are covered over by the middle of the neighbouring segment.另外,窗的兩端權重很小,每段邊緣因修改產生的瑕疵(例如循環卷積造成的繞回)也被壓得很小,而且正好被相鄰段的中央部分蓋過。さらに、窓の両端では重みが小さいので、加工が各セグメントの端に生じさせる欠陥(たとえば巡回畳み込みによる回り込み)も小さく抑えられ、ちょうど隣のセグメントの中央部によって覆い隠される。
An example: segment $r$ has gain 1 and segment $r+1$ has gain 0 (a mask cuts the whole segment away):例子:第 $r$ 段增益 1、第 $r+1$ 段增益 0(遮罩把整段砍掉):例:第 $r$ セグメントの利得を 1、第 $r+1$ セグメントの利得を 0 とする(マスクがセグメントをまるごと削り取る場合である)。
| rectangular window, no overlap矩形窗,不重疊矩形窓、重なり無し | Hann window, 50% overlapHann 窗,50% 重疊Hann 窓、50% の重なり | |
|---|---|---|
| how the gain changes增益變化利得の変化 | jumps from 1 to 0 instantly at the seam在接縫處從 1 瞬間跳到 0継ぎ目で 1 から 0 へ瞬時に跳ぶ | falls smoothly from 1 to 0 over 32 samples在 32 個樣本內平滑地從 1 降到 032 標本かけて 1 から 0 へなめらかに下がる |
| how it sounds聽起來聞こえ方 | a click「喀」的一聲「カチッ」という音 | a natural fade-out自然淡出自然なフェードアウト |
Each segment is given a random gain (simulating a modification that varies with time), and the two approaches are compared by the gain curve that actually acts on the signal and by the output waveform.每段隨機給一個增益(模擬隨時間變化的修改),比較兩種做法實際作用在訊號上的增益曲線與輸出波形。各セグメントに乱数の利得を与え(時間とともに変化する加工を模している)、信号に実際に作用する利得の曲線と出力波形とで二つのやり方を比べる。
The signal in the figure is a sine wave of constant amplitude, and each segment is assigned a random gain (grey dashed), simulating "a modification that varies with time".圖中的訊號是固定振幅的正弦波,每一段被指定一個隨機增益(灰色虛線),模擬「隨時間變化的修改」。図中の信号は振幅一定の正弦波であり、各セグメントには乱数の利得が割り当てられる(灰色の破線)。「時間とともに変化する加工」を模したものである。
This is what the slide's "OK" means: the differences the modification creates between one segment and the next are interpolated smoothly by the shape of the window, instead of being switched over abruptly. It cannot make the modified result perfect, but it can make the flaws inconspicuous. For a cleaner result one can go further and use the synthesis window mentioned above (WOLA), pressing down the head and the tail of each segment a second time at synthesis.這就是投影片說「OK」的意思:修改造成的段與段之間的差異,被窗的形狀平滑地內插起來,而不是硬生生地切換。它不能讓修改後的結果完美,但能讓瑕疵不明顯。若需要更乾淨的效果,可以進一步使用前面提到的合成窗(WOLA),讓每段的頭尾在合成時再被壓低一次。これがスライドのいう「OK」の意味である。加工が生むセグメント間の差は、窓の形によってなめらかに内挿されるのであって、無理やり切り替えられるのではない。加工後の結果を完璧にすることはできないが、欠陥を目立たなくすることはできる。もっと清潔な結果が必要なら、先に述べた合成窓(WOLA)をさらに用いて、各セグメントの先頭と末尾を合成時にもう一度押し下げればよい。
$X_m[k]=\sum_{n=0}^{N-1}x[n+mM]w[n]e^{-j2\pi kn/N}$: slide a length-$L$ window by hops of $M$, FFT each frame. Time grid $mM/f_s$, frequency grid $kf_s/N$.$X_m[k]=\sum_{n=0}^{N-1}x[n+mM]w[n]e^{-j2\pi kn/N}$:把長度 $L$ 的視窗以 $M$ 為跳距滑移,對每個音框做 FFT。時間格點為 $mM/f_s$,頻率格點為 $kf_s/N$。$X_m[k]=\sum_{n=0}^{N-1}x[n+mM]w[n]e^{-j2\pi kn/N}$:長さ $L$ の窓を $M$ ずつずらし、各フレームを FFT する。時間格子は $mM/f_s$、周波数格子は $kf_s/N$。
$S[m,k]=|X_m[k]|^2$, displayed in dB. Rows = bandpass channel outputs, columns = frame spectra. Keep $k<N/2$ for real signals.$S[m,k]=|X_m[k]|^2$,以 dB 顯示。列=帶通通道的輸出,欄=音框的頻譜。實數訊號只保留 $k<N/2$。$S[m,k]=|X_m[k]|^2$ を dB 表示したもの。行=帯域通過チャネルの出力、列=フレームのスペクトル。実信号では $k<N/2$ だけを残す。
Mainlobe ↔ resolution, sidelobes ↔ leakage. Rect: $4\pi/L$, $-13$ dB. Hann: $8\pi/L$, $-31$ dB, COLA at 50%/75% overlap — the default.主瓣 ↔ 解析度,旁瓣 ↔ 洩漏。矩形窗:$4\pi/L$,$-13$ dB。Hann 窗:$8\pi/L$,$-31$ dB,在 50%/75% 重疊下滿足 COLA——預設之選。主ローブ ↔ 分解能、サイドローブ ↔ 漏れ。矩形窓:$4\pi/L$、$-13$ dB。Hann 窓:$8\pi/L$、$-31$ dB、50%/75% の重なりで COLA を満たす——既定の選択である。
$\Delta t\approx L/f_s$, $\Delta f\approx c f_s/L$, $\Delta t\,\Delta f\ge 1/4\pi$. Long = narrowband (harmonics), short = wideband (transients). Zero-padding interpolates only.$\Delta t\approx L/f_s$,$\Delta f\approx c f_s/L$,$\Delta t\,\Delta f\ge 1/4\pi$。長窗=窄帶(看得到諧波),短窗=寬帶(看得到暫態)。補零只做內插。$\Delta t\approx L/f_s$、$\Delta f\approx c f_s/L$、$\Delta t\,\Delta f\ge 1/4\pi$。長い窓=狭帯域(高調波が見える)、短い窓=広帯域(過渡現象が見える)。ゼロ詰めは内挿するだけである。
Hop $M$, overlap $L-M$; 50–75% typical. spectrogram(x,hann(N),N-M,N,Fs) takes overlap, not hop. Frames: $\lfloor (L_x-N)/M\rfloor+1$.跳距 $M$,重疊 $L-M$;典型值為 50–75%。spectrogram(x,hann(N),N-M,N,Fs) 收的是重疊量,不是跳距。音框數:$\lfloor (L_x-N)/M\rfloor+1$。ホップ $M$、重なり $L-M$。典型的には 50–75%。spectrogram(x,hann(N),N-M,N,Fs) が受け取るのは重なり量であってホップではない。フレーム数:$\lfloor (L_x-N)/M\rfloor+1$。
IFFT frames + overlap-add; perfect reconstruction iff $\sum_m w[n-mM]=C$ (COLA). Hann at $M=L/2$: $C=1$; at $M=L/4$: $C=2$.對各音框做 IFFT 再重疊相加;完美重建的充要條件是 $\sum_m w[n-mM]=C$(COLA)。Hann 窗在 $M=L/2$ 時 $C=1$;在 $M=L/4$ 時 $C=2$。各フレームを IFFT して重畳加算する。完全再構成が成り立つのは $\sum_m w[n-mM]=C$(COLA)のとき、かつそのときに限る。Hann 窓では $M=L/2$ のとき $C=1$、$M=L/4$ のとき $C=2$。
Problem: Let $x_1[n]$ consist of a 50 Hz tone for the first half-second followed by a 120 Hz tone for the second half-second ($f_s=1$ kHz), and let $x_2[n]$ play the same two tones in the opposite order (Fig. 9-1). (a) Explain why $|X_1(e^{j\omega})| \approx |X_2(e^{j\omega})|$. (b) Where, mathematically, does the FT store the ordering information? (c) Describe what the STFT magnitude of each signal looks like and why it distinguishes them.題目:設 $x_1[n]$ 在前半秒是一個 50 Hz 的音調,後半秒是一個 120 Hz 的音調($f_s=1$ kHz),而 $x_2[n]$ 以相反的順序播放同樣這兩個音調(圖 9-1)。(a) 說明為什麼 $|X_1(e^{j\omega})| \approx |X_2(e^{j\omega})|$。(b) 在數學上,傅立葉轉換把順序的資訊存放在哪裡?(c) 描述這兩個訊號的 STFT 振幅各長什麼樣子,以及為什麼 STFT 分得出它們。問題:$x_1[n]$ を、最初の半秒が 50 Hz の純音、次の半秒が 120 Hz の純音からなる信号とし($f_s=1$ kHz)、$x_2[n]$ は同じ二つの純音を逆の順序で鳴らす信号とする(図 9-1)。(a) なぜ $|X_1(e^{j\omega})| \approx |X_2(e^{j\omega})|$ となるのかを説明せよ。(b) フーリエ変換は順序の情報を数学的にどこへ蓄えているか。(c) それぞれの信号の STFT 振幅がどのように見えるか、そしてなぜそれで両者を区別できるかを述べよ。
(a) Write $x_2[n]=x_1[n_0-1-n]$ approximately (the second signal is a time-reversal-plus-shift of the first up to phase of the tones; more simply, each is a sum of the same two gated tones, just gated by complementary halves). A gated tone $g[n]\cos(\omega_i n)$ has spectrum $\tfrac12 G(e^{j(\omega-\omega_i)})+\tfrac12 G(e^{j(\omega+\omega_i)})$ where $G$ is the gate's spectrum. Shifting the gate in time multiplies $G$ by a pure phase $e^{-j\omega n_d}$ and leaves $|G|$ unchanged. Since both signals are sums of the same two gated tones with gates that differ only by a time shift, and the two spectral lumps (50 and 120 Hz) barely overlap, the magnitude spectra are nearly identical — only the cross terms in the overlap region differ slightly.(a) 近似地寫成 $x_2[n]=x_1[n_0-1-n]$(第二個訊號是第一個訊號的時間反轉加平移,差別只在音調的相位;更簡單地說,兩者都是同樣兩個被閘控音調的和,只是閘控在互補的兩個半段上)。一個被閘控的音調 $g[n]\cos(\omega_i n)$ 的頻譜為 $\tfrac12 G(e^{j(\omega-\omega_i)})+\tfrac12 G(e^{j(\omega+\omega_i)})$,其中 $G$ 是閘函數的頻譜。把閘函數在時間上平移,只是讓 $G$ 乘上一個純相位 $e^{-j\omega n_d}$,而 $|G|$ 不變。既然兩個訊號都是同樣兩個被閘控音調的和、而兩個閘函數只差一個時間平移,又因為兩團頻譜(50 與 120 Hz)幾乎不重疊,所以振幅頻譜幾乎一模一樣——只有重疊區域的交叉項略有差異。(a) おおよそ $x_2[n]=x_1[n_0-1-n]$ と書ける(第二の信号は第一の信号を時間反転して平行移動したもので、違いは純音の位相だけである。もっと簡単に言えば、どちらも同じ二つのゲートされた純音の和であり、ゲートが相補的な前半と後半になっているにすぎない)。ゲートされた純音 $g[n]\cos(\omega_i n)$ のスペクトルは $\tfrac12 G(e^{j(\omega-\omega_i)})+\tfrac12 G(e^{j(\omega+\omega_i)})$ であり、ここで $G$ はゲートのスペクトルである。ゲートを時間方向にずらしても、$G$ に純粋な位相 $e^{-j\omega n_d}$ が掛かるだけで $|G|$ は変わらない。二つの信号はいずれも同じ二つのゲートされた純音の和で、ゲートどうしは時間移動しか違わず、しかも二つのスペクトルの塊(50 Hz と 120 Hz)はほとんど重ならない。したがって振幅スペクトルはほぼ同一となり、わずかに異なるのは重なり領域の交差項だけである。
(b) In the phase: a delay of $n_d$ samples contributes the linear phase factor $e^{-j\omega n_d}$. The ordering of events is encoded in how the phase of each spectral lump slopes with $\omega$ (group delay $-\,d\angle X/d\omega$ evaluated near each tone gives that tone's arrival time).(b) 在相位裡:延遲 $n_d$ 個樣本會貢獻一個線性相位因子 $e^{-j\omega n_d}$。事件的先後順序,就編碼在每一團頻譜的相位隨 $\omega$ 傾斜的方式裡(在每個音調附近計算群延遲 $-\,d\angle X/d\omega$,得到的就是那個音調的到達時刻)。(b) 位相の中である。$n_d$ 標本の遅延は線形位相因子 $e^{-j\omega n_d}$ をもたらす。事象の順序は、各スペクトルの塊の位相が $\omega$ に対してどう傾くかに符号化されている(各純音の近傍で群遅延 $-\,d\angle X/d\omega$ を評価すれば、その音の到来時刻が得られる)。
(c) With a window much shorter than 0.5 s, the STFT of $x_1$ shows a ridge at 50 Hz for $t<0.5$ s that jumps to 120 Hz afterwards; $x_2$ shows the mirror pattern. The STFT separates them because each frame sees only one regime — it converts the unreadable phase code into a readable time axis.(c) 用一個遠短於 0.5 秒的視窗,$x_1$ 的 STFT 會在 $t<0.5$ 秒時顯示一道 50 Hz 的脊,之後跳到 120 Hz;$x_2$ 則顯示鏡像的圖樣。STFT 之所以分得開,是因為每個音框只看見一種狀態——它把讀不出來的相位編碼,轉成了讀得出來的時間軸。(c) 0.5 s よりずっと短い窓を使うと、$x_1$ の STFT は $t<0.5$ s のあいだ 50 Hz に尾根を示し、その後 120 Hz へ跳ぶ。$x_2$ はその鏡像の模様になる。各フレームが一つの状態しか見ないので、STFT は両者を分離できる。読み取れない位相の符号を、読み取れる時間軸へ変換しているのである。
Problem: A signal sampled at $f_s=8$ kHz contains two simultaneous tones at 1000 Hz and 1040 Hz. (a) Using a Hann window (mainlobe null-to-null width $8\pi/L$), find the minimum window length $L$ that resolves the two tones, and the corresponding window duration. (b) Would zero-padding the FFT from $N=L$ to $N=8L$ help if $L$ is below your answer? (c) For the rectangular window, what $L$ suffices, and why might you still prefer the Hann window?題目:一個以 $f_s=8$ kHz 取樣的訊號,同時含有 1000 Hz 與 1040 Hz 兩個音調。(a) 使用 Hann 窗(主瓣零點到零點的寬度為 $8\pi/L$),求能分辨這兩個音調的最小窗長 $L$,以及對應的視窗時間長度。(b) 若 $L$ 小於你的答案,把 FFT 從 $N=L$ 補零到 $N=8L$ 有幫助嗎?(c) 改用矩形窗時,$L$ 要多大才夠?又為什麼你仍然可能偏好 Hann 窗?問題:$f_s=8$ kHz で標本化された信号が、1000 Hz と 1040 Hz の二つの純音を同時に含んでいる。(a) Hann 窓(主ローブの零点間幅は $8\pi/L$)を用いるとき、二つの純音を分解できる最小の窓長 $L$ と、それに対応する窓の時間長を求めよ。(b) $L$ が (a) の答えより小さいとき、FFT を $N=L$ から $N=8L$ へゼロ詰めすれば助けになるか。(c) 矩形窓ならどれだけの $L$ で足りるか。またそれでもなお Hann 窓を選びたくなるのはなぜか。
(a) The Hann mainlobe null-to-null width in rad/sample is $8\pi/L$, i.e. in hertz $\Delta f = \frac{8\pi/L}{2\pi}f_s = \frac{4f_s}{L}$. Two equal tones are (just) resolved when their spacing exceeds roughly half the null-to-null width, but the safe design rule is to require the full spacing to exceed the half-width $\frac{4f_s}{L}\cdot\frac12$... To keep it simple use the standard criterion $\Delta f_{\min}\approx 4f_s/L \le 40$ Hz:(a) Hann 窗主瓣零點到零點的寬度,以 rad/sample 計是 $8\pi/L$,換算成赫茲就是 $\Delta f = \frac{8\pi/L}{2\pi}f_s = \frac{4f_s}{L}$。兩個等振幅的音調,在間距大約超過零點到零點寬度的一半時(勉強)可以分辨,但安全的設計規則是要求完整的間距超過半寬 $\frac{4f_s}{L}\cdot\frac12$……為了簡單起見,這裡採用標準判準 $\Delta f_{\min}\approx 4f_s/L \le 40$ Hz:(a) Hann 窓の主ローブの零点間幅は rad/sample で $8\pi/L$、ヘルツに直すと $\Delta f = \frac{8\pi/L}{2\pi}f_s = \frac{4f_s}{L}$ である。振幅の等しい二つの純音は、間隔が零点間幅のおよそ半分を超えたときに(かろうじて)分解される。ただし安全な設計則としては、間隔そのものが半幅 $\frac{4f_s}{L}\cdot\frac12$ を超えることを要求する……ここでは簡単のため、標準的な判定基準 $\Delta f_{\min}\approx 4f_s/L \le 40$ Hz を用いる:
Choose the next power of two, $L=1024$, i.e. a window duration of $1024/8000=128$ ms. (Any consistent mainlobe criterion is acceptable; the scaling $L\propto f_s/\Delta f$ is the point.)取下一個 2 的冪次,$L=1024$,也就是視窗的時間長度為 $1024/8000=128$ ms。(任何一致的主瓣判準都可以接受;重點在於 $L\propto f_s/\Delta f$ 這個比例關係。)次の 2 のべき乗を取って $L=1024$、すなわち窓の時間長は $1024/8000=128$ ms となる。(一貫していればどの主ローブ判定基準でもよい。要点は $L\propto f_s/\Delta f$ というスケーリングである。)
(b) No. Zero-padding evaluates the same windowed spectrum — the convolution of the true line spectrum with the same mainlobe — on a denser grid. If the two mainlobes have already merged into one bump, sampling that bump more finely cannot split it. Only more data (larger $L$) narrows the mainlobe.(b) 不會。補零只是把同一個加窗後的頻譜——也就是真實線譜與同一個主瓣的摺積——放在更密的格點上求值而已。如果兩個主瓣早已合併成一個鼓包,再怎麼細密地取樣這個鼓包也分不開它。只有更多的資料(更大的 $L$)才能把主瓣變窄。(b) 助けにならない。ゼロ詰めは同じ窓かけスペクトル——真の線スペクトルと同じ主ローブとの畳み込み——を、より密な格子の上で評価するだけである。二つの主ローブがすでに一つの山に融合してしまっているなら、その山を細かく標本化しても分けることはできない。主ローブを狭くできるのは、より多くのデータ(より大きな $L$)だけである。
(c) The rectangular mainlobe is $4\pi/L$ (half of Hann's), so $L\ge 2f_s/\Delta f = 400$ samples suffices. But its $-13$ dB sidelobes leak badly: if the two tones have unequal amplitudes (or there is any other strong component), the weaker tone can be buried under the stronger one's sidelobes. Hann's $-31$ dB sidelobes cost a factor of 2 in length but buy 18 dB of dynamic range.(c) 矩形窗的主瓣是 $4\pi/L$(Hann 窗的一半),所以 $L\ge 2f_s/\Delta f = 400$ 個樣本就夠了。但它 $-13$ dB 的旁瓣洩漏得很厲害:如果兩個音調振幅不相等(或還有其他強成分存在),較弱的那個音調可能會被較強者的旁瓣埋掉。Hann 窗 $-31$ dB 的旁瓣,代價是長度要乘以 2,但買到了 18 dB 的動態範圍。(c) 矩形窓の主ローブは $4\pi/L$(Hann 窓の半分)なので、$L\ge 2f_s/\Delta f = 400$ 標本あれば足りる。しかしその $-13$ dB のサイドローブは漏れがひどい。二つの純音の振幅が等しくない場合(あるいは他に強い成分がある場合)、弱いほうの純音が強いほうのサイドローブの下に埋もれてしまう。Hann 窓の $-31$ dB のサイドローブは、長さを 2 倍にする代償と引き換えに 18 dB のダイナミックレンジを買ってくれる。
Problem: A speech signal is sampled at $f_s=10$ kHz. The talker's pitch (fundamental) is $f_0=200$ Hz, so harmonics are spaced 200 Hz apart and glottal pulses occur every $1/f_0 = 5$ ms. Using the Hann resolution rule $\Delta f\approx 4f_s/L$: (a) find the window lengths (samples and ms) for a narrowband spectrogram that clearly resolves the harmonics ($\Delta f \le 100$ Hz). (b) Find the window length for a wideband spectrogram that resolves individual glottal pulses in time ($\Delta t \le 2.5$ ms). (c) Show that no single window can do both, by computing $\Delta t\,\Delta f$ demanded by (a)+(b) and comparing with the uncertainty bound.題目:一段語音訊號以 $f_s=10$ kHz 取樣。說話者的音高(基頻)為 $f_0=200$ Hz,所以諧波彼此相隔 200 Hz,而聲門脈衝每 $1/f_0 = 5$ ms 出現一次。使用 Hann 窗的解析度規則 $\Delta f\approx 4f_s/L$:(a) 求出能清楚分辨諧波($\Delta f \le 100$ Hz)的窄帶頻譜圖所需的窗長(樣本數與毫秒數)。(b) 求出能在時間上分辨個別聲門脈衝($\Delta t \le 2.5$ ms)的寬帶頻譜圖所需的窗長。(c) 計算 (a)+(b) 所要求的 $\Delta t\,\Delta f$ 並與不確定性下界比較,藉此證明沒有任何單一視窗能同時做到這兩件事。問題:ある音声信号が $f_s=10$ kHz で標本化されている。話者のピッチ(基本周波数)は $f_0=200$ Hz なので、高調波は 200 Hz 間隔に並び、声門パルスは $1/f_0 = 5$ ms ごとに生じる。Hann 窓の分解能則 $\Delta f\approx 4f_s/L$ を用いて、(a) 高調波をはっきり分解する($\Delta f \le 100$ Hz)狭帯域スペクトログラムに必要な窓長を標本数と ms で求めよ。(b) 個々の声門パルスを時間的に分解する($\Delta t \le 2.5$ ms)広帯域スペクトログラムに必要な窓長を求めよ。(c) (a)+(b) が要求する $\Delta t\,\Delta f$ を計算して不確定性の下界と比べ、単一の窓では両方を同時に満たせないことを示せ。
(a) Need $4f_s/L\le 100$ Hz $\Rightarrow L\ge 4\cdot10000/100=400$ samples $=40$ ms. A 40 ms Hann window spans 8 pitch periods; harmonics appear as clean horizontal lines, but each glottal event is smeared over 40 ms — this is the narrowband setting.(a) 需要 $4f_s/L\le 100$ Hz $\Rightarrow L\ge 4\cdot10000/100=400$ 個樣本 $=40$ ms。一個 40 ms 的 Hann 窗橫跨 8 個音高週期;諧波會呈現為乾淨的水平線,但每一個聲門事件都被抹散在 40 ms 上——這就是窄帶的設定。(a) $4f_s/L\le 100$ Hz が必要で、$\Rightarrow L\ge 4\cdot10000/100=400$ 標本 $=40$ ms となる。40 ms の Hann 窓はピッチ周期 8 個分にわたる。高調波はきれいな水平線として現れるが、個々の声門事象は 40 ms にわたってにじむ。これが狭帯域の設定である。
(b) Time resolution is the window duration: $\Delta t\approx L/f_s\le 2.5$ ms $\Rightarrow L\le 25$ samples... in practice $L=25$ is extreme; taking $\Delta t = L/f_s = 2.5$ ms gives $L = 25$ samples, and commonly one relaxes to $L\approx 30$–$50$ ($3$–$5$ ms). Each window now spans less than one pitch period: vertical striations mark the glottal pulses — the wideband setting. Its frequency resolution is $4f_s/L\approx 1600$ Hz at $L=25$: individual harmonics merge, and only the broad formant envelope survives.(b) 時間解析度就是視窗的時間長度:$\Delta t\approx L/f_s\le 2.5$ ms $\Rightarrow L\le 25$ 個樣本……實務上 $L=25$ 太極端了;取 $\Delta t = L/f_s = 2.5$ ms 會得到 $L = 25$ 個樣本,而一般會放寬到 $L\approx 30$–$50$($3$–$5$ ms)。現在每個視窗橫跨不到一個音高週期:垂直的紋路標示出聲門脈衝——這就是寬帶的設定。它在 $L=25$ 時的頻率解析度是 $4f_s/L\approx 1600$ Hz:個別的諧波會合併,只剩下寬闊的共振峰包絡。(b) 時間分解能とは窓の時間長そのものである:$\Delta t\approx L/f_s\le 2.5$ ms $\Rightarrow L\le 25$ 標本……実際には $L=25$ は極端である。$\Delta t = L/f_s = 2.5$ ms と取れば $L = 25$ 標本となるが、ふつうは $L\approx 30$–$50$($3$–$5$ ms)まで緩める。こうすると各窓はピッチ周期一つ分にも満たない幅になり、縦縞が声門パルスを示す——これが広帯域の設定である。$L=25$ のときの周波数分解能は $4f_s/L\approx 1600$ Hz であり、個々の高調波は融合して、広いフォルマント包絡だけが残る。
(c) Demanding both simultaneously requires $\Delta t\,\Delta f \le (2.5\ \text{ms})(100\ \text{Hz}) = 0.25$. For a single Hann window the product is fixed: $\Delta t\,\Delta f = \frac{L}{f_s}\cdot\frac{4 f_s}{L} = 4$, independent of $L$ — sixteen times larger than required, and the theoretical floor for any window is $\Delta t\,\Delta f \ge 1/(4\pi)\approx 0.08$ with the practical mainlobe-based product always of order 1. Hence one analysis cannot satisfy both specs; speech researchers simply make two spectrograms, one narrowband and one wideband.(c) 要同時滿足兩者,就必須 $\Delta t\,\Delta f \le (2.5\ \text{ms})(100\ \text{Hz}) = 0.25$。但對單一個 Hann 窗來說,這個乘積是固定的:$\Delta t\,\Delta f = \frac{L}{f_s}\cdot\frac{4 f_s}{L} = 4$,與 $L$ 無關——比要求的大了十六倍;而任何視窗的理論下限都是 $\Delta t\,\Delta f \ge 1/(4\pi)\approx 0.08$,實務上以主瓣為準的乘積則總是在 1 的量級。因此單一次分析無法同時滿足兩項規格;語音研究者乾脆就畫兩張頻譜圖,一張窄帶、一張寬帶。(c) 両方を同時に要求すると $\Delta t\,\Delta f \le (2.5\ \text{ms})(100\ \text{Hz}) = 0.25$ でなければならない。しかし単一の Hann 窓ではこの積は固定されていて $\Delta t\,\Delta f = \frac{L}{f_s}\cdot\frac{4 f_s}{L} = 4$ であり、$L$ によらない。要求の十六倍である。さらにどんな窓であっても理論的な下限は $\Delta t\,\Delta f \ge 1/(4\pi)\approx 0.08$ であり、実用的な主ローブに基づく積は常に 1 のオーダーになる。したがって一回の解析で両方の仕様を満たすことはできない。音声研究者は単純に二枚のスペクトログラム、すなわち狭帯域のものと広帯域のものを作る。
Problem: Using the definition $X(n,\omega)=\sum_m x[m]\,w[m-n]\,e^{-j\omega m}$ with a length-$L$ window $w$ whose DTFT is $W(e^{j\omega})$, derive the STFT of (a) the complex exponential $x[m]=e^{j\omega_0 m}$ and (b) the shifted impulse $x[m]=\delta[m-m_0]$. (c) Interpret both results in terms of the spectrogram image and the tiling picture of Fig. 9-3.題目:使用定義 $X(n,\omega)=\sum_m x[m]\,w[m-n]\,e^{-j\omega m}$,其中視窗 $w$ 的長度為 $L$、其 DTFT 為 $W(e^{j\omega})$,推導 (a) 複數指數訊號 $x[m]=e^{j\omega_0 m}$ 與 (b) 平移脈衝 $x[m]=\delta[m-m_0]$ 的 STFT。(c) 用頻譜圖影像以及圖 9-3 的鋪磚圖像來詮釋這兩個結果。問題:定義 $X(n,\omega)=\sum_m x[m]\,w[m-n]\,e^{-j\omega m}$ を用いる。窓 $w$ の長さは $L$、その DTFT を $W(e^{j\omega})$ とする。(a) 複素指数信号 $x[m]=e^{j\omega_0 m}$ と、(b) 平行移動したインパルス $x[m]=\delta[m-m_0]$ の STFT を導け。(c) 二つの結果を、スペクトログラムの画像と図 9-3 のタイル分割の描像によって解釈せよ。
(a) Substitute and change variable $r=m-n$:(a) 代入後做變數變換 $r=m-n$:(a) 代入して変数変換 $r=m-n$ を行うと、
Magnitude: $|X(n,\omega)|=|W(e^{j(\omega-\omega_0)})|$ for every $n$ — a horizontal ridge at $\omega_0$ whose cross-section is the window spectrum (mainlobe width sets the ridge thickness, sidelobes appear as faint parallel stripes).振幅:對每一個 $n$ 都有 $|X(n,\omega)|=|W(e^{j(\omega-\omega_0)})|$——這是一道位在 $\omega_0$ 的水平脊,它的截面就是視窗的頻譜(主瓣寬度決定脊的厚度,旁瓣則表現為淡淡的平行條紋)。振幅はすべての $n$ について $|X(n,\omega)|=|W(e^{j(\omega-\omega_0)})|$ となる。すなわち $\omega_0$ に水平な尾根が立ち、その断面は窓のスペクトルである(主ローブ幅が尾根の太さを決め、サイドローブは淡い平行縞として現れる)。
(b) The sum collapses at $m=m_0$:(b) 這個和在 $m=m_0$ 處塌縮:(b) 和は $m=m_0$ で潰れて、
A vertical stripe at times $n$ near $m_0$, identical at all frequencies, whose cross-section along $n$ is the (reversed) window shape — width $=$ window length.這是一道垂直條紋,出現在 $m_0$ 附近的那些時刻 $n$ 上,而且在所有頻率上都一樣;它沿著 $n$ 的截面就是(反轉後的)視窗形狀——寬度 $=$ 窗長。$m_0$ の近くの時刻 $n$ に立つ縦縞であり、すべての周波数で同一である。$n$ に沿った断面は(時間反転した)窓の形そのもので、幅 $=$ 窓長である。
(c) The tone (a horizontal line in the ideal time–frequency plane) is blurred vertically by the window's frequency width $\Delta f$; the impulse (a vertical line) is blurred horizontally by the window's duration $\Delta t$. Every signal feature is smeared by exactly one tile of Fig. 9-3 — the STFT renders the time–frequency plane at the resolution of its window, no finer.(c) 音調(在理想的時頻平面上是一條水平線)被視窗的頻率寬度 $\Delta f$ 在垂直方向上糊開;脈衝(一條垂直線)則被視窗的時間長度 $\Delta t$ 在水平方向上糊開。每一個訊號特徵都正好被抹散成圖 9-3 的一塊磚——STFT 是以它所用視窗的解析度來描繪時頻平面的,不會更細。(c) 純音(理想的な時間周波数平面では水平な一本の線)は、窓の周波数幅 $\Delta f$ によって垂直方向にぼかされる。インパルス(垂直な一本の線)は、窓の時間長 $\Delta t$ によって水平方向にぼかされる。どの信号の特徴も、ちょうど図 9-3 のタイル一つ分だけ広がる。STFT は時間周波数平面を自らの窓の分解能で描き出すのであって、それより細かくは描けない。
Problem: An audio clip has $L_x=480{,}000$ samples ($f_s=48$ kHz, 10 s). The STFT uses a periodic Hann window $w[n]=\tfrac12(1-\cos\frac{2\pi n}{N})$, $N=1024$, hop $M=N/2=512$. (a) How many complete frames are computed, and what is the spacing of the spectrogram's time axis? (b) Prove the COLA property $\sum_m w[n-mM]=1$ for this window at $M=N/2$. (c) What constant results at $M=N/4$, and how must overlap-add synthesis account for it?題目:一段音訊有 $L_x=480{,}000$ 個樣本($f_s=48$ kHz,10 秒)。STFT 使用週期性 Hann 窗 $w[n]=\tfrac12(1-\cos\frac{2\pi n}{N})$,$N=1024$,跳距 $M=N/2=512$。(a) 會算出多少個完整的音框?頻譜圖時間軸的間距又是多少?(b) 證明這個視窗在 $M=N/2$ 時具有 COLA 性質 $\sum_m w[n-mM]=1$。(c) 在 $M=N/4$ 時得到的常數是多少?重疊相加合成又該如何處理它?問題:ある音声クリップは $L_x=480{,}000$ 標本をもつ($f_s=48$ kHz、10 秒)。STFT には周期 Hann 窓 $w[n]=\tfrac12(1-\cos\frac{2\pi n}{N})$、$N=1024$、ホップ $M=N/2=512$ を用いる。(a) 完全なフレームはいくつ計算されるか。またスペクトログラムの時間軸の間隔はいくらか。(b) この窓が $M=N/2$ において COLA 性質 $\sum_m w[n-mM]=1$ を満たすことを証明せよ。(c) $M=N/4$ ではどのような定数になるか。また重畳加算による合成ではそれをどう扱わねばならないか。
(a) $N_{\text{frames}}=\bigl\lfloor (L_x-N)/M \bigr\rfloor+1 =\bigl\lfloor (480000-1024)/512\bigr\rfloor+1 = 935+1 = 936$ frames. Time spacing $M/f_s = 512/48000 \approx 10.7$ ms per column.(a) $N_{\text{frames}}=\bigl\lfloor (L_x-N)/M \bigr\rfloor+1 =\bigl\lfloor (480000-1024)/512\bigr\rfloor+1 = 935+1 = 936$ 個音框。時間間距為每一欄 $M/f_s = 512/48000 \approx 10.7$ ms。(a) $N_{\text{frames}}=\bigl\lfloor (L_x-N)/M \bigr\rfloor+1 =\bigl\lfloor (480000-1024)/512\bigr\rfloor+1 = 935+1 = 936$ フレームである。時間間隔は 1 列あたり $M/f_s = 512/48000 \approx 10.7$ ms となる。
(b) At hop $M=N/2$, sample $n$ is covered by exactly two shifted windows, at offsets $r$ and $r+N/2$ where $r\equiv n \pmod{N/2}$, $0\le r<N/2$:(b) 在跳距 $M=N/2$ 之下,樣本 $n$ 恰好被兩個平移後的視窗覆蓋,偏移量分別是 $r$ 與 $r+N/2$,其中 $r\equiv n \pmod{N/2}$、$0\le r<N/2$:(b) ホップ $M=N/2$ のとき、標本 $n$ はちょうど二つのずらした窓に覆われる。そのオフセットは $r$ と $r+N/2$ であり、ここで $r\equiv n \pmod{N/2}$、$0\le r<N/2$ である。
where $c=\cos(2\pi r/N)$; the shifted cosine flips sign and the pair sums to exactly 1
for every $n$. (Note this uses the periodic Hann definition with denominator $N$,
exactly the formula in dsp10.m — the "symmetric" Hann with denominator $N-1$
violates COLA slightly.)其中 $c=\cos(2\pi r/N)$;平移後的餘弦會變號,因此這一對對每一個 $n$ 相加都恰好等於 1。(注意這裡用的是分母為 $N$ 的週期性 Hann 定義,正是 dsp10.m 裡的那條公式——分母為 $N-1$ 的「對稱」Hann 窗會稍微違反 COLA。)ここで $c=\cos(2\pi r/N)$ である。ずらしたほうの余弦は符号が反転するので、この二つの和はどの $n$ についてもちょうど 1 になる。(ここで用いているのは分母が $N$ の周期 Hann の定義であり、まさに dsp10.m にある式である。分母が $N-1$ の「対称」Hann 窓は COLA をわずかに破る。)
(c) At $M=N/4$ each sample is covered by four windows at phases $\theta, \theta+\tfrac\pi2, \theta+\pi, \theta+\tfrac{3\pi}2$. The four cosines cancel in pairs, leaving $\sum_m w[n-mM] = 4\cdot\tfrac12 = 2$. OLA synthesis then returns $y[n]=2x[n]$, so the output must be divided by $C=2$ (in general by $C = \sum_m w[-mM]$) for unit gain.(c) 在 $M=N/4$ 時,每個樣本被四個視窗覆蓋,相位分別是 $\theta, \theta+\tfrac\pi2, \theta+\pi, \theta+\tfrac{3\pi}2$。這四個餘弦兩兩相消,剩下 $\sum_m w[n-mM] = 4\cdot\tfrac12 = 2$。於是 OLA 合成會回傳 $y[n]=2x[n]$,所以輸出必須除以 $C=2$(一般而言是除以 $C = \sum_m w[-mM]$)才能得到單位增益。(c) $M=N/4$ では各標本が四つの窓に覆われ、その位相は $\theta, \theta+\tfrac\pi2, \theta+\pi, \theta+\tfrac{3\pi}2$ である。四つの余弦は二つずつ打ち消し合い、$\sum_m w[n-mM] = 4\cdot\tfrac12 = 2$ が残る。したがって OLA 合成は $y[n]=2x[n]$ を返すので、利得を 1 にするには出力を $C=2$ で(一般には $C = \sum_m w[-mM]$ で)割らねばならない。
Problem: Write a MATLAB function myspectrogram(x, N, w, M)
that computes the power spectrogram of a signal $x$ with DFT length $N$, window $w$, and
hop $M$, without using the Signal Processing Toolbox. Use it to analyze an audio recording
with a Hann window of length $N=1024$ and 75% overlap ($M=N/4$): plot the waveform, the
window, and the spectrogram in dB with correctly calibrated time/frequency axes. Report
the frequency resolution. (This is the Lecture-9 homework, dsp10.m.)題目:寫一個 MATLAB 函式 myspectrogram(x, N, w, M),在不使用 Signal Processing Toolbox 的情況下,以 DFT 長度 $N$、視窗 $w$、跳距 $M$ 計算訊號 $x$ 的功率頻譜圖。用它來分析一段錄音,視窗取長度 $N=1024$ 的 Hann 窗、重疊 75%($M=N/4$):畫出波形、視窗,以及以 dB 顯示、時間/頻率軸刻度正確的頻譜圖。並報告其頻率解析度。(這就是第 9 講的作業 dsp10.m。)問題:Signal Processing Toolbox を使わずに、DFT 長 $N$、窓 $w$、ホップ $M$ で信号 $x$ のパワースペクトログラムを計算する MATLAB 関数 myspectrogram(x, N, w, M) を書け。これを用いて、長さ $N=1024$ の Hann 窓と 75% の重なり($M=N/4$)で録音を解析し、波形、窓、そして時間軸と周波数軸を正しく較正した dB 表示のスペクトログラムを描け。周波数分解能も報告すること。(これが第 9 講の課題 dsp10.m である。)
Cleaned-up solution code:整理過的解答程式碼:整理した解答コードを示す。
clc; clear; close all;
% Step 1: load audio
[x, Fs] = audioread('guitar4.m4a');
t_audio = (0:length(x)-1) / Fs;
figure; plot(t_audio, x, 'r');
xlabel('Time (s)'); ylabel('Amplitude'); title('Audio Signal');
% Step 2: Hann window, N chosen so Fs/N is around 20-40 Hz
N = 2^10; % DFT length (1024)
w = 0.5 * (1 - cos(2*pi*(0:N-1)'/N)); % periodic Hann window
disp(['Frequency resolution (bin spacing): ', num2str(Fs/N), ' Hz']);
figure; plot(w, 'r');
xlabel('Sample Index'); ylabel('Amplitude'); title('Hann Window');
% Step 3-4: spectrogram with hop M = N/4 (75% overlap)
M = N/4;
X = myspectrogram(x, N, w, M);
num_frames = size(X, 2);
t = (0:num_frames-1) * M / Fs; % frame times
f = (0:N/2-1) * Fs / N; % bin frequencies
% Step 5: display in dB
figure;
image(t, f, 10*log10(X(1:N/2, :)));
axis xy;
xlabel('Time (s)'); ylabel('Frequency (Hz)'); title('Spectrogram');
colormap(hot(256)); colorbar;
function X = myspectrogram(x, N, w, M)
L = length(x);
num_frames = floor((L - N)/M) + 1;
X = zeros(N, num_frames);
for m = 1:num_frames
idx = (m-1)*M + (1:N); % frame indices
X(:, m) = abs(fft(x(idx) .* w)).^2; % window, FFT, power
end
end
Key design points:幾個關鍵的設計要點:設計上の要点は次のとおりである。
axis xy puts 0 Hz at the
bottom.座標軸:第 $m$ 欄位在 $t=mM/f_s$,第 $k$ 列位在 $f=kf_s/N$;對實數訊號只顯示 $k<N/2$ 這些列,而 axis xy 把 0 Hz 放在底部。軸:第 $m$ 列は $t=mM/f_s$ に、第 $k$ 行は $f=kf_s/N$ に置かれる。実信号では $k<N/2$ の行だけを表示し、axis xy によって 0 Hz が下端に来る。Result regenerated below with the identical pipeline (Hann $N=1024$, $M=256$) in NumPy:下面是用 NumPy 以完全相同的流程(Hann 窗,$N=1024$,$M=256$)重新產生的結果:以下は NumPy でまったく同じ流れ(Hann 窓、$N=1024$、$M=256$)を再現した結果である。
myspectrogram pipeline rerun on a synthetic guitar-like signal (three exponentially decaying harmonic "plucks" — G3 196 Hz, B3 246.9 Hz, E4 329.6 Hz — at $t=0,1,2$ s, $f_s=8$ kHz), since the original guitar4.m4a recording is not available here. Each pluck appears as a stack of harmonic lines starting at its onset and fading as the note decays — exactly the structure the homework observes on the real recording.(原始音檔不在手邊,故以合成撥弦訊號重現同一流程;諧波線、起音時刻與衰減皆清晰可見。)圖 9-7 — 由於原始的 guitar4.m4a 錄音在此不可得,myspectrogram 的流程改在一個合成的類吉他訊號上重跑(三次指數衰減的諧波「撥弦」——G3 196 Hz、B3 246.9 Hz、E4 329.6 Hz——分別落在 $t=0,1,2$ 秒,$f_s=8$ kHz)。每一次撥弦都呈現為一疊諧波線,從起音時刻開始、隨著音的衰減而淡去——正是作業在真實錄音上所觀察到的結構。(原始音檔不在手邊,故以合成撥弦訊號重現同一流程;諧波線、起音時刻與衰減皆清晰可見。)図 9-7 — 元の guitar4.m4a の録音がここでは入手できないため、myspectrogram のパイプラインを合成したギター風の信号で再実行した(指数的に減衰する三つの高調波「撥弦」——G3 196 Hz、B3 246.9 Hz、E4 329.6 Hz——をそれぞれ $t=0,1,2$ s、$f_s=8$ kHz に置いたもの)。各撥弦は立ち上がりの時刻から始まる高調波の線の積み重なりとして現れ、音の減衰とともに薄れていく。まさに課題が実際の録音で観察している構造である。