# Changeset 8986239

Ignore:
Timestamp:
Oct 30, 2018, 3:22:41 PM (2 years ago)
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
Children:
37a6942
Parents:
152bf4f (diff), 81abf91 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'feature/cdocstrings' into feature/docstrings

Location:
python/ext
Files:
7 edited

Unmodified
Added
Removed
• ## python/ext/aubiomodule.c

 r152bf4f static char Py_alpha_norm_doc[] = "" "alpha_norm(fvec, integer) -> float\n" "\n" "Compute alpha normalisation factor on vector, given alpha\n" "alpha_norm(vec, alpha)\n" "\n" "Compute alpha normalisation factor of vector vec.\n" "\n" "Parameters\n" "----------\n" "vec : fvec\n" "   input vector\n" "alpha : float\n" "   norm factor\n" "\n" "Returns\n" "-------\n" "float\n" "   p-norm of the input vector, where p=alpha\n" "\n" "Example\n" "-------\n" "\n" ">>> b = alpha_norm(a, 9)"; ">>> a = aubio.fvec(np.arange(10)); alpha = 2\n" ">>> aubio.alpha_norm(a, alpha), (sum(a**alpha)/len(a))**(1./alpha)\n" "(5.338539123535156, 5.338539126015656)\n" "\n" "Note\n" "----\n" "Computed as:\n" "\n" ".. math::\n" "  l_{\\alpha} = \n" "       \\|\\frac{\\sum_{n=0}^{N-1}{{x_n}^{\\alpha}}}{N}\\|^{1/\\alpha}\n" ""; static char Py_bintomidi_doc[] = "" "bintomidi(float, samplerate = integer, fftsize = integer) -> float\n" "\n" "Convert bin (float) to midi (float), given the sampling rate and the FFT size\n" "bintomidi(fftbin, samplerate, fftsize)\n" "\n" "Convert FFT bin to frequency in midi note, given the sampling rate\n" "and the size of the FFT.\n" "\n" "Parameters\n" "----------\n" "fftbin : float\n" "   input frequency bin\n" "samplerate : float\n" "   sampling rate of the signal\n" "fftsize : float\n" "   size of the FFT\n" "\n" "Returns\n" "-------\n" "float\n" "   Frequency converted to midi note.\n" "\n" "Example\n" "-------\n" "\n" ">>> midi = bintomidi(float, samplerate = 44100, fftsize = 1024)"; ">>> aubio.bintomidi(10, 44100, 1024)\n" "68.62871551513672\n" ""; static char Py_miditobin_doc[] = "" "miditobin(float, samplerate = integer, fftsize = integer) -> float\n" "\n" "Convert midi (float) to bin (float), given the sampling rate and the FFT size\n" "miditobin(midi, samplerate, fftsize)\n" "\n" "Convert frequency in midi note to FFT bin, given the sampling rate\n" "and the size of the FFT.\n" "\n" "Parameters\n" "----------\n" "midi : float\n" "   input frequency, in midi note\n" "samplerate : float\n" "   sampling rate of the signal\n" "fftsize : float\n" "   size of the FFT\n" "\n" "Returns\n" "-------\n" "float\n" "   Frequency converted to FFT bin.\n" "\n" "Examples\n" "--------\n" "\n" ">>> aubio.miditobin(69, 44100, 1024)\n" "10.216779708862305\n" ">>> aubio.miditobin(75.08, 32000, 512)\n" "10.002175331115723\n" ""; static char Py_bintofreq_doc[] = "" "bintofreq(fftbin, samplerate, fftsize)\n" "\n" "Convert FFT bin to frequency in Hz, given the sampling rate\n" "and the size of the FFT.\n" "\n" "Parameters\n" "----------\n" "fftbin : float\n" "   input frequency bin\n" "samplerate : float\n" "   sampling rate of the signal\n" "fftsize : float\n" "   size of the FFT\n" "\n" "Returns\n" "-------\n" "float\n" "   Frequency converted to Hz.\n" "\n" "Example\n" "-------\n" "\n" ">>> bin = miditobin(midi, samplerate = 44100, fftsize = 1024)"; static char Py_bintofreq_doc[] = "" "bintofreq(float, samplerate = integer, fftsize = integer) -> float\n" "\n" "Convert bin number (float) in frequency (Hz), given the sampling rate and the FFT size\n" ">>> aubio.bintofreq(10, 44100, 1024)\n" "430.6640625\n" ""; static char Py_freqtobin_doc[] = "" "freqtobin(freq, samplerate, fftsize)\n" "\n" "Convert frequency in Hz to FFT bin, given the sampling rate\n" "and the size of the FFT.\n" "\n" "Parameters\n" "----------\n" "midi : float\n" "   input frequency, in midi note\n" "samplerate : float\n" "   sampling rate of the signal\n" "fftsize : float\n" "   size of the FFT\n" "\n" "Returns\n" "-------\n" "float\n" "   Frequency converted to FFT bin.\n" "\n" "Examples\n" "--------\n" "\n" ">>> aubio.freqtobin(440, 44100, 1024)\n" "10.216779708862305\n" ""; static char Py_zero_crossing_rate_doc[] = "" "zero_crossing_rate(vec)\n" "\n" "Compute zero-crossing rate of vec.\n" "\n" "Parameters\n" "----------\n" "vec : fvec\n" "   input vector\n" "\n" "Returns\n" "-------\n" "float\n" "   Zero-crossing rate.\n" "\n" "Example\n" "-------\n" "\n" ">>> freq = bintofreq(bin, samplerate = 44100, fftsize = 1024)"; static char Py_freqtobin_doc[] = "" "freqtobin(float, samplerate = integer, fftsize = integer) -> float\n" "\n" "Convert frequency (Hz) in bin number (float), given the sampling rate and the FFT size\n" ">>> a = np.linspace(-1., 1., 1000, dtype=aubio.float_type)\n" ">>> aubio.zero_crossing_rate(a), 1/1000\n" "(0.0010000000474974513, 0.001)\n" ""; static char Py_min_removal_doc[] = "" "min_removal(vec)\n" "\n" "Remove the minimum value of a vector to each of its element.\n" "\n" "Modifies the input vector in-place and returns a reference to it.\n" "\n" "Parameters\n" "----------\n" "vec : fvec\n" "   input vector\n" "\n" "Returns\n" "-------\n" "fvec\n" "   modified input vector\n" "\n" "Example\n" "-------\n" "\n" ">>> bin = freqtobin(freq, samplerate = 44100, fftsize = 1024)"; static char Py_zero_crossing_rate_doc[] = "" "zero_crossing_rate(fvec) -> float\n" "\n" "Compute Zero crossing rate of a vector\n" "\n" "Example\n" "-------\n" "\n" ">>> z = zero_crossing_rate(a)"; static char Py_min_removal_doc[] = "" "min_removal(fvec) -> float\n" "\n" "Remove the minimum value of a vector, in-place modification\n" "\n" "Example\n" "-------\n" "\n" ">>> min_removal(a)"; ">>> aubio.min_removal(aubio.fvec(np.arange(1,4)))\n" "array([0., 1., 2.], dtype=" AUBIO_NPY_SMPL_STR ")\n" ""; extern void add_ufuncs ( PyObject *m );
• ## python/ext/py-cvec.c

 r152bf4f } Py_cvec; static char Py_cvec_doc[] = "cvec object"; static char Py_cvec_doc[] = "" "cvec(size)\n" "\n" "Data structure to hold spectral vectors.\n" "\n" "A vector holding spectral data in two vectors, :attr:phas\n" "and :attr:norm. Each vector is a :class:numpy.ndarray\n" "of shape (length,), where length = size // 2 + 1.\n" "\n" "Parameters\n" "----------\n" "size: int\n" "   Size of spectrum to create.\n" "\n" "Examples\n" "--------\n" ">>> c = aubio.cvec(1024)\n" ">>> c\n" "aubio cvec of 513 elements\n" ">>> c.length\n" "513\n" ">>> c.norm.dtype, c.phas.dtype\n" "(dtype('float32'), dtype('float32'))\n" ">>> c.norm.shape, c.phas.shape\n" "((513,), (513,))\n" "\n" "See Also\n" "--------\n" "fft, pvoc\n" ""; // TODO remove READONLY flag and define getter/setter {"length", T_INT, offsetof (Py_cvec, length), READONLY, "length attribute"}, "int: Length of norm and phas vectors."}, {NULL}                        /* Sentinel */ }; static PyGetSetDef Py_cvec_getseters[] = { {"norm", (getter)Py_cvec_get_norm, (setter)Py_cvec_set_norm, "Numpy vector of shape (length,) containing the magnitude", {"norm", (getter)Py_cvec_get_norm, (setter)Py_cvec_set_norm, "numpy.ndarray: Vector of shape (length,) containing the magnitude.", NULL}, {"phas", (getter)Py_cvec_get_phas, (setter)Py_cvec_set_phas, "Numpy vector of shape (length,) containing the phase", {"phas", (getter)Py_cvec_get_phas, (setter)Py_cvec_set_phas, "numpy.ndarray: Vector of shape (length,) containing the phase.", NULL}, {NULL} /* sentinel */
• ## python/ext/py-musicutils.h

 r152bf4f static char Py_aubio_window_doc[] = "" "window(string, integer) -> fvec\n" "\n" "Create a window\n" "\n" "Example\n" "-------\n" "\n" ">>> window('hanningz', 1024)\n" "window(window_type, size)\n" "\n" "Create a window of length size. window_type should be one\n" "of the following:\n" "\n" "- default (same as hanningz).\n" "- ones\n" "- rectangle\n" "- hamming\n" "- hanning\n" "- hanningz _\n" "- blackman\n" "- blackman_harris\n" "- gaussian\n" "- welch\n" "- parzen\n" "\n" "Parameters\n" "----------\n" "window_type : str\n" "   Type of window.\n" "size : int\n" "   Length of window.\n" "\n" "Returns\n" "-------\n" "fvec\n" "   Array of shape (length,) containing the new window.\n" "\n" "See Also\n" "--------\n" "pvoc, fft\n" "\n" "Examples\n" "--------\n" "Compute a zero-phase Hann window on 1024 points:\n" "\n" ">>> aubio.window('hanningz', 1024)\n" "array([  0.00000000e+00,   9.41753387e-06,   3.76403332e-05, ...,\n" "         8.46982002e-05,   3.76403332e-05,   9.41753387e-06], dtype=float32)"; "         8.46982002e-05,   3.76403332e-05,   9.41753387e-06], dtype=float32)\n" "\n" "Plot different window types with matplotlib _:\n" "\n" ">>> import matplotlib.pyplot as plt\n" ">>> modes = ['default', 'ones', 'rectangle', 'hamming', 'hanning',\n" "...          'hanningz', 'blackman', 'blackman_harris', 'gaussian',\n" "...          'welch', 'parzen']; n = 2048\n" ">>> for m in modes: plt.plot(aubio.window(m, n), label=m)\n" "...\n" ">>> plt.legend(); plt.show()\n" "\n" "Note\n" "----\n" "The following examples contain the equivalent source code to compute\n" "each type of window with NumPy _:\n" "\n" ">>> n = 1024; x = np.arange(n, dtype=aubio.float_type)\n" ">>> ones = np.ones(n).astype(aubio.float_type)\n" ">>> rectangle = 0.5 * ones\n" ">>> hanning = 0.5 - 0.5 * np.cos(2 * np.pi * x / n)\n" ">>> hanningz = 0.5 * (1 - np.cos(2 * np.pi * x / n))\n" ">>> hamming = 0.54 - 0.46 * np.cos(2.*np.pi * x / (n - 1))\n" ">>> blackman = 0.42 \\\n" "...          - 0.50 * np.cos(2 * np.pi * x / (n - 1)) \\\n" "...          + 0.08 * np.cos(4 * np.pi * x / (n - 1))\n" ">>> blackman_harris = 0.35875 \\\n" "...       - 0.48829 * np.cos(2 * np.pi * x / (n - 1)) \\\n" "...       + 0.14128 * np.cos(4 * np.pi * x / (n - 1)) \\\n" "...       + 0.01168 * np.cos(6 * np.pi * x / (n - 1))\n" ">>> gaussian = np.exp( - 0.5 * ((x - 0.5 * (n - 1)) \\\n" "...                            / (0.25 * (n - 1)) )**2 )\n" ">>> welch = 1 - ((2 * x - n) / (n + 1))**2\n" ">>> parzen = 1 - np.abs((2 * x - n) / (n + 1))\n" ">>> default = hanningz\n" "References\n" "----------\n" #if 0 "Window function _ on\n" "Wikipedia.\n" "\n" #endif "..  Amalia de Götzen, Nicolas Bernardini, and Daniel Arfib. Traditional\n" "   (?) implementations of a phase vocoder: the tricks of the trade.\n" "   In *Proceedings of the International Conference on Digital Audio\n" "   Effects* (DAFx-00), pages 37–44, University of Verona, Italy, 2000.\n" "   (online version <" "https://www.cs.princeton.edu/courses/archive/spr09/cos325/Bernardini.pdf" ">_).\n" ""; PyObject * Py_aubio_window(PyObject *self, PyObject *args); static char Py_aubio_level_lin_doc[] = "" "level_lin(fvec) -> fvec\n" "\n" "Compute sound level on a linear scale.\n" "\n" "This gives the average of the square amplitudes.\n" "\n" "Example\n" "-------\n" "\n" ">>> level_Lin(numpy.ones(1024))\n" "1.0"; "level_lin(x)\n" "\n" "Compute sound pressure level of x, on a linear scale.\n" "\n" "Parameters\n" "----------\n" "x : fvec\n" "   input vector\n" "\n" "Returns\n" "-------\n" "float\n" "   Linear level of x.\n" "\n" "Example\n" "-------\n" "\n" ">>> aubio.level_lin(aubio.fvec(numpy.ones(1024)))\n" "1.0\n" "\n" "Note\n" "----\n" "Computed as the average of the squared amplitudes:\n" "\n" ".. math:: L = \\frac {\\sum_{n=0}^{N-1} {x_n}^2} {N}\n" "\n" "See Also\n" "--------\n" "db_spl, silence_detection, level_detection\n" ""; PyObject * Py_aubio_level_lin(PyObject *self, PyObject *args); static char Py_aubio_db_spl_doc[] = "" "Compute sound pressure level (SPL) in dB\n" "\n" "This quantity is often wrongly called 'loudness'.\n" "\n" "This gives ten times the log10 of the average of the square amplitudes.\n" "\n" "Example\n" "-------\n" "\n" ">>> db_spl(numpy.ones(1024))\n" "1.0"; "db_spl(x)\n" "\n" "Compute Sound Pressure Level (SPL) of x, in dB.\n" "\n" "Parameters\n" "----------\n" "x : fvec\n" "   input vector\n" "\n" "Returns\n" "-------\n" "float\n" "   Level of x, in dB SPL.\n" "\n" "Example\n" "-------\n" "\n" ">>> aubio.db_spl(aubio.fvec(np.ones(1024)))\n" "1.0\n" ">>> aubio.db_spl(0.7*aubio.fvec(np.ones(32)))\n" "-3.098040819168091\n" "\n" "Note\n" "----\n" "Computed as log10 of :py:func:level_lin:\n" "\n" ".. math::\n" "\n" "   {SPL}_{dB} = log10{\\frac {\\sum_{n=0}^{N-1}{x_n}^2} {N}}\n" "\n" "This quantity is often incorrectly called 'loudness'.\n" "\n" "See Also\n" "--------\n" "level_lin, silence_detection, level_detection\n" ""; PyObject * Py_aubio_db_spl(PyObject *self, PyObject *args); static char Py_aubio_silence_detection_doc[] = "" "Check if buffer level in dB SPL is under a given threshold\n" "\n" "Return 0 if level is under the given threshold, 1 otherwise.\n" "\n" "Example\n" "-------\n" "\n" ">>> import numpy\n""" ">>> silence_detection(numpy.ones(1024, dtype=\"float32\"), -80)\n" "0"; "silence_detection(vec, level)\n" "\n" "Check if level of vec, in dB SPL, is under a given threshold.\n" "\n" "Parameters\n" "----------\n" "vec : fvec\n" "   input vector\n" "level : float\n" "   level threshold, in dB SPL\n" "\n" "Returns\n" "-------\n" "int\n" "   1 if level of vec, in dB SPL, is under level,\n" "   0 otherwise.\n" "\n" "Examples\n" "--------\n" "\n" ">>> aubio.silence_detection(aubio.fvec(32), -100.)\n" "1\n" ">>> aubio.silence_detection(aubio.fvec(np.ones(32)), 0.)\n" "0\n" "\n" "See Also\n" "--------\n" "level_detection, db_spl, level_lin\n" ""; PyObject * Py_aubio_silence_detection(PyObject *self, PyObject *args); static char Py_aubio_level_detection_doc[] = "" "Get buffer level in dB SPL if over a given threshold, 1. otherwise.\n" "\n" "Example\n" "-------\n" "\n" ">>> import numpy\n""" ">>> level_detection(0.7*numpy.ones(1024, dtype=\"float32\"), -80)\n" "0"; "level_detection(vec, level)\n" "\n" "Check if vec is above threshold level, in dB SPL.\n" "\n" "Parameters\n" "----------\n" "vec : fvec\n" "   input vector\n" "level : float\n" "   level threshold, in dB SPL\n" "\n" "Returns\n" "-------\n" "float\n" "   1.0 if level of vec in dB SPL is under level,\n" "   db_spl(vec) otherwise.\n" "\n" "Example\n" "-------\n" "\n" ">>> aubio.level_detection(0.7*aubio.fvec(np.ones(1024)), -3.)\n" "1.0\n" ">>> aubio.level_detection(0.7*aubio.fvec(np.ones(1024)), -4.)\n" "-3.0980708599090576\n" "\n" "See Also\n" "--------\n" "silence_detection, db_spl, level_lin\n" ""; PyObject * Py_aubio_level_detection(PyObject *self, PyObject *args); static char Py_aubio_shift_doc[] = "" "Swap left and right partitions of a vector\n" "\n" "Returns the swapped vector. The input vector is also modified.\n" "shift(vec)\n" "\n" "Swap left and right partitions of a vector, in-place.\n" "\n" "Parameters\n" "----------\n" "vec : fvec\n" "   input vector to shift\n" "\n" "Returns\n" "-------\n" "fvec\n" "   The swapped vector.\n" "\n" "Notes\n" "-----\n" "The input vector is also modified.\n" "\n" "For a vector of length N, the partition is split at index N - N//2.\n" "-------\n" "\n" ">>> import numpy\n" ">>> shift(numpy.arange(3, dtype=aubio.float_type))\n" "array([2., 0., 1.], dtype=" AUBIO_NPY_SMPL_STR ")"; ">>> aubio.shift(aubio.fvec(np.arange(3)))\n" "array([2., 0., 1.], dtype=" AUBIO_NPY_SMPL_STR ")\n" "\n" "See Also\n" "--------\n" "ishift\n" ""; PyObject * Py_aubio_shift(PyObject *self, PyObject *args); static char Py_aubio_ishift_doc[] = "" "Swap right and left partitions of a vector\n" "\n" "Returns the swapped vector. The input vector is also modified.\n" "\n" "Unlike with shift(), the partition is split at index N//2.\n" "\n" "Example\n" "-------\n" "\n" ">>> import numpy\n" ">>> ishift(numpy.arange(3, dtype=aubio.float_type))\n" "array([1., 2., 0.], dtype=" AUBIO_NPY_SMPL_STR ")"; "ishift(vec)\n" "\n" "Swap right and left partitions of a vector, in-place.\n" "\n" "Parameters\n" "----------\n" "vec : fvec\n" "   input vector to shift\n" "\n" "Returns\n" "-------\n" "fvec\n" "   The swapped vector.\n" "\n" "Notes\n" "-----\n" "The input vector is also modified.\n" "\n" "Unlike with :py:func:shift, the partition is split at index N//2.\n" "\n" "Example\n" "-------\n" "\n" ">>> aubio.ishift(aubio.fvec(np.arange(3)))\n" "array([1., 2., 0.], dtype=" AUBIO_NPY_SMPL_STR ")\n" "\n" "See Also\n" "--------\n" "shift\n" ""; PyObject * Py_aubio_ishift(PyObject *self, PyObject *args);
• ## python/ext/py-phasevoc.c

 r152bf4f #include "aubio-types.h" static char Py_pvoc_doc[] = "pvoc object"; static char Py_pvoc_doc[] = "" "pvoc(win_s=512, hop_s=256)\n" "\n" "Phase vocoder.\n" "\n" "pvoc creates callable object implements a phase vocoder _,\n" "using the tricks detailed in _.\n" "\n" "The call function takes one input of type fvec and of size\n" "hop_s, and returns a cvec of length win_s//2+1.\n" "\n" "Parameters\n" "----------\n" "win_s : int\n" "  number of channels in the phase-vocoder.\n" "hop_s : int\n" "  number of samples expected between each call\n" "\n" "Examples\n" "--------\n" ">>> x = aubio.fvec(256)\n" ">>> pv = aubio.pvoc(512, 256)\n" ">>> pv(x)\n" "aubio cvec of 257 elements\n" "\n" "Default values for hop_s and win_s are provided:\n" "\n" ">>> pv = aubio.pvoc()\n" ">>> pv.win_s, pv.hop_s\n" "512, 256\n" "\n" "A cvec can be resynthesised using rdo():\n" "\n" ">>> pv = aubio.pvoc(512, 256)\n" ">>> y = aubio.cvec(512)\n" ">>> x_reconstructed = pv.rdo(y)\n" ">>> x_reconstructed.shape\n" "(256,)\n" "\n" "References\n" "----------\n" "..  James A. Moorer. The use of the phase vocoder in computer music\n" "   applications. Journal of the Audio Engineering Society,\n" "   26(1/2):42–45, 1978.\n" "..  Amalia de Götzen, Nicolas Bernardini, and Daniel Arfib. Traditional\n" "   (?) implementations of a phase vocoder: the tricks of the trade.\n" "   In Proceedings of the International Conference on Digital Audio\n" "   Effects (DAFx-00), pages 37–44, University of Verona, Italy, 2000.\n" "   (online version <" "https://www.cs.princeton.edu/courses/archive/spr09/cos325/Bernardini.pdf" ">_).\n" ""; typedef struct static PyMemberDef Py_pvoc_members[] = { {"win_s", T_INT, offsetof (Py_pvoc, win_s), READONLY, "size of the window"}, "int: Size of phase vocoder analysis windows, in samples.\n" ""}, {"hop_s", T_INT, offsetof (Py_pvoc, hop_s), READONLY, "size of the hop"}, "int: Interval between two analysis, in samples.\n" ""}, { NULL } // sentinel }; static PyMethodDef Py_pvoc_methods[] = { {"rdo", (PyCFunction) Py_pvoc_rdo, METH_VARARGS, "synthesis of spectral grain"}, {"set_window", (PyCFunction) Pyaubio_pvoc_set_window, METH_VARARGS, ""}, "rdo(fftgrain)\n" "\n" "Read a new spectral grain and resynthesise the next hop_s\n" "output samples.\n" "\n" "Parameters\n" "----------\n" "fftgrain : cvec\n" "    new input cvec to synthesize from, should be of size win_s/2+1\n" "\n" "Returns\n" "-------\n" "fvec\n" "    re-synthesised output of shape (hop_s,)\n" "\n" "Example\n" "-------\n" ">>> pv = aubio.pvoc(2048, 512)\n" ">>> out = pv.rdo(aubio.cvec(2048))\n" ">>> out.shape\n" "(512,)\n" ""}, {"set_window", (PyCFunction) Pyaubio_pvoc_set_window, METH_VARARGS, "set_window(window_type)\n" "\n" "Set window function\n" "\n" "Parameters\n" "----------\n" "window_type : str\n" "    the window type to use for this phase vocoder\n" "\n" "Raises\n" "------\n" "ValueError\n" "    If an unknown window type was given.\n" "\n" "See Also\n" "--------\n" "window : create a window.\n" ""}, {NULL} };
• ## python/ext/py-sink.c

 r152bf4f static char Py_sink_doc[] = "" "  __new__(path, samplerate = 44100, channels = 1)\n" "\n" "      Create a new sink, opening the given path for writing.\n" "\n" "      Examples\n" "      --------\n" "\n" "      Create a new sink at 44100Hz, mono:\n" "\n" "      >>> sink('/tmp/t.wav')\n" "\n" "      Create a new sink at 8000Hz, mono:\n" "\n" "      >>> sink('/tmp/t.wav', samplerate = 8000)\n" "\n" "      Create a new sink at 32000Hz, stereo:\n" "\n" "      >>> sink('/tmp/t.wav', samplerate = 32000, channels = 2)\n" "\n" "      Create a new sink at 32000Hz, 5 channels:\n" "\n" "      >>> sink('/tmp/t.wav', channels = 5, samplerate = 32000)\n" "\n" "  __call__(vec, write)\n" "      x(vec,write) <==> x.do(vec, write)\n" "\n" "      Write vector to sink.\n" "\n" "      See also\n" "      --------\n" "      aubio.sink.do\n" "sink(path, samplerate=44100, channels=1)\n" "\n" "Open path to write a WAV file.\n" "\n" "Parameters\n" "----------\n" "path : str\n" "   Pathname of the file to be opened for writing.\n" "samplerate : int\n" "   Sampling rate of the file, in Hz.\n" "channels : int\n" "   Number of channels to create the file with.\n" "\n" "Examples\n" "--------\n" "\n" "Create a new sink at 44100Hz, mono:\n" "\n" ">>> snk = aubio.sink('out.wav')\n" "\n" "Create a new sink at 32000Hz, stereo, write 100 samples into it:\n" "\n" ">>> snk = aubio.sink('out.wav', samplerate=16000, channels=3)\n" ">>> snk(aubio.fvec(100), 100)\n" "\n" "Open a new sink at 48000Hz, stereo, write 1234 samples into it:\n" "\n" ">>> with aubio.sink('out.wav', samplerate=48000, channels=2) as src:\n" "...     snk(aubio.fvec(1024), 1024)\n" "...     snk(aubio.fvec(210), 210)\n" "...\n" "\n" "See also\n" "--------\n" "source: read audio samples from a file.\n" "\n"; static char Py_sink_do_doc[] = "" "x.do(vec, write) <==> x(vec, write)\n" "\n" "write monophonic vector to sink"; "do(vec, write)\n" "\n" "Write a single channel vector to sink.\n" "\n" "Parameters\n" "----------\n" "vec : fvec\n" "   input vector (n,) where n >= 0.\n" "write : int\n" "   Number of samples to write.\n" ""; static char Py_sink_do_multi_doc[] = "" "x.do_multi(mat, write)\n" "\n" "write polyphonic vector to sink"; "do_multi(mat, write)\n" "\n" "Write a matrix containing vectors from multiple channels to sink.\n" "\n" "Parameters\n" "----------\n" "mat : numpy.ndarray\n" "   input matrix of shape (channels, n), where n >= 0.\n" "write : int\n" "   Number of frames to write.\n" ""; static char Py_sink_close_doc[] = "" "x.close()\n" "\n" "close this sink now"; "close()\n" "\n" "Close this sink now.\n" "\n" "By default, the sink will be closed before being deleted.\n" "Explicitely closing a sink can be useful to control the number\n" "of files simultaneously opened.\n" ""; static PyObject * static PyMemberDef Py_sink_members[] = { {"uri", T_STRING, offsetof (Py_sink, uri), READONLY, "path at which the sink was created"}, "str (read-only): Path at which the sink was created."}, {"samplerate", T_INT, offsetof (Py_sink, samplerate), READONLY, "samplerate at which the sink was created"}, "int (read-only): Samplerate at which the sink was created."}, {"channels", T_INT, offsetof (Py_sink, channels), READONLY, "number of channels with which the sink was created"}, "int (read-only): Number of channels with which the sink was created."}, { NULL } // sentinel };
• ## python/ext/py-source.c

 r152bf4f static char Py_source_doc[] = "" "   __new__(path, samplerate = 0, hop_size = 512, channels = 1)\n" "\n" "       Create a new source, opening the given path for reading.\n" "\n" "       Examples\n" "       --------\n" "\n" "       Create a new source, using the original samplerate, with hop_size = 512:\n" "\n" "       >>> source('/tmp/t.wav')\n" "\n" "       Create a new source, resampling the original to 8000Hz:\n" "\n" "       >>> source('/tmp/t.wav', samplerate = 8000)\n" "\n" "       Create a new source, resampling it at 32000Hz, hop_size = 32:\n" "\n" "       >>> source('/tmp/t.wav', samplerate = 32000, hop_size = 32)\n" "\n" "       Create a new source, using its original samplerate:\n" "\n" "       >>> source('/tmp/t.wav', samplerate = 0)\n" "\n" "   __call__()\n" "       vec, read = x() <==> vec, read = x.do()\n" "\n" "       Read vector from source.\n" "\n" "       See also\n" "       --------\n" "       aubio.source.do\n" "\n"; "source(path, samplerate=0, hop_size=512, channels=0)\n" "\n" "Create a new source, opening the given pathname for reading.\n" "\n" "source open the file specified in path and creates a callable\n" "returning hop_size new audio samples at each invocation.\n" "\n" "If samplerate=0 (default), the original sampling rate of path\n" "will be used. Otherwise, the output audio samples will be\n" "resampled at the desired sampling-rate.\n" "\n" "If channels=0 (default), the original number of channels\n" "in path will be used. Otherwise, the output audio samples\n" "will be down-mixed or up-mixed to the desired number of\n" "channels.\n" "\n" "If path is a URL, a remote connection will be attempted to\n" "open the resource and stream data from it.\n" "\n" "The parameter hop_size determines how many samples should be\n" "read at each consecutive calls.\n" "\n" "Parameters\n" "----------\n" "path : str\n" "   pathname (or URL) of the file to be opened for reading\n" "samplerate : int, optional\n" "   sampling rate of the file\n" "hop_size : int, optional\n" "   number of samples to be read per iteration\n" "channels : int, optional\n" "   number of channels of the file\n" "\n" "Examples\n" "--------\n" "By default, when only path is given, the file will be opened\n" "with its original sampling rate and channel:\n" "\n" ">>> src = aubio.source('stereo.wav')\n" ">>> src.uri, src.samplerate, src.channels, src.duration\n" "('stereo.wav', 48000, 2, 86833)\n" "\n" "A typical loop to read all samples from a local file could\n" "look like this:\n" "\n" ">>> src = aubio.source('stereo.wav')\n" ">>> total_read = 0\n" ">>> while True:\n" "...     samples, read = src()\n" "...     # do something with samples\n" "...     total_read += read\n" "...     if read < src.hop_size:\n" "...         break\n" "...\n" "\n" "In a more Pythonic way, it can also look like this:\n" "\n" ">>> total_read = 0\n" ">>> with aubio.source('stereo.wav') as src:\n" "...     for frames in src:\n" "...         total_read += samples.shape[-1]\n" "...\n" "\n" ".. rubric:: Basic interface\n" "\n" "source is a **callable**; its :meth:__call__ method\n" "returns a tuple containing:\n" "\n" "- a vector of shape (hop_size,), filled with the read next\n" "  samples available, zero-padded if read < hop_size\n" "- read, an integer indicating the number of samples read\n" "\n" "To read the first hop_size samples from the source, simply call\n" "the instance itself, with no argument:\n" "\n" ">>> src = aubio.source('song.ogg')\n" ">>> samples, read = src()\n" ">>> samples.shape, read, src.hop_size\n" "((512,), 512, 512)\n" "\n" "The first call returned the slice of samples [0 : hop_size].\n" "The next call will return samples [hop_size: 2*hop_size].\n" "\n" "After several invocations of :meth:__call__, when reaching the end\n" "of the opened stream, read might become less than hop_size:\n" "\n" ">>> samples, read = src()\n" ">>> samples.shape, read\n" "((512,), 354)\n" "\n" "The end of the vector samples is filled with zeros.\n" "\n" "After the end of the stream, read will be 0 since no more\n" "samples are available:\n" "\n" ">>> samples, read = src()\n" ">>> samples.shape, read\n" "((512,), 0)\n" "\n" "**Note**: when the source has more than one channels, they\n" "are be down-mixed to mono when invoking :meth:__call__.\n" "To read from each individual channel, see :meth:__next__.\n" "\n" ".. rubric:: for statements\n" "\n" "The source objects are **iterables**. This allows using them\n" "directly in a for loop, which calls :meth:__next__ until\n" "the end of the stream is reached:\n" "\n" ">>> src = aubio.source('stereo.wav')\n" ">>> for frames in src:\n" ">>>     print (frames.shape)\n" "...\n" "(2, 512)\n" "(2, 512)\n" "(2, 230)\n" "\n" "**Note**: When next(self) is called on a source with multiple\n" "channels, an array of shape (channels, read) is returned,\n" "unlike with :meth:__call__ which always returns the down-mixed\n" "channels.\n" "\n" "If the file is opened with a single channel, next(self) returns\n" "an array of shape (read,):\n" "\n" ">>> src = aubio.source('stereo.wav', channels=1)\n" ">>> next(src).shape\n" "(512,)\n" "\n" ".. rubric:: with statements\n" "\n" "The source objects are **context managers**, which allows using\n" "them in with statements:\n" "\n" ">>> with aubio.source('audiotrack.wav') as source:\n" "...     n_frames=0\n" "...     for samples in source:\n" "...         n_frames += len(samples)\n" "...     print('read', n_frames, 'samples in', samples.shape, 'channels',\n" "...         'from file \"\%s\"' \% source.uri)\n" "...\n" "read 239334 samples in 2 channels from file \"audiotrack.wav\"\n" "\n" "The file will be closed before exiting the statement.\n" "\n" "See also the methods implementing the context manager,\n" ":meth:__enter__ and :meth:__exit__.\n" "\n" ".. rubric:: Seeking and closing\n" "\n" "At any time, :meth:seek can be used to move to any position in\n" "the file. For instance, to rewind to the start of the stream:\n" "\n" ">>> src.seek(0)\n" "\n" "The opened file will be automatically closed when the object falls\n" "out of scope and is scheduled for garbage collection.\n" "\n" "In some cases, it is useful to manually :meth:close a given source,\n" "for instance to limit the number of simultaneously opened files:\n" "\n" ">>> src.close()\n" "\n" ".. rubric:: Input formats\n" "\n" "Depending on how aubio was compiled, :class:source may or may not\n" "open certain **files format**. Below are some examples that assume\n" "support for compressed files and remote urls was compiled in:\n" "\n" "- open a local file using its original sampling rate and channels,\n" "  and with the default hop size:\n" "\n" ">>> s = aubio.source('sample.wav')\n" ">>> s.uri, s.samplerate, s.channels, s.hop_size\n" "('sample.wav', 44100, 2, 512)\n" "\n" "- open a local compressed audio file, resampling to 32000Hz if needed:\n" "\n" ">>> s = aubio.source('song.mp3', samplerate=32000)\n" ">>> s.uri, s.samplerate, s.channels, s.hop_size\n" "('song.mp3', 32000, 2, 512)\n" "\n" "- open a local video file, down-mixing and resampling it to 16kHz:\n" "\n" ">>> s = aubio.source('movie.mp4', samplerate=16000, channels=1)\n" ">>> s.uri, s.samplerate, s.channels, s.hop_size\n" "('movie.mp4', 16000, 1, 512)\n" "\n" "- open a remote resource, with hop_size = 1024:\n" "\n" ">>> s = aubio.source('https://aubio.org/drum.ogg', hop_size=1024)\n" ">>> s.uri, s.samplerate, s.channels, s.hop_size\n" "('https://aubio.org/drum.ogg', 48000, 2, 1024)\n" "\n" "See Also\n" "--------\n" "sink: write audio samples to a file.\n" ""; static char Py_source_get_samplerate_doc[] = "" "x.get_samplerate() -> source samplerate\n" "\n" "Get samplerate of source."; "get_samplerate()\n" "\n" "Get sampling rate of source.\n" "\n" "Returns\n" "-------\n" "int\n" "    Sampling rate, in Hz.\n" ""; static char Py_source_get_channels_doc[] = "" "x.get_channels() -> number of channels\n" "\n" "Get number of channels in source."; "get_channels()\n" "\n" "Get number of channels in source.\n" "\n" "Returns\n" "-------\n" "int\n" "    Number of channels.\n" ""; static char Py_source_do_doc[] = "" "vec, read = x.do() <==> vec, read = x()\n" "\n" "Read monophonic vector from source."; "source.do()\n" "\n" "Read vector of audio samples.\n" "\n" "If the audio stream in the source has more than one channel,\n" "the channels will be down-mixed.\n" "\n" "Returns\n" "-------\n" "samples : numpy.ndarray, shape (hop_size,), dtype aubio.float_type\n" "    fvec of size hop_size containing the new samples.\n" "read : int\n" "    Number of samples read from the source, equals to hop_size\n" "    before the end-of-file is reached, less when it is reached,\n" "    and 0 after.\n" "\n" "See Also\n" "--------\n" "do_multi\n" "\n" "Examples\n" "--------\n" ">>> src = aubio.source('sample.wav', hop_size=1024)\n" ">>> src.do()\n" "(array([-0.00123001, -0.00036685,  0.00097106, ..., -0.2031033 ,\n" "       -0.2025854 , -0.20221856], dtype=" AUBIO_NPY_SMPL_STR "), 1024)\n" ""; static char Py_source_do_multi_doc[] = "" "mat, read = x.do_multi()\n" "\n" "Read polyphonic vector from source."; "do_multi()\n" "\n" "Read multiple channels of audio samples.\n" "\n" "If the source was opened with the same number of channels\n" "found in the stream, each channel will be read individually.\n" "\n" "If the source was opened with less channels than the number\n" "of channels in the stream, only the first channels will be read.\n" "\n" "If the source was opened with more channels than the number\n" "of channel in the original stream, the first channels will\n" "be duplicated on the additional output channel.\n" "\n" "Returns\n" "-------\n" "samples : np.ndarray([hop_size, channels], dtype=aubio.float_type)\n" "    NumPy array of shape (hop_size, channels) containing the new\n" "    audio samples.\n" "read : int\n" "    Number of samples read from the source, equals to hop_size\n" "    before the end-of-file is reached, less when it is reached,\n" "    and 0 after.\n" "\n" "See Also\n" "--------\n" "do\n" "\n" "Examples\n" "--------\n" ">>> src = aubio.source('sample.wav')\n" ">>> src.do_multi()\n" "(array([[ 0.00668335,  0.0067749 ,  0.00714111, ..., -0.05737305,\n" "        -0.05856323, -0.06018066],\n" "       [-0.00842285, -0.0072937 , -0.00576782, ..., -0.09405518,\n" "        -0.09558105, -0.09725952]], dtype=" AUBIO_NPY_SMPL_STR "), 512)\n" ""; static char Py_source_close_doc[] = "" "x.close()\n" "\n" "Close this source now."; "close()\n" "\n" "Close this source now.\n" "\n" ".. note:: Closing twice a source will **not** raise any exception.\n" ""; static char Py_source_seek_doc[] = "" "x.seek(position)\n" "\n" "Seek to resampled frame position."; "seek(position)\n" "\n" "Seek to position in file.\n" "\n" "If the source was not opened with its original sampling-rate,\n" "position corresponds to the position in the re-sampled file.\n" "\n" "Parameters\n" "----------\n" "position : str\n" "   position to seek to, in samples\n" ""; static PyObject * static PyMemberDef Py_source_members[] = { {"uri", T_STRING, offsetof (Py_source, uri), READONLY, "path at which the source was created"}, "str (read-only): pathname or URL"}, {"samplerate", T_INT, offsetof (Py_source, samplerate), READONLY, "samplerate at which the source is viewed"}, "int (read-only): sampling rate"}, {"channels", T_INT, offsetof (Py_source, channels), READONLY, "number of channels found in the source"}, "int (read-only): number of channels"}, {"hop_size", T_INT, offsetof (Py_source, hop_size), READONLY, "number of consecutive frames that will be read at each do or do_multi call"}, "int (read-only): number of samples read per iteration"}, {"duration", T_INT, offsetof (Py_source, duration), READONLY, "total number of frames in the source (estimated)"}, "int (read-only): total number of frames in the source\n" "\n" "Can be estimated, for instance if the opened stream is\n" "a compressed media or a remote resource.\n" "\n" "Example\n" "-------\n" ">>> n = 0\n" ">>> src = aubio.source('track1.mp3')\n" ">>> for samples in src:\n" "...     n += samples.shape[-1]\n" "...\n" ">>> n, src.duration\n" "(9638784, 9616561)\n" ""}, { NULL } // sentinel };
• ## python/ext/ufuncs.c

 r152bf4f }; static char Py_unwrap2pi_doc[] = "map angle to unit circle [-pi, pi["; // Note: these docstrings should *not* include the function signatures static char Py_unwrap2pi_doc[] = "" "\n" "Map angle to unit circle :math:[-\\pi, \\pi[.\n" "\n" "Parameters\n" "----------\n" "x : numpy.ndarray\n" "   input array\n" "\n" "Returns\n" "-------\n" "numpy.ndarray\n" "   values clamped to the unit circle :math:[-\\pi, \\pi[\n" ""; static void* Py_unwrap2pi_data[] = { }; static char Py_freqtomidi_doc[] = "convert frequency to midi"; static char Py_freqtomidi_doc[] = "" "\n" "Convert frequency [0; 23000[ to midi [0; 128[.\n" "\n" "Parameters\n" "----------\n" "x : numpy.ndarray\n" "    Array of frequencies, in Hz.\n" "\n" "Returns\n" "-------\n" "numpy.ndarray\n" "    Converted frequencies, in midi note.\n" ""; static void* Py_freqtomidi_data[] = { }; static char Py_miditofreq_doc[] = "convert midi to frequency"; static char Py_miditofreq_doc[] = "" "\n" "Convert midi [0; 128[ to frequency [0, 23000].\n" "\n" "Parameters\n" "----------\n" "x : numpy.ndarray\n" "    Array of frequencies, in midi note.\n" "\n" "Returns\n" "-------\n" "numpy.ndarray\n" "    Converted frequencies, in Hz\n" ""; static void* Py_miditofreq_data[] = {
Note: See TracChangeset for help on using the changeset viewer.