SoundFileAnalysis:
Filter:
SoundFileAnalysis/Classes (extension) | Non-Realtime | Files

SoundFileAnalysis
ExtensionExtension

A simple system for non realtime soundfile analysis

Description

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:

Class Methods

.verbose

Post what's going on (default: false).

.new

Return a new SoundFileAnalysis Object

.initAnalysisMethods

Return a function with a dictionary of basic analysis methods (trig, average, direct).

.basicAnalysisMethods

A dictionary with the tree keys: \trig, \average, \direct. This dictionary (basicAnalysisMethods) can be extended.

trig
Write a value on receiveing a trigger
average
Average all values in the file
direct
Write a value on each frame

Instance Methods

.add

Add a new analysis method

Arguments:

name

Name for the method (a Symbol)

type

One of currently three types:

trig
Write one or more values on receiveing a trigger
direct
Write a value on each frame
average
Average all values in the file
ugenFunc

A function that returns a UGen graph. It takes the sound signal and the soundfile object as arguments.

.analysisMethods

Returns a dictionary of functions of currently defined methods.

.analyzeFile

Analyze a sound file, using the defined analysis methods. This method returns an Event with the following information:

~fileName, ~path, ~fileNumChannels
path and sound file information
~analysisStart, ~analysisDuration
What part of the file was analyzed
~dataDimensions
The results, each resulting from an analysis method (an Event)
~dataTable
The above results ordered as a multidimensional array

Arguments:

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 trimDuration is unspecified, the duration is no longer than the length of the file. Because only full blocks are written to the buffer, usually the last samples of a file are not analysed. Setting trimDuration allows you to specify what is supposed to happen with the last block or leaves the duration be as specified in the argument. (see example below)

\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)

.analyzeAll

Analyze all files given, returning a List of Events.

Arguments:

paths

A list of paths

Examples

Live audio analysis

Tests

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.