Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- def subband_filtering(x, h):
- """ ASSIGNMENT 3
- Write a routine to implement the efficient version of the subband filter
- as specified by the MP3 standard
- Arguments:
- x: a new 512-point data buffer, in time-reversed order [x[n],x[n-1],...,x[n-511]].
- h: The prototype filter of the filter bank you found in the previous assignment
- Returns:
- s: 32 new output samples
- """
- # Time reverse input and muliply by filter response
- r = np.multiply(h,x)
- # Reshape for further processing into 64 sub
- r = r.reshape(-1,64)
- # The weights, in this case only of size 8 : -1 1 -1 1 ...
- weights = np.array([1,-1]*4)
- # do the sum(weights * r[:,q] for q in range(8)) with a matrix multiplication
- c = np.dot(np.transpose(r),weights)
- # generate two coordintes, ii and qq, which just loop over the array
- ii , qq = np.ogrid[:32,:c.shape[0]]
- # Do \sum cos(....) * c[q], but with .dot
- s = np.squeeze(np.dot(np.cos(np.pi / 64 * (2*ii +1)*(qq -16)),c[qq].transpose()))
- return s
Add Comment
Please, Sign In to add comment