History

Merge branch 'master' into feature/pytest

Paul Brossier committed 7 years ago

Commit e893e6f2 parents bf3f09b c4a8bc115 files · +299 −128Browse files

Showing the changes to python (2 of 15 files). Show all

Unified · Split

2 files
  1. python/README.md +88 −84
  2. python/tests/test_source_channels.py +1 −1
python/README.md+88−84
@@ -1,105 +1,109 @@
1Python aubio module1aubio
2===================2=====
3 3
4This module wraps the aubio library for Python using the numpy module.4aubio is a collection of tools for music and audio analysis.
5 5
6Using the Python aubio module6This package integrates the aubio library with [NumPy] to provide a set of
7-----------------------------7efficient tools to process and analyse audio signals, including:
8 8
9After installing python-aubio, you will be able to import the aubio module:9- read audio from any media file, including videos and remote streams
10- high quality phase vocoder, spectral filterbanks, and linear filters
11- Mel-Frequency Cepstrum Coefficients and standard spectral descriptors
12- detection of note attacks (onset)
13- pitch tracking (fundamental frequency estimation)
14- beat detection and tempo tracking
10 15
11 $ python16aubio works with both Python 2 and Python 3.
12 [...]
13 >>> import aubio
14 >>> help(aubio.miditofreq)
15 17
16Finding some inspiration18Links
17------------------------19-----
18 20
19Some examples are available in the `python/demos` directory. These scripts are21- [module documentation][doc_python]
20small programs written in python and using python-aubio.22- [installation instructions][doc_python_install]
23- [aubio manual][manual]
24- [aubio homepage][homepage]
25- [issue tracker][bugtracker]
21 26
22For instance, `demo_source.py` reads a media file.27Demos
28-----
23 29
24 $ ./python/demos/demo_source.py /path/to/sound/sample.wav30Some examples are available in the [`python/demos`][demos_dir] folder. Each
31script is a command line program which accepts one ore more argument.
25 32
26and `demo_timestretch_online.py` stretches the original file into a new one:33**Notes**: installing additional modules is required to run some of the demos.
27 34
28 $ ./python/demo/demo_timestretch_online.py loop.wav stretched_loop.wav 0.92`35### Analysis
29 36
30Note: you might need to install additional modules to run some of the demos.37- `demo_source.py` uses aubio to read audio samples from media files
31Some demos use [matplotlib](http://matplotlib.org/) to draw plots, others use38- `demo_onset_plot.py` detects attacks in a sound file and plots the results
32[PySoundCard](https://github.com/bastibe/PySoundCard) to play and record39 using [matplotlib]
33sounds.40- `demo_pitch.py` looks for fundamental frequency in a sound file and plots the
41 results using [matplotlib]
42- `demo_spectrogram.py`, `demo_specdesc.py`, `demo_mfcc.py` for spectral
43 analysis.
34 44
35Testing the Python module45### Real-time
36-------------------------
37 46
38Python tests are in `python/tests` and use [pytest].47- `demo_pyaudio.py` and `demo_tapthebeat.py` use [pyaudio]
48- `demo_pysoundcard_play.py`, `demo_pysoundcard.py` use [PySoundCard]
49- `demo_alsa.py` uses [pyalsaaudio]
39 50
40To run the all the python tests:51### Others
41 52
42 $ cd aubio53- `demo_timestretch.py` can change the duration of an input file and write the
43 $ pytest54 new sound to disk,
55- `demo_wav2midi.py` detects the notes in a file and uses [mido] to write the
56 results into a MIDI file
44 57
45Each test script can also be called one at a time. For instance:58### Example
46 59
47 $ pytest -v python/tests/test_note2midi.py60Use `demo_timestretch_online.py` to slow down `loop.wav`, write the results in
61`stretched_loop.wav`:
48 62
49[pytest]: https://pytest.org63 $ python demo_timestretch_online.py loop.wav stretched_loop.wav 0.92
50 64
51Install in a virtualenv65Built with
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----------66----------
96 67
97To install the Python module:68The core of aubio is written in C for portability and speed. In addition to
98 69[NumPy], aubio can be optionally built to use one or more of the following
99 $ ./setup.py install70libraries:
100 71
101Alternatively, you may want to use the Python module without installing it by72- media file reading:
102setting your PYTHONPATH, for instance as follows:73
103 74 - [ffmpeg] / [avcodec] to decode and read audio from almost any format,
104 $ export PYTHONPATH=$PYTHONPATH:$PWD/`ls -rtd build/lib.* | head -1`:$PWD/tests75 - [libsndfile] to read audio from uncompressed sound files,
105 76 - [libsamplerate] to re-sample audio signals,
77 - [CoreAudio] to read all media formats supported by macOS, iOS, and tvOS.
78
79- hardware acceleration:
80
81 - [Atlas] and [Blas], for accelerated vector and matrix computations,
82 - [fftw3], to compute fast Fourier Transforms of any size,
83 - [Accelerate] for accelerated FFT and matrix computations (macOS/iOS),
84 - [Intel IPP], accelerated vector computation and FFT implementation.
85
86[ffmpeg]: https://ffmpeg.org
87[avcodec]: https://libav.org
88[libsndfile]: http://www.mega-nerd.com/libsndfile/
89[libsamplerate]: http://www.mega-nerd.com/SRC/
90[CoreAudio]: https://developer.apple.com/reference/coreaudio
91[Atlas]: http://math-atlas.sourceforge.net/
92[Blas]: https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms
93[fftw3]: http://fftw.org
94[Accelerate]: https://developer.apple.com/reference/accelerate
95[Intel IPP]: https://software.intel.com/en-us/intel-ipp
96
97[demos_dir]:https://github.com/aubio/aubio/tree/master/python/demos
98[pyaudio]:https://people.csail.mit.edu/hubert/pyaudio/
99[PySoundCard]:https://github.com/bastibe/PySoundCard
100[pyalsaaudio]:https://larsimmisch.github.io/pyalsaaudio/
101[mido]:https://mido.readthedocs.io
102
103[manual]: https://aubio.org/manual/latest/
104[doc_python]: https://aubio.org/manual/latest/python.html
105[doc_python_install]: https://aubio.org/manual/latest/python_module.html
106[homepage]: https://aubio.org
107[NumPy]: https://www.numpy.org
108[bugtracker]: https://github.com/aubio/aubio/issues
109[matplotlib]:https://matplotlib.org/
python/tests/test_source_channels.py+1−1
@@ -8,7 +8,7 @@ import unittest · 7 unmodified lines
8import aubio8import aubio
9import numpy as np9import numpy as np
10from numpy.testing import assert_equal10from numpy.testing import assert_equal
11from utils import get_tmp_sink_path11from .utils import get_tmp_sink_path
12 12
13class aubio_source_test_case(unittest.TestCase):13class aubio_source_test_case(unittest.TestCase):
14 14

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t