- Timestamp:
- Nov 26, 2018, 10:33:30 PM (6 years ago)
- Branches:
- feature/constantq
- Children:
- 868c6b8
- Parents:
- d1d4ad4 (diff), db3eb5c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- python
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
python/README.md
rd1d4ad4 rf87e191 1 Python aubio module 2 ===== ==============1 aubio 2 ===== 3 3 4 This module wraps the aubio library for Python using the numpy module.4 aubio is a collection of tools for music and audio analysis. 5 5 6 Using the Python aubio module 7 ----------------------------- 6 This package integrates the aubio library with [NumPy] to provide a set of 7 efficient tools to process and analyse audio signals, including: 8 8 9 After 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 $ python 12 [...] 13 >>> import aubio 14 >>> help(aubio.miditofreq) 16 aubio works with both Python 2 and Python 3. 15 17 16 Finding some inspiration 17 ----- -------------------18 Links 19 ----- 18 20 19 Some examples are available in the `python/demos` directory. These scripts are 20 small programs written in python and using python-aubio. 21 - [module documentation][doc_python] 22 - [installation instructions][doc_python_install] 23 - [aubio manual][manual] 24 - [aubio homepage][homepage] 25 - [issue tracker][bugtracker] 21 26 22 For instance, `demo_source.py` reads a media file. 27 Demos 28 ----- 23 29 24 $ ./python/demos/demo_source.py /path/to/sound/sample.wav 30 Some examples are available in the [`python/demos`][demos_dir] folder. Each 31 script is a command line program which accepts one ore more argument. 25 32 26 and `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 30 Note: you might need to install additional modules to run some of the demos. 31 Some demos use [matplotlib](http://matplotlib.org/) to draw plots, others use 32 [PySoundCard](https://github.com/bastibe/PySoundCard) to play and record 33 sounds. 37 - `demo_source.py` uses aubio to read audio samples from media files 38 - `demo_onset_plot.py` detects attacks in a sound file and plots the results 39 using [matplotlib] 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 35 Testing the Python module 36 ------------------------- 45 ### Real-time 37 46 38 Python tests are in `python/tests` and use the [nose2 python package][nose2]. 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 40 To run the all the python tests, use the script: 51 ### Others 41 52 42 $ ./python/tests/run_all_tests 53 - `demo_timestretch.py` can change the duration of an input file and write the 54 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 43 57 44 Each test script can also be called one at a time. For instance: 58 ### Example 45 59 46 $ ./python/tests/test_note2midi.py -v 60 Use `demo_timestretch_online.py` to slow down `loop.wav`, write the results in 61 `stretched_loop.wav`: 47 62 48 [nose2]: https://github.com/nose-devs/nose263 $ python demo_timestretch_online.py loop.wav stretched_loop.wav 0.92 49 64 50 Install in a virtualenv 51 ----------------------- 52 53 You should be able to install python-aubio directly from the top source 54 directory of aubio. 55 56 First, create a virtualenv to hold the required python module: 57 58 $ virtualenv pyaubio 59 $ source pyaubio/bin/activate 60 61 Now install and build the python extension using: 62 63 $ pip install . 64 65 Install requirements 66 -------------------- 67 68 Before compiling this module, you must have compiled libaubio. 69 70 A simple way to do this is with pip: 71 72 $ pip install -r requirements.txt 73 74 For more information about how this module works, please refer to the [Python/C 75 API 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 78 Compiling python aubio 79 ---------------------- 80 81 To build the aubio Python module, run the following command from the top source 82 directory of aubio: 83 84 $ ./setup.py build 85 86 Note: if libaubio was previously built using waf, the script will use it. 87 Otherwise, the entire library will be built inside the python extension. 88 89 To find out more about `setup.py` options: 90 91 $ ./setup.py --help 92 93 Installing 65 Built with 94 66 ---------- 95 67 96 To install the Python module: 68 The core of aubio is written in C for portability and speed. In addition to 69 [NumPy], aubio can be optionally built to use one or more of the following 70 libraries: 97 71 98 $ ./setup.py install 72 - media file reading: 99 73 100 Alternatively, you may want to use the Python module without installing it by 101 setting your PYTHONPATH, for instance as follows: 74 - [ffmpeg] / [avcodec] to decode and read audio from almost any format, 75 - [libsndfile] to read audio from uncompressed sound files, 76 - [libsamplerate] to re-sample audio signals, 77 - [CoreAudio] to read all media formats supported by macOS, iOS, and tvOS. 102 78 103 $ export PYTHONPATH=$PYTHONPATH:$PWD/`ls -rtd build/lib.* | head -1`:$PWD/tests 79 - hardware acceleration: 104 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_phasevoc.py
rd1d4ad4 rf87e191 56 56 + 'This is expected when using fftw3 on powerpc.') 57 57 assert_equal ( r, 0.) 58 59 def test_no_overlap(self): 60 win_s, hop_s = 1024, 1024 61 f = pvoc (win_s, hop_s) 62 t = fvec (hop_s) 63 for _ in range(4): 64 s = f(t) 65 r = f.rdo(s) 66 assert_equal ( t, 0.) 58 67 59 68 @params( -
python/tests/test_source_channels.py
rd1d4ad4 rf87e191 9 9 import numpy as np 10 10 from numpy.testing import assert_equal 11 from utils import get_tmp_sink_path11 from .utils import get_tmp_sink_path 12 12 13 13 class aubio_source_test_case(unittest.TestCase):
Note: See TracChangeset
for help on using the changeset viewer.