[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 | |
---|
[3d8a6c0] | 13 | .. code-block:: console |
---|
[241e2fb] | 14 | |
---|
| 15 | $ pip install aubio |
---|
| 16 | |
---|
[34abeaf] | 17 | Building the module |
---|
| 18 | ------------------- |
---|
| 19 | |
---|
| 20 | From ``aubio`` source directory, run the following: |
---|
| 21 | |
---|
[3d8a6c0] | 22 | .. code-block:: console |
---|
[34abeaf] | 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 | |
---|
[109ba42] | 31 | Once the python module is installed, its version can be checked with: |
---|
| 32 | |
---|
| 33 | .. code-block:: console |
---|
| 34 | |
---|
| 35 | $ python -c "import aubio; print(aubio.version, aubio.float_type)" |
---|
| 36 | |
---|
| 37 | The command line `aubio` is also installed: |
---|
| 38 | |
---|
| 39 | .. code-block:: console |
---|
| 40 | |
---|
| 41 | $ aubio -h |
---|
[34abeaf] | 42 | |
---|
[d44763f] | 43 | A simple example |
---|
| 44 | ................ |
---|
[5417b3a] | 45 | |
---|
[d44763f] | 46 | Here is a :download:`simple script <../python/demos/demo_source_simple.py>` |
---|
| 47 | that reads all the samples from a media file: |
---|
[34abeaf] | 48 | |
---|
[d44763f] | 49 | .. literalinclude:: ../python/demos/demo_source_simple.py |
---|
| 50 | :language: python |
---|
[34abeaf] | 51 | |
---|
[5417b3a] | 52 | Filtering an input sound file |
---|
| 53 | ............................. |
---|
| 54 | |
---|
[d44763f] | 55 | Here is a more complete example, :download:`demo_filter.py |
---|
| 56 | <../python/demos/demo_filter.py>`. This files executes the following: |
---|
[5417b3a] | 57 | |
---|
| 58 | * read an input media file (``aubio.source``) |
---|
| 59 | |
---|
[d44763f] | 60 | * filter it using an `A-weighting <https://en.wikipedia.org/wiki/A-weighting>`_ |
---|
| 61 | filter (``aubio.digital_filter``) |
---|
[5417b3a] | 62 | |
---|
| 63 | * write result to a new file (``aubio.sink``) |
---|
| 64 | |
---|
| 65 | .. literalinclude:: ../python/demos/demo_filter.py |
---|
| 66 | :language: python |
---|
| 67 | |
---|
| 68 | More demos |
---|
| 69 | .......... |
---|
| 70 | |
---|
| 71 | Check out the `python demos folder`_ for more examples. |
---|
| 72 | |
---|
| 73 | Python tests |
---|
| 74 | ------------ |
---|
| 75 | |
---|
| 76 | A number of `python tests`_ are provided. To run them, use |
---|
| 77 | ``python/tests/run_all_tests``. |
---|
| 78 | |
---|
| 79 | .. _python demos folder: https://github.com/aubio/aubio/blob/master/python/demos |
---|
| 80 | .. _demo_filter.py: https://github.com/aubio/aubio/blob/master/python/demos/demo_filter.py |
---|
[d44763f] | 81 | .. _python tests: https://github.com/aubio/aubio/blob/master/python/tests |
---|