Skip to content

Commit

Permalink
Add a utility function to return a dct basis
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnVinyard committed Feb 6, 2018
1 parent d7d1c9b commit 6678d0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion zounds/spectral/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
from frequencyadaptive import FrequencyAdaptive

from functional import \
fft, stft, apply_scale, frequency_decomposition, phase_shift, rainbowgram
fft, stft, apply_scale, frequency_decomposition, phase_shift, rainbowgram, \
dct_basis
7 changes: 7 additions & 0 deletions zounds/spectral/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ def rainbowgram(time_frequency_repr, colormap=cm.rainbow):
return arr


def dct_basis(size):
r = np.arange(size)
basis = np.outer(r, r + 0.5)
basis = np.cos((np.pi / size) * basis)
return basis


def frequency_decomposition(x, sizes):
sizes = sorted(sizes)

Expand Down

0 comments on commit 6678d0f

Please sign in to comment.