Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/ext/py-phasevoc.c

    r965adee r3821415  
    11#include "aubio-types.h"
    22
    3 static char Py_pvoc_doc[] = "pvoc object";
     3static char Py_pvoc_doc[] = ""
     4"pvoc(win_s=512, hop_s=256)\n"
     5"\n"
     6"Phase vocoder.\n"
     7"\n"
     8"`pvoc` creates callable object implements a phase vocoder [1]_,\n"
     9"using the tricks detailed in [2]_.\n"
     10"\n"
     11"The call function takes one input of type `fvec` and of size\n"
     12"`hop_s`, and returns a `cvec` of length `win_s//2+1`.\n"
     13"\n"
     14"Parameters\n"
     15"----------\n"
     16"win_s : int\n"
     17"  number of channels in the phase-vocoder.\n"
     18"hop_s : int\n"
     19"  number of samples expected between each call\n"
     20"\n"
     21"Examples\n"
     22"--------\n"
     23">>> x = aubio.fvec(256)\n"
     24">>> pv = aubio.pvoc(512, 256)\n"
     25">>> pv(x)\n"
     26"aubio cvec of 257 elements\n"
     27"\n"
     28"Default values for hop_s and win_s are provided:\n"
     29"\n"
     30">>> pv = aubio.pvoc()\n"
     31">>> pv.win_s, pv.hop_s\n"
     32"512, 256\n"
     33"\n"
     34"A `cvec` can be resynthesised using `rdo()`:\n"
     35"\n"
     36">>> pv = aubio.pvoc(512, 256)\n"
     37">>> y = aubio.cvec(512)\n"
     38">>> x_reconstructed = pv.rdo(y)\n"
     39">>> x_reconstructed.shape\n"
     40"(256,)\n"
     41"\n"
     42"References\n"
     43"----------\n"
     44".. [1] James A. Moorer. The use of the phase vocoder in computer music\n"
     45"   applications. `Journal of the Audio Engineering Society`,\n"
     46"   26(1/2):42–45, 1978.\n"
     47".. [2] Amalia de Götzen, Nicolas Bernardini, and Daniel Arfib. Traditional\n"
     48"   (?) implementations of a phase vocoder: the tricks of the trade.\n"
     49"   In `Proceedings of the International Conference on Digital Audio\n"
     50"   Effects` (DAFx-00), pages 37–44, University of Verona, Italy, 2000.\n"
     51"   (`online version <"
     52"https://www.cs.princeton.edu/courses/archive/spr09/cos325/Bernardini.pdf"
     53">`_).\n"
     54"";
     55
    456
    557typedef struct
     
    3991  self->hop_s = Py_default_vector_length/2;
    4092
    41   if (self == NULL) {
    42     return NULL;
    43   }
    44 
    4593  if (win_s > 0) {
    4694    self->win_s = win_s;
     
    122170static PyMemberDef Py_pvoc_members[] = {
    123171  {"win_s", T_INT, offsetof (Py_pvoc, win_s), READONLY,
    124     "size of the window"},
     172    "int: Size of phase vocoder analysis windows, in samples.\n"
     173    ""},
    125174  {"hop_s", T_INT, offsetof (Py_pvoc, hop_s), READONLY,
    126     "size of the hop"},
     175    "int: Interval between two analysis, in samples.\n"
     176    ""},
    127177  { NULL } // sentinel
    128178};
     
    176226static PyMethodDef Py_pvoc_methods[] = {
    177227  {"rdo", (PyCFunction) Py_pvoc_rdo, METH_VARARGS,
    178     "synthesis of spectral grain"},
    179   {"set_window", (PyCFunction) Pyaubio_pvoc_set_window, METH_VARARGS, ""},
     228    "rdo(fftgrain)\n"
     229    "\n"
     230    "Read a new spectral grain and resynthesise the next `hop_s`\n"
     231    "output samples.\n"
     232    "\n"
     233    "Parameters\n"
     234    "----------\n"
     235    "fftgrain : cvec\n"
     236    "    new input `cvec` to synthesize from, should be of size `win_s/2+1`\n"
     237    "\n"
     238    "Returns\n"
     239    "-------\n"
     240    "fvec\n"
     241    "    re-synthesised output of shape `(hop_s,)`\n"
     242    "\n"
     243    "Example\n"
     244    "-------\n"
     245    ">>> pv = aubio.pvoc(2048, 512)\n"
     246    ">>> out = pv.rdo(aubio.cvec(2048))\n"
     247    ">>> out.shape\n"
     248    "(512,)\n"
     249    ""},
     250  {"set_window", (PyCFunction) Pyaubio_pvoc_set_window, METH_VARARGS,
     251    "set_window(window_type)\n"
     252    "\n"
     253    "Set window function\n"
     254    "\n"
     255    "Parameters\n"
     256    "----------\n"
     257    "window_type : str\n"
     258    "    the window type to use for this phase vocoder\n"
     259    "\n"
     260    "Raises\n"
     261    "------\n"
     262    "ValueError\n"
     263    "    If an unknown window type was given.\n"
     264    "\n"
     265    "See Also\n"
     266    "--------\n"
     267    "window : create a window.\n"
     268    ""},
    180269  {NULL}
    181270};
Note: See TracChangeset for help on using the changeset viewer.