Core API¶
Audio¶
-
class
amen.audio.
Audio
(file_path=None, raw_samples=None, convert_to_mono=False, sample_rate=44100, analysis_sample_rate=22050)[source]¶ The base Audio object: wraps the ouput from librosa, and provides access to features
Attributes
sample_rate: number sample rate raw_samples: numpy array raw samples from the audio analysis_samples: numpy array downsampled samples for analysis num_channels: integer number of channels of the audio duration: float duration, in seconds features: dict collection of named feature objects Methods
output
-
output
(filename, format=None)[source]¶ Write the samples out to the given filename.
Parameters: filename : str
The path to write the audio on disk. This can be any format supported by pysoundfile, including WAV, FLAC, or OGG (but not mp3).
format : str
If provided, explicitly set the output encoding format. See soundfile.available_formats.
-
Advanced functionality¶
Feature¶
Container classes for feature analysis
-
class
amen.feature.
Feature
(data, aggregate=<Mock name='mock.mean' id='140402776451280'>, base=None, time_slices=None)[source]¶ Core feature container object. Handles indexing and time-slicing.
- at(time_slices)
- Resample the feature at the given TimeSlices
Methods
at
(time_slices)Resample the data at a new time slice index. with_time
()Allows iteration over a time-indexed feature and the associated timeslices.
-
class
amen.feature.
FeatureCollection
[source]¶ A dictionary of features.
Delegates .at to the features it contains.
Allows for selection of multiple keys, which returns a smaller feature collection.
Methods
at
(time_slices)Resample each feature at a new time slice index. clear
(() -> None. Remove all items from D.)copy
(() -> a shallow copy of D)fromkeys
(...)v defaults to None. get
(keys)Get a subset of the keys in the correct feature collection has_key
((k) -> True if D has a key k, else False)items
(() -> list of D’s (key, value) pairs, ...)iteritems
(() -> an iterator over the (key, ...)iterkeys
(() -> an iterator over the keys of D)itervalues
(...)keys
(() -> list of D’s keys)pop
((k[,d]) -> v, ...)If key is not found, d is returned if given, otherwise KeyError is raised popitem
(() -> (k, v), ...)2-tuple; but raise KeyError if D is empty. setdefault
((k[,d]) -> D.get(k,d), ...)update
(([E, ...)If E present and has a .keys() method, does: for k in E: D[k] = E[k] values
(() -> list of D’s values)viewitems
(...)viewkeys
(...)viewvalues
(...)with_time
()Allows iteration over a time-indexed feature and the associated timeslices. -
at
(time_slices)[source]¶ Resample each feature at a new time slice index.
Parameters: time_slices : TimeSlice or TimeSlice collection
The time slices at which to index this feature object
Returns: new_features : FeatureCollection
The resampled feature data
-
Timing¶
Timing interface
-
class
amen.timing.
TimeSlice
(time, duration, audio, unit='s')[source]¶ A slice of time: has a start time, a duration, and a reference to an Audio object.
Methods
get_samples
()Gets the samples corresponding to this TimeSlice from the parent audio object.
-
class
amen.timing.
TimingList
(name, timings, audio, unit='s')[source]¶ A list of TimeSlices.
Methods
append
L.append(object) – append object to end count
(...)extend
L.extend(iterable) – extend list by appending elements from the iterable index
((value, [start, ...)Raises ValueError if the value is not present. insert
L.insert(index, object) – insert object before index pop
(...)Raises IndexError if list is empty or index is out of range. remove
L.remove(value) – remove first occurrence of value. reverse
L.reverse() – reverse IN PLACE sort
L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE;