new VowelWorm.instance(stream)
Contains methods used in the analysis of vowel audio data
Name | Type | Description |
---|---|---|
stream |
* | The audio stream to analyze OR a string representing the URL for an audio file |
Namespaces
Members
-
nullablemodenumber
-
The current mode the vowel worm is in (e.g., stream, audio element, etc.)
Methods
-
destroy()
-
Removes reference to this particular worm instance as well as all properties of it.
-
getFFT()
-
Retrieves the current FFT data of the audio source. NOTE: this returns a reference to the internal buffer used to store this information. It WILL change. If you need to store it, iterate through it and make a copy. The reason this doesn't return a new Float32Array is because Google Chrome (as of v. 36) does not adequately garbage collect new Float32Arrays. Best to keep them to a minimum.
Example
var w = new VowelWorm.instance(audioelement), fft = w.getFFT(); // store a copy for later var saved_data = []; for(var i = 0; i<fft.length; i++) { saved_data[i] = fft[i]; }
-
getFFTSize(){number}
-
The size of the FFT, in bins
-
getFormants(data, sampleRate){Array.<number>}
-
Retrieves formants. Uses the current time of the audio file or stream, unless data is passed in.
Name Type Description data
Array.<number> optional FFT transformation data. If null, pulls from the analyzer sampleRate
number optional the sample rate of the data. Required if data is not null Returns:
formants found for the audio stream/file. If nothing worthwhile has been found, returns an empty array.
-
getMFCCs(options){Array.<number>}
-
Retrieves Mel Frequency Cepstrum Coefficients (MFCCs). For best results, if using preexisting webaudio FFT data (from getFloatFrequencyData), pass your values through VowelWorm.decibelsToLinear first. If you do not pass in specific FFT data, the default data will be converted to a linear magnitude scale anyway.
Name Type Description options
Object mfccsOptions Returns:
MFFCs. Probably relevant are the second and third values (i.e., a[1] and a[2])
-
getSampleRate(){number}
-
The sample rate of the attached audio source
-
setStream(stream)
-
Specifies the audio source for the instance. Can be a video or audio element, a URL, or a MediaStream
Name Type Description stream
MediaStream | string | HTMLAudioElement | HTMLVideoElement The audio stream to analyze OR a string representing the URL for an audio file OR an Audio file Throws:
An error if stream is neither a Mediastream, Audio or Video Element, or a string