-
Notifications
You must be signed in to change notification settings - Fork 11
/
mgc2b.jl
48 lines (39 loc) · 1.2 KB
/
mgc2b.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# mgc2b converts mel generalized cesptrum to MGLSADF filter coefficients.
# TODO: consider `otype` optional argument?
function mgc2b!(mgc::AbstractVector, α, γ)
b = mgc
mc2b!(b, α)
# when gamma = 0, mel-generalized cespstrum corresponds to mel cepstrum
γ == zero(γ) && return mgc
gnorm!(b, γ)
# scale by gamma
b[1] = log(b[1])
for i=2:length(b)
@inbounds b[i] *= γ
end
b
end
mgc2b(mgc::AbstractVector, α=0.35, γ=0.0) = mgc2b!(copy(mgc), α, γ)
function mgc2b!{T<:MelGeneralizedCepstrum}(state::SpectralParamState{T})
assert_not_ready_to_filt(state)
@assert has_loggain(state)
γ = glog_gamma(paramdef(state))
if γ == zero(γ)
@assert gain_normalized(state)
else
@assert !gain_normalized(state)
end
def = paramdef(state)
α = allpass_alpha(def)
γ = glog_gamma(def)
data = rawdata(state)
state.data = mgc2b!(data, α, γ)
state.has_loggain = true
state.gain_normalized = true
state.ready_to_filt = true
state
end
# mgc is assumed not to be gamma scaled (TODO: handle this explicitly?)
function mgc2b{T<:MelGeneralizedCepstrum}(state::SpectralParamState{T})
mgc2b!(copy(state))
end