Package: pyACA
pyACAPython 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.functionalityThe top-level functions are (alphabetical):computeBeatHisto: calculates a simple beat histogramcomputeChords: simple chord recognitioncomputeFeature: calculates instantaneous featurescomputeFingerprint: audio fingerprint extractioncomputeKey: calculates a simple key estimatecomputeMelSpectrogram: computes a mel spectrogramcomputeNoveltyFunction: simple onset detectioncomputePitch: calculates a fundamental frequency estimatecomputeSpectrogram: computes a magnitude spectrogramThe names of the additional functions follow the following
conventions:Feature*: instantaneous featuresPitch*: pitch tracking approachNovelty*: novelty function computationTool*: additional helper functions and basic algorithms such asBlockingof audio into overlapping blocksPre-processingaudioConversion (freq2bark,freq2mel,freq2midi,mel2freq,midi2freq)Filterbank (Gammatone)Gaussian Mixture ModelPrincipal Component AnalysisFeature SelectionDynamic Time WarpingK-Means ClusteringK Nearest Neighbor classificationNon-Negative Matrix FactorizationViterbialgorithmdesign principlesPlease note that the provided code examples are onlyintended 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 dependenciesTherequired dependenciesare reduced to a minimum, more specifically to onlynumpyandscipy, 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.readabilityConsistent 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 comparabilityAll code is matched exactly withMatlab implementationsand the equations in the book. This also means that the python code mightviolate typical python style conventionsin order to be consistent.related repositories and linksThe python source code in this repository is matched with corresponding source code in theMatlab repository.Other,related repositoriesareACA-Slides: slide decks for teaching and learning audio content analysisACA-Plots: Matlab scripts for generating all plots in the book and slidesThemain entry pointto all book-related information isAudioContentAnalysis.orggetting startedinstallationpip install pyACAcode examplesexample 1: computation and plot of theSpectral CentroidimportpyACAimportmatplotlib.pyplotasplt# file to analyzecPath="c:/temp/test.wav"# extract feature[v,t]=pyACA.computeFeatureCl(cPath,"SpectralCentroid")# plot feature outputplt.plot(t,np.squeeze(v))example 2: Computation of two features (here:Spectral CentroidandSpectral Flux)importpyACA# read audio filecPath="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)