[d44763f] | 1 | .. _python: |
---|
| 2 | |
---|
[5417b3a] | 3 | Python module |
---|
| 4 | ============= |
---|
[34abeaf] | 5 | |
---|
[d44763f] | 6 | The aubio extension for Python is available for Python 2.7 and Python 3. |
---|
| 7 | |
---|
[5417b3a] | 8 | Installing aubio with pip |
---|
| 9 | ------------------------- |
---|
[241e2fb] | 10 | |
---|
[a9a1e79] | 11 | aubio can now be installed using ``pip``: |
---|
[d44763f] | 12 | |
---|
[241e2fb] | 13 | .. code-block:: bash |
---|
| 14 | |
---|
| 15 | $ pip install aubio |
---|
| 16 | |
---|
[34abeaf] | 17 | Building the module |
---|
| 18 | ------------------- |
---|
| 19 | |
---|
| 20 | From ``aubio`` source directory, run the following: |
---|
| 21 | |
---|
| 22 | .. code-block:: bash |
---|
| 23 | |
---|
[241e2fb] | 24 | $ ./setup.py clean |
---|
[34abeaf] | 25 | $ ./setup.py build |
---|
| 26 | $ sudo ./setup.py install |
---|
| 27 | |
---|
[5417b3a] | 28 | Using aubio in python |
---|
| 29 | --------------------- |
---|
| 30 | |
---|
| 31 | Once you have python-aubio installed, you should be able to run ``python -c |
---|
[d8380d2] | 32 | "import aubio; print(aubio.version)"``. |
---|
[34abeaf] | 33 | |
---|
[d44763f] | 34 | A simple example |
---|
| 35 | ................ |
---|
[5417b3a] | 36 | |
---|
[d44763f] | 37 | Here is a :download:`simple script <../python/demos/demo_source_simple.py>` |
---|
| 38 | that reads all the samples from a media file: |
---|
[34abeaf] | 39 | |
---|
[d44763f] | 40 | .. literalinclude:: ../python/demos/demo_source_simple.py |
---|
| 41 | :language: python |
---|
[34abeaf] | 42 | |
---|
[5417b3a] | 43 | Filtering an input sound file |
---|
| 44 | ............................. |
---|
| 45 | |
---|
[d44763f] | 46 | Here is a more complete example, :download:`demo_filter.py |
---|
| 47 | <../python/demos/demo_filter.py>`. This files executes the following: |
---|
[5417b3a] | 48 | |
---|
| 49 | * read an input media file (``aubio.source``) |
---|
| 50 | |
---|
[d44763f] | 51 | * filter it using an `A-weighting <https://en.wikipedia.org/wiki/A-weighting>`_ |
---|
| 52 | filter (``aubio.digital_filter``) |
---|
[5417b3a] | 53 | |
---|
| 54 | * write result to a new file (``aubio.sink``) |
---|
| 55 | |
---|
| 56 | .. literalinclude:: ../python/demos/demo_filter.py |
---|
| 57 | :language: python |
---|
| 58 | |
---|
| 59 | More demos |
---|
| 60 | .......... |
---|
| 61 | |
---|
| 62 | Check out the `python demos folder`_ for more examples. |
---|
| 63 | |
---|
| 64 | Python tests |
---|
| 65 | ------------ |
---|
| 66 | |
---|
| 67 | A number of `python tests`_ are provided. To run them, use |
---|
| 68 | ``python/tests/run_all_tests``. |
---|
| 69 | |
---|
| 70 | .. _python demos folder: https://github.com/aubio/aubio/blob/master/python/demos |
---|
| 71 | .. _demo_filter.py: https://github.com/aubio/aubio/blob/master/python/demos/demo_filter.py |
---|
[d44763f] | 72 | .. _python tests: https://github.com/aubio/aubio/blob/master/python/tests |
---|
[34abeaf] | 73 | |
---|