Time/Frequency analysis¶
In signal processing, time–frequency analysis comprises those techniques that study a signal in both the time and frequency domains simultaneously, using various time–frequency representations. Rather than viewing a 1-dimensional signal (a function, real or complex-valued, whose domain is the real line) and some transform (another function whose domain is the real line, obtained from the original via some transform), time–frequency analysis studies a two-dimensional signal – a function whose domain is the two-dimensional real plane, obtained from the signal via a time–frequency transform. More on wikipedia
Goals¶
Our goals here are pretty straight forward :
- To play with audio signal in python with the
librosa
library - To visualise audio signal with the
matplotlib
library - To understand how mechanical signals are converted into digital ones (aka time/frequency domain pipeline)
- To understand the audio data filtering process (aka framming and windowing)
- To extract the amplitude envelope of an audio signal
In [32]:
Copied!
!pip install librosa
!pip install librosa
Requirement already satisfied: librosa in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (0.10.1) Requirement already satisfied: typing-extensions>=4.1.1 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from librosa) (4.7.1) Requirement already satisfied: msgpack>=1.0 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from librosa) (1.0.0) Requirement already satisfied: soundfile>=0.12.1 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from librosa) (0.12.1) Requirement already satisfied: audioread>=2.1.9 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from librosa) (3.0.1) Requirement already satisfied: soxr>=0.3.2 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from librosa) (0.3.7) Requirement already satisfied: lazy-loader>=0.1 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from librosa) (0.3) Requirement already satisfied: scipy>=1.2.0 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages/scipy-1.4.1-py3.7-macosx-10.15-x86_64.egg (from librosa) (1.4.1) Requirement already satisfied: numba>=0.51.0 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from librosa) (0.56.4) Requirement already satisfied: pooch>=1.0 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from librosa) (1.8.1) Requirement already satisfied: scikit-learn>=0.20.0 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages/scikit_learn-0.22.2.post1-py3.7-macosx-10.15-x86_64.egg (from librosa) (0.22.2.post1) Requirement already satisfied: decorator>=4.3.0 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from librosa) (4.4.2) Requirement already satisfied: joblib>=0.14 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages/joblib-0.14.1-py3.7.egg (from librosa) (0.14.1) Requirement already satisfied: numpy!=1.22.0,!=1.22.1,!=1.22.2,>=1.20.3 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from librosa) (1.21.6) Requirement already satisfied: setuptools in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from numba>=0.51.0->librosa) (49.6.0) Requirement already satisfied: importlib-metadata in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from numba>=0.51.0->librosa) (6.7.0) Requirement already satisfied: llvmlite<0.40,>=0.39.0dev0 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from numba>=0.51.0->librosa) (0.39.1) Requirement already satisfied: requests>=2.19.0 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pooch>=1.0->librosa) (2.31.0) Requirement already satisfied: platformdirs>=2.5.0 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pooch>=1.0->librosa) (4.0.0) Requirement already satisfied: packaging>=20.0 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pooch>=1.0->librosa) (23.2) Requirement already satisfied: cffi>=1.0 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from soundfile>=0.12.1->librosa) (1.14.0) Requirement already satisfied: pycparser in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from cffi>=1.0->soundfile>=0.12.1->librosa) (2.20) Requirement already satisfied: idna<4,>=2.5 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages/idna-2.8-py3.7.egg (from requests>=2.19.0->pooch>=1.0->librosa) (2.8) Requirement already satisfied: certifi>=2017.4.17 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from requests>=2.19.0->pooch>=1.0->librosa) (2023.11.17) Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from requests>=2.19.0->pooch>=1.0->librosa) (2.0.7) Requirement already satisfied: charset-normalizer<4,>=2 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from requests>=2.19.0->pooch>=1.0->librosa) (3.3.2) Requirement already satisfied: zipp>=0.5 in /Users/mac/.pyenv/versions/3.7.0/lib/python3.7/site-packages/zipp-3.1.0-py3.7.egg (from importlib-metadata->numba>=0.51.0->librosa) (3.1.0) [notice] A new release of pip is available: 23.0.1 -> 24.0 [notice] To update, run: pip install --upgrade pip
In [33]:
Copied!
import matplotlib.pyplot as plt
import numpy as np
import librosa
import librosa.display
import IPython.display as ipd
import matplotlib.pyplot as plt
import numpy as np
import librosa
import librosa.display
import IPython.display as ipd
In [34]:
Copied!
melo_file = "./files/94_Melo.wav"
melo_file = "./files/94_Melo.wav"
In [35]:
Copied!
ipd.Audio(melo_file)
ipd.Audio(melo_file)
Out[35]: