I basically want to use a digital wavelet transform to get the high frequencies of an audio signal and get the time information or really anything that can make me understand where they happen so I can compare with the data I get by reading the audio so I can perform some operations on the samples that have a high frequency.

I'm new to signal processing but I have studied a scientific paper that used DWT for that and I want to try to replicate that idea.

Yes I have studied DWT and what got me into it was the fact that you can get time information from it, as far as I understand. And I know about the coefficients but I don't know what to do with them exactly.

For all that, I'm using scipy to read a wav file and getting "data" that I suppose is the amplitude of every sample, the scipy.io.wavfile.read documentation doesn't make that clear). For the DWT itself, I'm using PyWavelets.

This is what I have right now (adapted):

from scipy.io import wavfile
import numpy as np
import pywt

sample_rate, data = wavfile.read('test.wav')

coefficientsApproximation, coefficientsDetail = pywt.dwt(data, 'db1')

coefficientsApproximation = np.array(coefficientsApproximation)
coefficientsDetail = np.array(coefficientsDetail)

The length of data is the number of samples. If I divide it by the sample rate I get the length of the audio in seconds, as expected.

The data itself is presented like this:

array([[ 19,  20],
       [ 19,  19],
       [ 20,  19],
       [-84, -84],
       [-75, -75],
       [-74, -74]], dtype=int16)

Which is a 2D numpy array (2D because the audio is stereo, but don't focus on that cause I'm also working with mono).

coefficientsDetail is presented like this:

       [ 0.        ],
       [ 0.70710678],
       [ 0.        ],
       [ 0.        ],
       [ 0.        ]])

Which is again a 2D numpy array.

coefficientsApproximation is presented similarly:

array([[  27.57716447],
       [  26.87005769],
       [  27.57716447],

I want to use the information of WHERE are the high frequencies happening so that I can actually change the data variable based on that (e.g. change all the values related to a high frequency to 20). I tried to find a way to use the values of coefficientsDetail in order to do that but I wasn't able to do it.


1 Answer 1


Any highpass filter will give you high frequency time information.

A standard method for analysing and processing audio is a windowed/overlapped fft filterbank. I would suggest using that as a starting point as you will find more references and code snippets and litterature. Then, if you want to achieve something more specific, wavelets may well be the choice.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.