Package echonest :: Module audio :: Class AudioQuantumList
[hide private]
[frames] | no frames]

Class AudioQuantumList

source code


A container that enables content-based selection and filtering. A List that contains AudioQuantum objects, with additional methods for manipulating them.

When an AudioQuantumList is created for a track via a call to the Analyze API, attach() is called so that its container is set to the containing AudioAnalysis, and the container of each of the AudioQuantum list members is set to itself.

Additional accessors now include AudioQuantum elements such as start, duration, and confidence, which each return a List of the corresponding properties in the contained AudioQuanta. A special name is kinds, which returns a List of the kind of each AudioQuantum. If AudioQuantumList.kind is "segment", then pitches, timbre, loudness_begin, loudness_max, time_loudness_max, and loudness_end are available.

Instance Methods [hide private]
new list
__init__(self, kind=None, container=None)
Initializes an AudioQuantumList.
source code
call graph 
 
that(self, filt)
Method for applying a function to each of the contained AudioQuantum objects.
source code
call graph 
 
ordered_by(self, function, descending=False)
Returns a new AudioQuantumList of the same kind with the original elements, but ordered from low to high according to the input function acting as a key.
source code
call graph 
 
beget(self, source, which=None)
There are two basic forms: a map-and-flatten and an converse-that.
source code
 
attach(self, container)
Create circular references to the containing AudioAnalysis and for the contained AudioQuantum objects.
source code
 
__getstate__(self)
Eliminates the circular reference for pickling.
source code
 
__getattribute__(self, name)
In the case of AudioQuantum and AudioSegment accessors, return the corresponding ones from each of the contained AudioQuanta.
source code

Inherited from list: __add__, __contains__, __delitem__, __delslice__, __eq__, __ge__, __getitem__, __getslice__, __gt__, __hash__, __iadd__, __imul__, __iter__, __le__, __len__, __lt__, __mul__, __ne__, __new__, __repr__, __reversed__, __rmul__, __setitem__, __setslice__, append, count, extend, index, insert, pop, remove, reverse, sort

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__, __str__

Class Variables [hide private]
  QUANTUM_ATTRIBUTES = ['start', 'duration', 'confidence']
  SEGMENT_ATTRIBUTES = ['pitches', 'timbre', 'loudness_begin', '...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, kind=None, container=None)
(Constructor)

source code 
call graph 
Initializes an AudioQuantumList.
Parameters:
Returns: new list
Overrides: object.__init__

that(self, filt)

source code 
call graph 

Method for applying a function to each of the contained AudioQuantum objects. Returns a new AudioQuantumList of the same kind containing the AudioQuantum objects for which the input function is true.

See echonest.selection for example selection filters.

Parameters:
  • filt - a function that takes one AudioQuantum and returns a True value None

Change Log: experimenting with a filter-only form

ordered_by(self, function, descending=False)

source code 
call graph 

Returns a new AudioQuantumList of the same kind with the original elements, but ordered from low to high according to the input function acting as a key.

See echonest.sorting for example ordering functions.

Parameters:
  • function - a function that takes one AudioQuantum and returns a comparison key
  • descending - when True, reverses the sort order, from high to low

beget(self, source, which=None)

source code 

There are two basic forms: a map-and-flatten and an converse-that.

The basic form, with one function argument, returns a new AudioQuantumList so that the source function returns None, one, or many AudioQuanta for each AudioQuantum contained within self, and flattens them, in order.

beats.beget(the_next_ones)

A second form has the first argument source as an AudioQuantumList, and a second argument, which, is used as a filter for the first argument, for each of self. The results are collapsed and accordianned into a flat list.

For example, calling:

beats.beget(segments, which=overlap)

Gets evaluated as:

for beat in beats:
    return segments.that(overlap(beat))

And all of the AudioQuantumLists that return are flattened into a single AudioQuantumList. Note that the function passed to which must be a function that takes a single argument that returns a function returning a single argument.

Parameters:
  • source - A function of one argument that is applied to each AudioQuantum of self, or an AudioQuantumList, in which case the second argument is required.
  • which - A function of one argument that acts as a that() filter on the first argument if it is an AudioQuantumList, or as a filter on the output, in the case of source being a function.

__getattribute__(self, name)

source code 
In the case of AudioQuantum and AudioSegment accessors, return the corresponding ones from each of the contained AudioQuanta. If the attribute is kinds, do the same for each kind accessor. Otherwise, do normal attribute dispatch.
Overrides: object.__getattribute__

Class Variable Details [hide private]

SEGMENT_ATTRIBUTES

Value:
['pitches',
 'timbre',
 'loudness_begin',
 'loudness_max',
 'time_loudness_max',
 'loudness_end']