top of page

DC removal

What problem are you trying to solve?

To perform certain operations on an audio signal in the time domain, we need to transform it into the frequency domain, which is essentially a Fourier transform. The Short-Time Fourier Transform (STFT) function is used to analyze the signal over time at different frequencies. It takes a continuous time signal and divides it into small windows, on which it performs a Fast Fourier Transform (FFT) to obtain the frequencies that make up each small window over time.

How does the code you wrote solve the problem?

Essentially, all the functions we built are helper functions for the main STFT and ISTFT functions:
- STFT:
  - Divide the signal into small windows.
  - Perform FFT on each window separately to obtain the spectral information.
  - Store the results in an STFT matrix.

- ISTFT:
  - Perform IFFT on each spectral window to reconstruct the signal in time.
  - Combine the windows to get the reconstructed signal.
  - Write the reconstructed signal to a WAV file.

What types of inputs does the code receive, and what is expected to see in the output?

Input:
- `input_wav` (str): Path to the WAV file containing the audio signal.
- `window_size` (int, default 2048): Size of the window (number of samples in each window).
- `hop_size` (int, default 512): Distance (in number of samples) between the starts of consecutive windows (i.e., how many samples to shift the window each time).

Output:
- `stft_matrix` (numpy array): Matrix of STFT results.

Explain the parameter names in the code and their roles

- CreateHanningWindow
  - `window_length:` The length of the window (number of samples) for creating the Hanning window.

- FFT & IFFT
  - `N:` The length of the signal (number of samples in the input signal).
  - `even:` The FFT result for the even indices of the signal.
  - `odd:` The FFT result for the odd indices of the signal.
  - `T:` FFT coefficients computed for combining the results of even and odd.

- STFT
  - `sample_rate:` The sampling rate of the original signal.
  - `audio_signal:` The audio signal read from the WAV file.
  - `window:` The Hanning window created with the given size.
  - `num_frames:` The number of windows created from the audio signal.
  - `stft_matrix:` Matrix for storing STFT results (complex matrix).

- ISTFT
  - `num_frames:` The number of windows in the STFT matrix.
  - `expected_signal_length:` The estimated length of the reconstructed signal.
  - `reconstructed_signal:` Array for storing the reconstructed signal.
  - `window:` The Hanning window created with the given size.

Section Title

Section Subtitle

Every website has a story, and your visitors want to hear yours. This space is a great opportunity to give a full background on who you are, what your team does and what your site has to offer. Double click on the text box to start editing your content and make sure to add all the relevant details you want site visitors to know.

If you’re a business, talk about how you started and share your professional journey. Explain your core values, your commitment to customers and how you stand out from the crowd. Add a photo, gallery or video for even more engagement.

bottom of page