Skip to content

Commit

Permalink
Initial istft implementation. Has to be optimized with type informati…
Browse files Browse the repository at this point in the history
…on and FFT plans.
  • Loading branch information
jfsantos committed Nov 10, 2014
1 parent 0274d36 commit a29dbbb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ function hilbert{T<:Real}(x::AbstractArray{T})
out
end

function istft(S, wlen, winc; nfft=nextfastfft(wlen), window::Union(Function,AbstractVector,Nothing)=nothing)
win, norm2 = DSP.Periodograms.compute_window(window, wlen)
win² = win.^2
nframes = size(S,2)-1
outlen = nfft + nframes*winc
out = zeros(outlen)
wsum = zeros(outlen)
for k = 1:size(S,2)
out[1+(k-1)*winc:((k-1)*winc+wlen)] += irfft(S[:,k], wlen).*win
wsum[1+(k-1)*winc:((k-1)*winc+wlen)] += win²
end
pos = wsum .!= 0
out[pos] ./= wsum[pos]
out
end

## FFT TYPES

# Get the input element type of FFT for a given type
Expand Down

0 comments on commit a29dbbb

Please sign in to comment.