Skip to content

Commit

Permalink
Merge pull request #14 from r9y9/synthesis-filters
Browse files Browse the repository at this point in the history
Synthesis filters
  • Loading branch information
r9y9 committed Sep 5, 2015
2 parents 93f4fbd + 12e4b86 commit cec6999
Show file tree
Hide file tree
Showing 10 changed files with 1,044 additions and 25 deletions.
7 changes: 5 additions & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
API
===
SPTK API
========

All functionality in ``pysptk.sptk`` is directly accesible from the top-level ``pysptk.*`` namespace.

.. note:: Almost all of pysptk functions assume that the input array is **C-contiguous** and has ``float64`` element type.

.. automodule:: pysptk.sptk


.. automodule:: pysptk.conversion
27 changes: 14 additions & 13 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
]

autosummary_generate = True
numpydoc_show_class_members = False

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down Expand Up @@ -217,25 +218,25 @@
# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Additional stuff for the LaTeX preamble.
#'preamble': '',

# Latex figure (float) alignment
#'figure_align': 'htbp',
# Latex figure (float) alignment
#'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'pysptk.tex', u'pysptk Documentation',
u'Ryuichi YAMAMOTO', 'manual'),
(master_doc, 'pysptk.tex', u'pysptk Documentation',
u'Ryuichi YAMAMOTO', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -278,9 +279,9 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'pysptk', u'pysptk Documentation',
author, 'pysptk', 'One line description of project.',
'Miscellaneous'),
(master_doc, 'pysptk', u'pysptk Documentation',
author, 'pysptk', 'One line description of project.',
'Miscellaneous'),
]

# Documents to append as an appendix to all manuals.
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ API documentation
:maxdepth: 2

api
synthesis



Expand Down
4 changes: 4 additions & 0 deletions docs/synthesis.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
High-level interface for waveform synthesis
===========================================

.. automodule:: pysptk.synthesis
11 changes: 9 additions & 2 deletions pysptk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
<https://github.com/r9y9/SPTK>`_)
"""

from __future__ import print_function
from __future__ import absolute_import
from __future__ import division, print_function, absolute_import

import pkg_resources

Expand All @@ -33,6 +32,11 @@ def assert_pade(pade):
raise ValueError("4 or 5 pade approximation is supported")


def assert_stage(stage):
if stage < 1:
raise ValueError("stage >= 1 (-1 <= gamma < 0)")


def ispow2(num):
return ((num & (num - 1)) == 0) and num != 0

Expand All @@ -43,3 +47,6 @@ def assert_fftlen(fftlen):


from .sptk import * # pylint: disable=wildcard-import

from . import synthesis
from .conversion import mgc2b
60 changes: 60 additions & 0 deletions pysptk/conversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# coding: utf-8

"""
Other conversions
-----------------
.. autosummary::
:toctree: generated/
mgc2b
"""

from __future__ import division, print_function, absolute_import

import numpy as np

from pysptk.sptk import mc2b, gnorm


def mgc2b(mgc, alpha=0.35, gamma=0.0):
"""Mel-generalized cepstrum to MGCLSA filter coefficients
Parameters
----------
mgc : array, shape
Mel-generalized cepstrum
alpha : float
All-pass constant. Default is 0.35.
gamma : float
Parameter of generalized log function. Default is 0.0.
Returns
-------
b : array, shape(same as `mgc`)
MGLSA filter coefficients
See Also
--------
pysptk.sptk.mlsadf
pysptk.sptk.mglsadf
pysptk.sptk.mc2b
pysptk.sptk.b2mc
pysptk.sptk.mcep
pysptk.sptk.mgcep
pysptk.sptk.mgcep
"""

b = mc2b(mgc, alpha)
if gamma == 0:
return b

b = gnorm(b, gamma)

b[0] = np.log(b[0])
b[1:] *= gamma

return b

0 comments on commit cec6999

Please sign in to comment.