Skip to content

Spectrum Analysis Service – Samples

Performing Discrete Fourier Transform (DFT)

Use the following endpoint for performing DFT on an audio file:

1
2
3
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 a windowType which is applied to the input signal before the DFT is computed. Four options are available: FLATTOP, HAMMING, HANNING or BLACKMAN.

Sample request for the fftProperties:

1
2
3
{
  "windowType": "FLATTOP"
}

Sample response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
{
  "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:

1
2
3
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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
  "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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
{
  "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.

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.