pyACA


NamepyACA JSON
Version 0.3.1 PyPI version JSON
download
home_pagehttps://github.com/alexanderlerch/pyACA
Summaryscripts accompanying the book An Introduction to Audio Content Analysis by Alexander Lerch
upload_time2022-02-28 19:30:28
maintainer
docs_urlNone
authorAlexander Lerch
requires_python
licenseMIT
keywords audio analysis features pitch key extraction music onset beat detection descriptors
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![GitHub top language](https://img.shields.io/github/languages/top/alexanderlerch/pyACA)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyACA)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/alexanderlerch/pyACA)
![GitHub issues](https://img.shields.io/github/issues-raw/alexanderlerch/pyACA)
[![CodeFactor](https://www.codefactor.io/repository/github/alexanderlerch/pyaca/badge)](https://www.codefactor.io/repository/github/alexanderlerch/pyaca)
![GitHub last commit](https://img.shields.io/github/last-commit/alexanderlerch/pyACA)
![GitHub](https://img.shields.io/github/license/alexanderlerch/pyACA)

# pyACA
Python scripts accompanying the book "An Introduction to Audio Content 
Analysis" (www.AudioContentAnalysis.org). The source code shows example implementations of basic approaches, features, and algorithms for music audio content analysis.

## functionality
The top-level functions are (alphabetical):
> - [`computeBeatHisto`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeBeatHisto.py): calculates a simple beat histogram
> - [`computeChords`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeChords.py): simple chord recognition
> - [`computeFeature`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeFeature.py): calculates instantaneous features 
> - [`computeFingerprint`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeFingerprint.py): audio fingerprint extraction 
> - [`computeKey`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeKey.py): calculates a simple key estimate
> - [`computeMelSpectrogram`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeMelSpectrogram.py): computes a mel spectrogram
> - [`computeNoveltyFunction`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeNoveltyFunction.py): simple onset detection
> - [`computePitch`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computePitch.py): calculates a fundamental frequency estimate
> - [`computeSpectrogram`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeSpectrogram.py): computes a magnitude spectrogram

The names of the additional functions follow the following 
conventions:
> - `Feature`*: instantaneous features
> - `Pitch`*: pitch tracking approach
> - `Novelty`*: novelty function computation
> - `Tool`*: additional helper functions and basic algorithms such as 
>   - [Blocking](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolBlockAudio.py) of audio into overlapping blocks
>   - [Pre-processing](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolPreprocAudio.py) audio
>   - Conversion ([freq2bark](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolFreq2Bark.py), [freq2mel](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolFreq2Mel.py), [freq2midi](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolFreq2Midi.py), [mel2freq](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/Mel2Freq.py), [midi2freq](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolMidi2Freq.py))
>   - Filterbank ([Gammatone](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolGammatoneFb.py))
>   - [Gaussian Mixture Model](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolGmm.py)
>   - [Principal Component Analysis](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolPca.py)
>   - [Feature Selection](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolSeqFeatureSel.py)
>   - [Dynamic Time Warping](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolSimpleDtw.py)
>   - [K-Means Clustering](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolSimpleKmeans.py)
>   - [K Nearest Neighbor classification](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolSimpleKnn.py)
>   - [Non-Negative Matrix Factorization](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolSimpleNmf.py)
>   - [Viterbi](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolViterbi.py) algorithm


## design principles
Please note that the provided code examples are only _intended to showcase 
algorithmic principles_ – they are not entirely suitable for practical usage without 
parameter optimization and additional algorithmic tuning. Rather, they intend to show how to implement audio analysis solutions and to facilitate algorithmic understanding to enable the reader to design and implement their own analysis approaches. 

### minimal dependencies
The _required dependencies_ are reduced to a minimum, more specifically to only [numpy](https://numpy.org/) and [scipy](https://scipy.org/), for the following reasons:
* accessibility, i.e., clear algorithmic implementation from scratch without obfuscation by using 3rd party implementations,
* maintainability through independence of 3rd party code. 
This design choice brings, however, some limitations; for instance, reading of non-RIFF audio files is not supported and the machine learning models are very simple.  

### readability
Consistent variable naming and formatting, as well as the choice for simple implementations allow for easier parsing.
The readability of the source code will sometimes come at the cost of lower performance.

### cross-language comparability
All code is matched exactly with [Matlab implementations](https://www.github.com/alexanderlerch/ACA=Code) and the equations in the book. This also means that the python code might **violate typical python style conventions** in order to be consistent.

## related repositories and links
The python source code in this repository is matched with corresponding source code in the [Matlab repository](https://www.github.com/alexanderlerch/ACA-Code).

Other, _related repositories_ are
* [ACA-Slides](https://www.github.com/alexanderlerch/ACA-Slides): slide decks for teaching and learning audio content analysis
* [ACA-Plots](https://www.github.com/alexanderlerch/ACA-Plots): Matlab scripts for generating all plots in the book and slides

The _main entry point_ to all book-related information is [AudioContentAnalysis.org](https://www.AudioContentAnalysis.org)

## getting started
### installation
```console
pip install pyACA 
```

### code examples

**example 1**: computation and plot of the _Spectral Centroid_

```python
import pyACA
import matplotlib.pyplot as plt 

# file to analyze
cPath = "c:/temp/test.wav"

# extract feature
[v, t] = pyACA.computeFeatureCl(cPath, "SpectralCentroid")

# plot feature output
plt.plot(t,np.squeeze(v))
```
**example 2**: Computation of two features (here: _Spectral Centroid_ and _Spectral Flux_)

```python
import pyACA

# read audio file
cPath = "c:/temp/test.wav"
[f_s, afAudioData] = pyACA.ToolReadAudio(cPath)

# compute feature
[vsc, t] = pyACA.computeFeature("SpectralCentroid", afAudioData, f_s)
[vsf, t] = pyACA.computeFeature("SpectralFlux", afAudioData, f_s)
```





            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/alexanderlerch/pyACA",
    "name": "pyACA",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "audio analysis features pitch key extraction music onset beat detection descriptors",
    "author": "Alexander Lerch",
    "author_email": "info@AudioContentAnalysis.org",
    "download_url": "https://files.pythonhosted.org/packages/e7/ec/59d9c127208221f57f2acd9f859f114c56e369649fe019436f00c9610900/pyACA-0.3.1.tar.gz",
    "platform": "",
    "description": "![GitHub top language](https://img.shields.io/github/languages/top/alexanderlerch/pyACA)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyACA)\n![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/alexanderlerch/pyACA)\n![GitHub issues](https://img.shields.io/github/issues-raw/alexanderlerch/pyACA)\n[![CodeFactor](https://www.codefactor.io/repository/github/alexanderlerch/pyaca/badge)](https://www.codefactor.io/repository/github/alexanderlerch/pyaca)\n![GitHub last commit](https://img.shields.io/github/last-commit/alexanderlerch/pyACA)\n![GitHub](https://img.shields.io/github/license/alexanderlerch/pyACA)\n\n# pyACA\nPython scripts accompanying the book \"An Introduction to Audio Content \nAnalysis\" (www.AudioContentAnalysis.org). The source code shows example implementations of basic approaches, features, and algorithms for music audio content analysis.\n\n## functionality\nThe top-level functions are (alphabetical):\n> - [`computeBeatHisto`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeBeatHisto.py): calculates a simple beat histogram\n> - [`computeChords`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeChords.py): simple chord recognition\n> - [`computeFeature`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeFeature.py): calculates instantaneous features \n> - [`computeFingerprint`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeFingerprint.py): audio fingerprint extraction \n> - [`computeKey`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeKey.py): calculates a simple key estimate\n> - [`computeMelSpectrogram`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeMelSpectrogram.py): computes a mel spectrogram\n> - [`computeNoveltyFunction`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeNoveltyFunction.py): simple onset detection\n> - [`computePitch`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computePitch.py): calculates a fundamental frequency estimate\n> - [`computeSpectrogram`](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/computeSpectrogram.py): computes a magnitude spectrogram\n\nThe names of the additional functions follow the following \nconventions:\n> - `Feature`*: instantaneous features\n> - `Pitch`*: pitch tracking approach\n> - `Novelty`*: novelty function computation\n> - `Tool`*: additional helper functions and basic algorithms such as \n>   - [Blocking](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolBlockAudio.py) of audio into overlapping blocks\n>   - [Pre-processing](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolPreprocAudio.py) audio\n>   - Conversion ([freq2bark](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolFreq2Bark.py), [freq2mel](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolFreq2Mel.py), [freq2midi](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolFreq2Midi.py), [mel2freq](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/Mel2Freq.py), [midi2freq](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolMidi2Freq.py))\n>   - Filterbank ([Gammatone](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolGammatoneFb.py))\n>   - [Gaussian Mixture Model](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolGmm.py)\n>   - [Principal Component Analysis](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolPca.py)\n>   - [Feature Selection](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolSeqFeatureSel.py)\n>   - [Dynamic Time Warping](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolSimpleDtw.py)\n>   - [K-Means Clustering](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolSimpleKmeans.py)\n>   - [K Nearest Neighbor classification](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolSimpleKnn.py)\n>   - [Non-Negative Matrix Factorization](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolSimpleNmf.py)\n>   - [Viterbi](https://github.com/alexanderlerch/pyACA/blob/master/pyACA/ToolViterbi.py) algorithm\n\n\n## design principles\nPlease note that the provided code examples are only _intended to showcase \nalgorithmic principles_ \u2013 they are not entirely suitable for practical usage without \nparameter optimization and additional algorithmic tuning. Rather, they intend to show how to implement audio analysis solutions and to facilitate algorithmic understanding to enable the reader to design and implement their own analysis approaches. \n\n### minimal dependencies\nThe _required dependencies_ are reduced to a minimum, more specifically to only [numpy](https://numpy.org/) and [scipy](https://scipy.org/), for the following reasons:\n* accessibility, i.e., clear algorithmic implementation from scratch without obfuscation by using 3rd party implementations,\n* maintainability through independence of 3rd party code. \nThis design choice brings, however, some limitations; for instance, reading of non-RIFF audio files is not supported and the machine learning models are very simple.  \n\n### readability\nConsistent variable naming and formatting, as well as the choice for simple implementations allow for easier parsing.\nThe readability of the source code will sometimes come at the cost of lower performance.\n\n### cross-language comparability\nAll code is matched exactly with [Matlab implementations](https://www.github.com/alexanderlerch/ACA=Code) and the equations in the book. This also means that the python code might **violate typical python style conventions** in order to be consistent.\n\n## related repositories and links\nThe python source code in this repository is matched with corresponding source code in the [Matlab repository](https://www.github.com/alexanderlerch/ACA-Code).\n\nOther, _related repositories_ are\n* [ACA-Slides](https://www.github.com/alexanderlerch/ACA-Slides): slide decks for teaching and learning audio content analysis\n* [ACA-Plots](https://www.github.com/alexanderlerch/ACA-Plots): Matlab scripts for generating all plots in the book and slides\n\nThe _main entry point_ to all book-related information is [AudioContentAnalysis.org](https://www.AudioContentAnalysis.org)\n\n## getting started\n### installation\n```console\npip install pyACA \n```\n\n### code examples\n\n**example 1**: computation and plot of the _Spectral Centroid_\n\n```python\nimport pyACA\nimport matplotlib.pyplot as plt \n\n# file to analyze\ncPath = \"c:/temp/test.wav\"\n\n# extract feature\n[v, t] = pyACA.computeFeatureCl(cPath, \"SpectralCentroid\")\n\n# plot feature output\nplt.plot(t,np.squeeze(v))\n```\n**example 2**: Computation of two features (here: _Spectral Centroid_ and _Spectral Flux_)\n\n```python\nimport pyACA\n\n# read audio file\ncPath = \"c:/temp/test.wav\"\n[f_s, afAudioData] = pyACA.ToolReadAudio(cPath)\n\n# compute feature\n[vsc, t] = pyACA.computeFeature(\"SpectralCentroid\", afAudioData, f_s)\n[vsf, t] = pyACA.computeFeature(\"SpectralFlux\", afAudioData, f_s)\n```\n\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "scripts accompanying the book An Introduction to Audio Content Analysis by Alexander Lerch",
    "version": "0.3.1",
    "project_urls": {
        "Homepage": "https://github.com/alexanderlerch/pyACA"
    },
    "split_keywords": [
        "audio",
        "analysis",
        "features",
        "pitch",
        "key",
        "extraction",
        "music",
        "onset",
        "beat",
        "detection",
        "descriptors"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "27ef604e8170f50d7a8f21afbd871010d5ac530bc8c7ad767028cb8fcb2e96a7",
                "md5": "ba0f6327347a23a72b708c7a6b71a48b",
                "sha256": "c94b673cf9ff5c6958c5e37e3dffc638f4ccfbbd5841637ce791eb876c44b9ce"
            },
            "downloads": -1,
            "filename": "pyACA-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ba0f6327347a23a72b708c7a6b71a48b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 57054,
            "upload_time": "2022-02-28T19:30:26",
            "upload_time_iso_8601": "2022-02-28T19:30:26.943096Z",
            "url": "https://files.pythonhosted.org/packages/27/ef/604e8170f50d7a8f21afbd871010d5ac530bc8c7ad767028cb8fcb2e96a7/pyACA-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e7ec59d9c127208221f57f2acd9f859f114c56e369649fe019436f00c9610900",
                "md5": "b836cace6c7d8b0e4626eda6c905c617",
                "sha256": "ab4240b274e78dd76aaec3e2741992f3ad7d2e4814096cb1a14236b4005f4840"
            },
            "downloads": -1,
            "filename": "pyACA-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b836cace6c7d8b0e4626eda6c905c617",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 103630,
            "upload_time": "2022-02-28T19:30:28",
            "upload_time_iso_8601": "2022-02-28T19:30:28.421177Z",
            "url": "https://files.pythonhosted.org/packages/e7/ec/59d9c127208221f57f2acd9f859f114c56e369649fe019436f00c9610900/pyACA-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-02-28 19:30:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "alexanderlerch",
    "github_project": "pyACA",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pyaca"
}
        
Elapsed time: 0.18517s