Hi Tom,
yes Beads can do this, but the analysis classes are quite basic and don’t employ the very best algorithms for analysis. However, the analysis classes like Power and PowerSpectrum are pretty solid.
The basic idea is that you set up a ShortFrameSegmenter. This is a UGen that has one input and no outputs. Like Clock it needs to be added as a dependent to be updated. It turns a stream of audio into a stream of overlapping grains for analysis.
ShortFrameSegmenter sfs = new ShortFrameSegmenter(ac);
ac.out.addDepdendent(sfs);
Then from there you start to add listeners in analysis chains.
FFT fft = new FFT();
sfs.addListener(fft);
PowerSpectrum ps = new PowerSpectrum();
fft.addListener(ps); //the power spectrum takes FFT as its input. It’s not obvious what chains are available unfortunately!
Then lastly, you need to add a segment listener which is where you receive the notification that you have new analysis data. Here’s the whole thing….
AudioContext ac = new AudioContext();
ShortFrameSegmenter sfs = new ShortFrameSegmenter(ac);
ac.out.addDependent(sfs);
FFT fft = new FFT();
sfs.addListener(fft);
PowerSpectrum ps = new PowerSpectrum();
fft.addListener(ps);
sfs.addSegmentListener(new SegmentListener() {
@Override
public void newSegment(TimeStamp timeStamp, TimeStamp timeStamp1) {
float[] psData = ps.getFeatures();
//do your stuff here
}
});
So based on this you may want to try writing your own feature extractors. Sorry the documentation for this stuff has never been very good.
Ollie