def mt_deconvolve(data_a, data_b, delta, nfft=None, time_bandwidth=None,
                  number_of_tapers=None, weights="adaptive", demean=True,
                  fmax=0.0):
    npts = len(data_a)
    if len(data_b) != npts:
        raise ValueError("Input arrays must have the same length!")
    if nfft is None:
        nfft = npts
    elif nfft < npts:
        raise ValueError("nfft must be larger then the number of samples in "
                         "the array.")
    mt = _MtspecType("float32")
    if number_of_tapers is None:
        number_of_tapers = int(2 * time_bandwidth) - 1
    data_a = np.require(data_a, mt.float, requirements=[mt.order])
    data_b = np.require(data_b, mt.float, requirements=[mt.order])
    nf = nfft // 2 + 1
    if demean:
        demean = 1
    else:
        demean = 0
    if weights == "constant":
        adaptive = 1
    elif weights == "adaptive":
        adaptive = 0
    else:
        raise ValueError('Weights must be either "adaptive" or "constant".')
    tfun = mt.empty(nfft)
    freq = mt.empty(nf)
    spec_ratio = mt.empty(nf)
    speci = mt.empty(nf)
    specj = mt.empty(nf)
    mtspeclib.mt_deconv_(
        C.byref(C.c_int(int(npts))),
        C.byref(C.c_int(int(nfft))),
        C.byref(C.c_float(float(delta))),
        mt.p(data_a),
        mt.p(data_b),
        C.byref(C.c_float(float(time_bandwidth))),
        C.byref(C.c_int(int(number_of_tapers))),
        C.byref(C.c_int(int(nf))),
        C.byref(C.c_int(adaptive)),
        mt.p(freq),
        mt.p(tfun),
        mt.p(spec_ratio),
        mt.p(speci),
        mt.p(specj),
        C.byref(C.c_int(demean)),
        C.byref(C.c_float(fmax)))
    return {
        "frequencies": freq,
        "deconvolved": tfun,
        "spectral_ratio": spec_ratio,
        "spectrum_a": speci,
        "spectrum_b": specj
    }