The Peak Spectrum Data object allows for processing of a vector representing the audio in the frequency domain after peak picking. This gives a sparse spectrum view.
PeakSpectrumData() has the following two constructors:
// Some Globals var N = 1024; var sample_rate = 44100.0; // Creates a peakSpectrumData with no sample_rate defined // Automatically defines a data size of 1024 elements var peakSpectrumData = new PeakSpectrumData(N); // Creates a peakSpectrumData with a sample_rate defined // Automatically defines a data size of 1024 elements var peakSpectrumData2 = new PeakSpectrumData(N,sample_rate);
||Returns sample rate||Set the sample rate if sample_rate is undefined|
||Returns the f0||Set the f0|
||Return the length of the vector||Read only|
Clear the result object to an empty object
Get the data store view (including both magnitudes and frequency arrays);
Fill the maginitude array with zeros.
Copy the data from a source array into the Object.
src must be a defined array with at least one element.
number defines the number of elements to copy from source, will be set to
offset defines the starting point in the destination array. See Using the Object Oriented calls for more details.
SpectrumData().copyDataFrom(src); SpectrumData().copyDataFrom(src, number); SpectrumData().copyDataFrom(src, number, offset);
Duplicate the object with another SpectrumData object with the data elements copied. Does not copy the current results node.
PeakSpectrumData() object includes all the features of the SpectrumData object.
All these functions return their computed features and store them in the results. Any intermediary results which are calculated are also stored.
Calculate the balance of the spectrum between peaks related to the fundamental and those not related. The fundamental frequency must have been set before calling this function.
value = PeakSpectrumData().spectral_inharmonicity(); PeakSpectrumData().result.spectral_inharmonicity = Number();
Return a HarmonicSpectrum() object containing the peaks only related to the fundamental frequency. If
threshold is undefined then an error is thrown. If the
f0 fundamental has not been set then an error is thrown.
value = PeakSpectrumData().harmonic_spectrum(threshold); PeakSpectrumData().result.harmonic_spectrum = HarmonicSpectrum();