Song Property Analyzer beaTlets
As you know, beaTunes has the ability to analyze music files at the audio signal level. Features one might want to extract from the signal are e.g. key, beats per minute (bpm) or time signature (4/4, 3/4, ...). For this kind of analysis, beaTunes uses Jipes. Jipes is an open source digtal signal processing (DSP) library that was created in the process of improving beaTunes. It lets you define a pipeline of processors that transform the signal until you obtain the desired feature. For examples on how to use Jipes, please refer to its documentation. BTW, contrary to Jipes, beaTunes uses native FFT implementations on both OS X and Windows.
While beaTunes can't write your Jipes DSP code for you, it makes it extraordinarily easy to integrate.
You just need to implement the com.tagtraum.audiokern.SongPropertyAnalyzer interface, which
basically serves as a factory for your pipeline and tells beaTunes which song property to write the result
to.
The pipeline itself can rely on the pumped AudioBuffers having a sample rate of 44.1kHz,
two channels, being signed, and 16 bits/sample (i.e. values are floats, but in the range of shorts).
To map the signal to a value range between -1 and 1, you might want to use
new Mapping<AudioBuffer>(AudioBufferFunctions.createMapFunction(MapFunctions.createShortToOneNormalization())).
To make sure that beaTunes picks the correct result from the pipeline, you must give the processor that delivers the feature, an id that is identical to the property name. Typically the last processor in the pipeline is the one that computes the feature. The property name also makes sure that beaTunes knows how to display your analyzer in the beaTunes analysis options dialog.
Because feature extraction is nontrivial, the following examples don't actually compute anything. They are merely meant as illustrations for how to integrate your own pipeline.
from com.tagtraum.audiokern import AudioClip
from com.tagtraum.audiokern import SongPropertyAnalyzer
from com.tagtraum.jipes.audio import Mono
# Simple song property analyzer.
class KeyAnalyzer(SongPropertyAnalyzer):
# Name of this analyzer. Please include a version number.
def getName(self):
return "Jython KeyAnalyzer 1.0.0"
# How much audio do we need?
def getRequiredClip(self, audioFileFormat):
# AudioClip takes start and stop times in ms
return AudioClip(0, 120000)
# Create a new pipeline. See Jipes for details.
def createPipeline(self):
# Mono does not compute a key. It's merely a stand-in for a real
# com.tagtraum.jipes.SignalPipeline
# The id of the processor that computes the key, must be "key".
return Mono()
# The property you want to change.
# This corresponds to com.tagtraum.audiokern.AudioSong properties.
def getPropertyName(self):
return "key"

