Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/audio/spectrogram.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ See [`stft`](@ref) for other arguments.
Spectrogram in the shape `(T, F, B)`, where
`T` is the number of window hops and `F = n_fft ÷ 2 + 1`.
"""
function spectrogram(waveform;
function spectrogram(waveform::AbstractArray{T};
pad::Int = 0, n_fft::Int, hop_length::Int, window,
center::Bool = true, power::Real = 2.0,
normalized::Bool = false, window_normalized::Bool = false,
)
) where T
pad > 0 && (waveform = pad_zeros(waveform, pad; dims=1);)

# Pack batch dimensions.
Expand All @@ -41,8 +41,8 @@ function spectrogram(waveform;
window_normalized && (spec = spec .* inv(norm(window));)

if power > 0
p = eltype(waveform)(power)
spec = abs.(spec).^p
p = T(power)
spec = abs.(spec .+ eps(T)).^p
end
return spec
end
Expand Down
Loading