Spectrum Analysis Service – Samples¶
Performing Discrete Fourier Transform (DFT)¶
Use the following endpoint for performing DFT on an audio file:
POST /calculateFrequencies
Content-Type: multipart/form-data; audio/wav
The body of the request consists of two parts:
file
(required): The audio file to be transformed. It must be in .wav format and its size is limited to 1 MB. It can have a sample size of 8 or 16 bits and be mono or stereo.fftProperties
(optional): JSON Configuration for the Fourier transformation. Sets awindowType
which is applied to the input signal before the DFT is computed. Four options are available:FLATTOP
,HAMMING
,HANNING
orBLACKMAN
.
Sample request for the fftProperties
:
{
"windowType": "FLATTOP"
}
Sample response:
{
"numberOfFFTComponents": 9,
"amplitudeUnit": "dB",
"data": {
"maxFFTFrequency": 22050,
"amplitudes": [
-225.81,
-35.42,
-36.66,
-35.15,
-40.27,
-35.72,
-38.73,
-29.63,
-27.35
]
}
}
The response is a JSON object that contains the following information:
- The maximum frequency resolvable by DFT, which is half of the sampling frequency. This is also known as Nyquist frequency.
- Number of frequency components found by DFT
- Measuring unit for amplitudes
- Array of amplitudes found by DFT
Performing Threshold Breach Detection¶
Use the following endpoint for detecting threshold breaches:
POST /detectThresholdViolations
Content-Type: application/json
The body of the request consists of two parts:
data
(required): Array of amplitudes of frequency components as returned by the Discrete Fourier Transformation.spectrumFilter
(required): Defines a frequency interval of interest as well as an upper and lower frequency threshold. At least one threshold is required, the frequency interval is optional. If no frequency interval is defined, the whole signal is analyzed.
Sample request:
{
"data": {
"amplitudes": [
-225.81,
-35.42,
-36.66,
-35.15,
-40.27,
-35.72,
-38.73,
-29.63,
-27.35
],
"maxFFTFrequency": 22050
},
"spectrumFilter": {
"minFrequency": 1000,
"maxFrequency": 12000,
"lowerThreshold": -40.25,
"upperThreshold": -30
}
}
Sample response:
{
"upperDetection": {
"frequencyAtMaxAmplitude": 6120,
"maxAmplitude": -40.27,
"breachPercentage": 25
},
"lowerDetection": {
"frequencyAtMinAmplitude": 10020,
"minAmplitude": -27.35,
"breachPercentage": 50
}
}
The response is a JSON object which contains upper and lower threshold breach detections. They indicate where the biggest threshold breach occurred (frequencyAtMaxAmplitude
), the amplitude value in dB (maxAmplitude
), and the percentage of components that breached the threshold (breachPercentage
) within the given array or, if specified, the frequency interval.
Except where otherwise noted, content on this site is licensed under the Development License Agreement.