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

Class AudioData

source code


Handles audio data transparently. A smart audio container with accessors that include:

sampleRate
samples per second
numChannels
number of channels
data
a numpy.array
Instance Methods [hide private]
 
__init__(self, filename=None, ndarray=None, shape=None, sampleRate=None, numChannels=None, defer=False, verbose=True)
Given an input ndarray, import the sample values and shape (if none is specified) of the input numpy.array.
source code
 
load(self) source code
 
__getitem__(self, index)
Fetches a frame or slice. Returns an individual frame (if the index is a time offset float or an integer sample number) or a slice if the index is an AudioQuantum (or quacks like one).
source code
 
getslice(self, index)
Help __getitem__ return a new AudioData for a given slice
source code
 
getsample(self, index)
Help __getitem__ return a frame (all channels for a given sample index)
source code
 
pad_with_zeros(self, num_samples) source code
 
append(self, another_audio_data)
Appends the input to the end of this AudioData.
source code
 
sum(self, another_audio_data) source code
 
add_at(self, time, another_audio_data)
Adds the input another_audio_data to this AudioData at the time specified in seconds.
source code
 
__len__(self) source code
 
__add__(self, other)
Supports stuff like this: sound3 = sound1 + sound2
source code
 
encode(self, filename=None, mp3=None)
Outputs an MP3 or WAVE file to filename. Format is determined by mp3 parameter.
source code
 
unload(self) source code
 
render(self, start=0.0, to_audio=None, with_source=None) source code

Inherited from AudioRenderable: resolve_source, sources

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]

Inherited from AudioRenderable: init_audio_data

Properties [hide private]
  duration
  source

Inherited from object: __class__

Method Details [hide private]

__init__(self, filename=None, ndarray=None, shape=None, sampleRate=None, numChannels=None, defer=False, verbose=True)
(Constructor)

source code 

Given an input ndarray, import the sample values and shape (if none is specified) of the input numpy.array.

Given a filename (and an input ndarray), use ffmpeg to convert the file to wave, then load the file into the data, auto-detecting the sample rate, and number of channels.

Parameters:
  • filename - a path to an audio file for loading its sample data into the AudioData.data
  • ndarray - a numpy.array instance with sample data
  • shape - a tuple of array dimensions
  • sampleRate - sample rate, in Hz
  • numChannels - number of channels
Overrides: object.__init__

encode(self, filename=None, mp3=None)

source code 
Outputs an MP3 or WAVE file to filename. Format is determined by mp3 parameter.
Overrides: AudioRenderable.encode

Property Details [hide private]

duration

Get Method:
unreachable.duration(self)

source

Get Method:
unreachable.source(self)