diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 923156a..e0cabbf 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -53,7 +53,7 @@ "state": { "type": "markdown", "state": { - "file": "00. Inbox/使用librosa做FFT.md", + "file": "00. Inbox/使用 librosa 做 FFT.md", "mode": "source", "source": true } @@ -126,7 +126,7 @@ "state": { "type": "backlink", "state": { - "file": "00. Inbox/使用librosa做FFT.md", + "file": "00. Inbox/使用 librosa 做 FFT.md", "collapseAll": false, "extraContext": false, "sortOrder": "alphabetical", @@ -151,7 +151,7 @@ "state": { "type": "outline", "state": { - "file": "00. Inbox/使用librosa做FFT.md" + "file": "00. Inbox/使用 librosa 做 FFT.md" } } }, @@ -179,7 +179,7 @@ "state": { "type": "file-properties", "state": { - "file": "00. Inbox/使用librosa做FFT.md" + "file": "00. Inbox/使用 librosa 做 FFT.md" } } } @@ -224,9 +224,13 @@ }, "active": "540ef396474d1c8b", "lastOpenFiles": [ + "00. Inbox/使用 librosa 做 mel spectrogram.md", + "attachments/Pasted image 20231212181946.png", + "00. Inbox/使用 librosa 做 FFT.md", + "attachments/Pasted image 20231212181543.png", + "00. Inbox/Mel spectrogram.md", + "attachments/Pasted image 20231212180917.png", "05. 資料收集/libsndfile.md", - "00. Inbox/使用librosa做FFT.md", - "00. Inbox/mel spectrogram.md", "00. Inbox/SSIM.md", "00. Inbox/Brown noise.md", "00. Inbox/White noise.md", @@ -251,8 +255,6 @@ "00. Inbox/01. TODO.md", "05. 資料收集/架站/Storj.md", "01. 個人/01. Daily/2023/11/2023-11-23(週四).md", - "00. Inbox/Habit Tracker.md", - "01. 個人/01. Daily/2023/11/2023-11-22(週三).md", "01. 個人/01. Daily/2023/10", "00. Inbox/vc-fwUpdate code trace(Meetup).canvas", "01. 個人/01. Daily/2023/09", @@ -270,9 +272,6 @@ "attachments/Pasted image 20230426213640.png", "attachments/Pasted image 20230426213616.png", "attachments/Pasted image 20230426213611.png", - "attachments/Pasted image 20230426213547.png", - "attachments/Pasted image 20230426213534.png", - "attachments/Pasted image 20230426213513.png", - "attachments/Pasted image 20230418111538.png" + "attachments/Pasted image 20230426213547.png" ] } \ No newline at end of file diff --git a/00. Inbox/使用 librosa 做 FFT.md b/00. Inbox/使用 librosa 做 FFT.md new file mode 100644 index 0000000..dea57d8 --- /dev/null +++ b/00. Inbox/使用 librosa 做 FFT.md @@ -0,0 +1,27 @@ + +```python +import numpy as np +n_fft=2048 +ft = np.abs(librosa.stft(y[:n_fft], hop_length=n_fft+l)) +plt.plot(ft) +plt.title('Spectrum') +plt.xlabel('Frequency Bin') +plt.ylabel('Amp1itude') +``` + +output e.g.: +![[Pasted image 20231212180917.png]] + +這時候 Y 軸是 amplitude,可以使用 `librosa.amplitude_to_db()` 來把 amplitude 轉為 db。 + +```python +import librosa.display +spec = np.abs(librosa.stft(y, hop_1ength=512)) +spec = librosa.amplitude_to_db(spec, ref=np.max) +librosa.display.specshow(spec, sr=sr, x_axis='time', y_axis='log') +p1t.colorbar(format='%+2.0f dB') +plt.title( 'Spectrogram') +``` + +Output: +![[Pasted image 20231212181543.png]] \ No newline at end of file diff --git a/00. Inbox/使用 librosa 做 mel spectrogram.md b/00. Inbox/使用 librosa 做 mel spectrogram.md new file mode 100644 index 0000000..7d62bfd --- /dev/null +++ b/00. Inbox/使用 librosa 做 mel spectrogram.md @@ -0,0 +1,13 @@ +由於人類會對低頻低音高的片段更感興趣,所以會對通過 FFT 變換得到的 Amplitude 和 Frequency。 +[[Mel spectrogram]] 和 spectrogram 的差別就是 mel spectrogram 的頻率是 mel scale 變換後的頻率(你可以想像把Spectrogram整體往下壓) + +```python +mel_spect = librosa.feature.melspectrogram(y=y, sr=sr, n fft=2048, hop_Iength=1024) +mel_spect = librosa.power_to_db(mel_spect, ref=np.max) +librosa.display.specshow(mel_spect, y_axis='mel', fmax=8000, x_axis='time') +plt.title('Mel Spectrogram') +p1t.colorbar(format='%+2.0f dB') +``` + +Output: +![[Pasted image 20231212181946.png]] \ No newline at end of file diff --git a/00. Inbox/使用librosa做FFT.md b/00. Inbox/使用librosa做FFT.md deleted file mode 100644 index e69de29..0000000 diff --git a/attachments/Pasted image 20231212180917.png b/attachments/Pasted image 20231212180917.png new file mode 100644 index 0000000..1c1064d Binary files /dev/null and b/attachments/Pasted image 20231212180917.png differ diff --git a/attachments/Pasted image 20231212181543.png b/attachments/Pasted image 20231212181543.png new file mode 100644 index 0000000..21abdb0 Binary files /dev/null and b/attachments/Pasted image 20231212181543.png differ diff --git a/attachments/Pasted image 20231212181946.png b/attachments/Pasted image 20231212181946.png new file mode 100644 index 0000000..2e0d0e6 Binary files /dev/null and b/attachments/Pasted image 20231212181946.png differ