This class provides a relatively simple way to do custom non realtime signal analysis. Using live recorded buffers, it can do the processing in the background while the recording continues. Its input is a soundfile, its output is a dataset formatted as an event.
(be aware that by default sound files are only analysed for n*serverOptions.blockSize<SoundFile.duration please look at the trimDuration argument for details.)
A simple example:
Post what's going on (default: false).
Return a new SoundFileAnalysis Object
Return a function with a dictionary of basic analysis methods (trig, average, direct).
A dictionary with the tree keys: \trig, \average, \direct. This dictionary (basicAnalysisMethods) can be extended.
Add a new analysis method
name |
Name for the method (a Symbol) |
type |
One of currently three types:
|
ugenFunc |
A function that returns a UGen graph. It takes the sound signal and the soundfile object as arguments. |
Returns a dictionary of functions of currently defined methods.
Analyze a sound file, using the defined analysis methods. This method returns an Event with the following information:
path |
Path to the soundfile |
start |
Start frame index for analysis |
duration |
Analysis duration in seconds |
which |
Which methods to use (an array of names as symbols). If none is given, use all. |
callback |
A function that is called when analysis is completed. It takes the result (an event) as argument. |
maxDataPoints |
A limit on the number of points added to the data. |
trimDuration |
When \roundDown analyses the file until the full last block. \roundUp analyses the file and adds silence to fill the last block. nil leaves the duration as given in the argument. |
serverOptions |
ServerOptions for the NRT server. A way to deal with the last half block problem is to set the blockSize to 1. (see example below) |
Example of three ways about how to deal with the last block problem.
In the following example the number of zerocrossing in a file is written in the last block of the calculation.
With the default values the result will be empty:
Only if the last block is included by setting the trimDuration to \roundUp the result is printed:
It is not enough to provide a duration that is the amount of samples longer to fill the last block. because by default the duration is trimmed to the sample length:
One can freely set the duration if one set trimDuration to nil:
Or one can use a server with the blockSize of 1. But this is less efficient.