source: python/README.md @ ff28d81

feature/autosinkfeature/constantqfeature/pitchshiftfeature/timestretch
Last change on this file since ff28d81 was 36ce209, checked in by Paul Brossier <piem@piem.org>, 8 months ago

[doc] remove references to run_all_tests

  • Property mode set to 100644
File size: 2.7 KB
Line 
1Python aubio module
2===================
3
4This module wraps the aubio library for Python using the numpy module.
5
6Using the Python aubio module
7-----------------------------
8
9After installing python-aubio, you will be able to import the aubio module:
10
11    $ python
12    [...]
13    >>> import aubio
14    >>> help(aubio.miditofreq)
15
16Finding some inspiration
17------------------------
18
19Some examples are available in the `python/demos` directory. These scripts are
20small programs written in python and using python-aubio.
21
22For instance, `demo_source.py` reads a media file.
23
24    $ ./python/demos/demo_source.py /path/to/sound/sample.wav
25
26and `demo_timestretch_online.py` stretches the original file into a new one:
27
28    $ ./python/demo/demo_timestretch_online.py loop.wav stretched_loop.wav 0.92`
29
30Note: you might need to install additional modules to run some of the demos.
31Some demos use [matplotlib](http://matplotlib.org/) to draw plots, others use
32[PySoundCard](https://github.com/bastibe/PySoundCard) to play and record
33sounds.
34
35Testing the Python module
36-------------------------
37
38Python tests are in `python/tests` and use [pytest].
39
40To run the all the python tests:
41
42    $ cd aubio
43    $ pytest
44
45Each test script can also be called one at a time. For instance:
46
47    $ pytest -v python/tests/test_note2midi.py
48
49[pytest]: https://pytest.org
50
51Install in a virtualenv
52-----------------------
53
54You should be able to install python-aubio directly from the top source
55directory of aubio.
56
57First, create a virtualenv to hold the required python module:
58
59    $ virtualenv pyaubio
60    $ source pyaubio/bin/activate
61
62Now install and build the python extension using:
63
64    $ pip install .
65
66Install requirements
67--------------------
68
69Before compiling this module, you must have compiled libaubio.
70
71A simple way to do this is with pip:
72
73    $ pip install -r requirements.txt
74
75For more information about how this module works, please refer to the [Python/C
76API Reference Manual] (http://docs.python.org/c-api/index.html) and the
77[Numpy/C API Reference](http://docs.scipy.org/doc/numpy/reference/c-api.html).
78
79Compiling python aubio
80----------------------
81
82To build the aubio Python module, run the following command from the top source
83directory of aubio:
84
85    $ ./setup.py build
86
87Note: if libaubio was previously built using waf, the script will use it.
88Otherwise, the entire library will be built inside the python extension.
89
90To find out more about `setup.py` options:
91
92    $ ./setup.py --help
93
94Installing
95----------
96
97To install the Python module:
98
99    $ ./setup.py install
100
101Alternatively, you may want to use the Python module without installing it by
102setting your PYTHONPATH, for instance as follows:
103
104    $ export PYTHONPATH=$PYTHONPATH:$PWD/`ls -rtd build/lib.* | head -1`:$PWD/tests
105
Note: See TracBrowser for help on using the repository browser.