source: python/README.md @ f61ffb9

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5sampleryinfft+
Last change on this file since f61ffb9 was 1154fd1, checked in by Paul Brossier <piem@piem.org>, 8 years ago

python/README.md: add a note about nose2 for python tests (closes #74)

  • Property mode set to 100644
File size: 2.8 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 the [nose2 python package][nose2].
39
40To run the all the python tests, use the script:
41
42    $ ./python/tests/run_all_tests
43
44Each test script can also be called one at a time. For instance:
45
46    $ ./python/tests/test_note2midi.py -v
47
48[nose2]: https://github.com/nose-devs/nose2
49
50Install in a virtualenv
51-----------------------
52
53You should be able to install python-aubio directly from the top source
54directory of aubio.
55
56First, create a virtualenv to hold the required python module:
57
58    $ virtualenv pyaubio
59    $ source pyaubio/bin/activate
60
61Now install and build the python extension using:
62
63    $ pip install .
64
65Install requirements
66--------------------
67
68Before compiling this module, you must have compiled libaubio.
69
70A simple way to do this is with pip:
71
72    $ pip install -r requirements.txt
73
74For more information about how this module works, please refer to the [Python/C
75API Reference Manual] (http://docs.python.org/c-api/index.html) and the
76[Numpy/C API Reference](http://docs.scipy.org/doc/numpy/reference/c-api.html).
77
78Compiling python aubio
79----------------------
80
81To build the aubio Python module, run the following command from the top source
82directory of aubio:
83
84    $ ./setup.py build
85
86Note: if libaubio was previously built using waf, the script will use it.
87Otherwise, the entire library will be built inside the python extension.
88
89To find out more about `setup.py` options:
90
91    $ ./setup.py --help
92
93Installing
94----------
95
96To install the Python module:
97
98    $ ./setup.py install
99
100Alternatively, you may want to use the Python module without installing it by
101setting your PYTHONPATH, for instance as follows:
102
103    $ export PYTHONPATH=$PYTHONPATH:$PWD/`ls -rtd build/lib.* | head -1`:$PWD/tests
104
Note: See TracBrowser for help on using the repository browser.