Skip to content
DocumentationAPI Reference

Get Track's Audio Analysis

Deprecated
client.audioAnalysis.retrieve(stringid, RequestOptionsoptions?): AudioAnalysisRetrieveResponse { bars, beats, meta, 5 more }
GET/audio-analysis/{id}

Get a low-level audio analysis for a track in the Spotify catalog. The audio analysis describes the track’s structure and musical content, including rhythm, pitch, and timbre.

ParametersExpand Collapse
id: string

The Spotify ID for the track.

ReturnsExpand Collapse
AudioAnalysisRetrieveResponse { bars, beats, meta, 5 more }
bars?: Array<TimeIntervalObject { confidence, duration, published, start } >

The time intervals of the bars throughout the track. A bar (or measure) is a segment of time defined as a given number of beats.

confidence?: number

The confidence, from 0.0 to 1.0, of the reliability of the interval.

minimum0
maximum1
duration?: number

The duration (in seconds) of the time interval.

published?: boolean

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

start?: number

The starting point (in seconds) of the time interval.

beats?: Array<TimeIntervalObject { confidence, duration, published, start } >

The time intervals of beats throughout the track. A beat is the basic time unit of a piece of music; for example, each tick of a metronome. Beats are typically multiples of tatums.

confidence?: number

The confidence, from 0.0 to 1.0, of the reliability of the interval.

minimum0
maximum1
duration?: number

The duration (in seconds) of the time interval.

published?: boolean

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

start?: number

The starting point (in seconds) of the time interval.

meta?: Meta { analysis_time, analyzer_version, detailed_status, 4 more }
analysis_time?: number

The amount of time taken to analyze this track.

analyzer_version?: string

The version of the Analyzer used to analyze this track.

detailed_status?: string

A detailed status code for this track. If analysis data is missing, this code may explain why.

input_process?: string

The method used to read the track's audio data.

platform?: string

The platform used to read the track's audio data.

status_code?: number

The return code of the analyzer process. 0 if successful, 1 if any errors occurred.

timestamp?: number

The Unix timestamp (in seconds) at which this track was analyzed.

formatint64
published?: boolean

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

sections?: Array<Section>

Sections are defined by large variations in rhythm or timbre, e.g. chorus, verse, bridge, guitar solo, etc. Each section contains its own descriptions of tempo, key, mode, time_signature, and loudness.

confidence?: number

The confidence, from 0.0 to 1.0, of the reliability of the section's "designation".

minimum0
maximum1
duration?: number

The duration (in seconds) of the section.

key?: number

The estimated overall key of the section. The values in this field ranging from 0 to 11 mapping to pitches using standard Pitch Class notation (E.g. 0 = C, 1 = C♯/D♭, 2 = D, and so on). If no key was detected, the value is -1.

key_confidence?: number

The confidence, from 0.0 to 1.0, of the reliability of the key. Songs with many key changes may correspond to low values in this field.

minimum0
maximum1
loudness?: number

The overall loudness of the section in decibels (dB). Loudness values are useful for comparing relative loudness of sections within tracks.

mode?: -1 | 0 | 1

Indicates the modality (major or minor) of a section, the type of scale from which its melodic content is derived. This field will contain a 0 for "minor", a 1 for "major", or a -1 for no result. Note that the major key (e.g. C major) could more likely be confused with the minor key at 3 semitones lower (e.g. A minor) as both keys carry the same pitches.

Accepts one of the following:
-1
0
1
mode_confidence?: number

The confidence, from 0.0 to 1.0, of the reliability of the mode.

minimum0
maximum1
published?: boolean

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

start?: number

The starting point (in seconds) of the section.

tempo?: number

The overall estimated tempo of the section in beats per minute (BPM). In musical terminology, tempo is the speed or pace of a given piece and derives directly from the average beat duration.

tempo_confidence?: number

The confidence, from 0.0 to 1.0, of the reliability of the tempo. Some tracks contain tempo changes or sounds which don't contain tempo (like pure speech) which would correspond to a low value in this field.

minimum0
maximum1
time_signature?: number

An estimated time signature. The time signature (meter) is a notational convention to specify how many beats are in each bar (or measure). The time signature ranges from 3 to 7 indicating time signatures of "3/4", to "7/4".

minimum3
maximum7
time_signature_confidence?: number

The confidence, from 0.0 to 1.0, of the reliability of the time_signature. Sections with time signature changes may correspond to low values in this field.

minimum0
maximum1
segments?: Array<Segment>

Each segment contains a roughly conisistent sound throughout its duration.

confidence?: number

The confidence, from 0.0 to 1.0, of the reliability of the segmentation. Segments of the song which are difficult to logically segment (e.g: noise) may correspond to low values in this field.

minimum0
maximum1
duration?: number

The duration (in seconds) of the segment.

loudness_end?: number

The offset loudness of the segment in decibels (dB). This value should be equivalent to the loudness_start of the following segment.

loudness_max?: number

The peak loudness of the segment in decibels (dB). Combined with loudness_start and loudness_max_time, these components can be used to describe the "attack" of the segment.

loudness_max_time?: number

The segment-relative offset of the segment peak loudness in seconds. Combined with loudness_start and loudness_max, these components can be used to desctibe the "attack" of the segment.

loudness_start?: number

The onset loudness of the segment in decibels (dB). Combined with loudness_max and loudness_max_time, these components can be used to describe the "attack" of the segment.

pitches?: Array<number>

Pitch content is given by a “chroma” vector, corresponding to the 12 pitch classes C, C#, D to B, with values ranging from 0 to 1 that describe the relative dominance of every pitch in the chromatic scale. For example a C Major chord would likely be represented by large values of C, E and G (i.e. classes 0, 4, and 7).

Vectors are normalized to 1 by their strongest dimension, therefore noisy sounds are likely represented by values that are all close to 1, while pure tones are described by one value at 1 (the pitch) and others near 0. As can be seen below, the 12 vector indices are a combination of low-power spectrum values at their respective pitch frequencies. pitch vector

published?: boolean

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

start?: number

The starting point (in seconds) of the segment.

timbre?: Array<number>

Timbre is the quality of a musical note or sound that distinguishes different types of musical instruments, or voices. It is a complex notion also referred to as sound color, texture, or tone quality, and is derived from the shape of a segment’s spectro-temporal surface, independently of pitch and loudness. The timbre feature is a vector that includes 12 unbounded values roughly centered around 0. Those values are high level abstractions of the spectral surface, ordered by degree of importance.

For completeness however, the first dimension represents the average loudness of the segment; second emphasizes brightness; third is more closely correlated to the flatness of a sound; fourth to sounds with a stronger attack; etc. See an image below representing the 12 basis functions (i.e. template segments). timbre basis functions

The actual timbre of the segment is best described as a linear combination of these 12 basis functions weighted by the coefficient values: timbre = c1 x b1 + c2 x b2 + ... + c12 x b12, where c1 to c12 represent the 12 coefficients and b1 to b12 the 12 basis functions as displayed below. Timbre vectors are best used in comparison with each other.

tatums?: Array<TimeIntervalObject { confidence, duration, published, start } >

A tatum represents the lowest regular pulse train that a listener intuitively infers from the timing of perceived musical events (segments).

confidence?: number

The confidence, from 0.0 to 1.0, of the reliability of the interval.

minimum0
maximum1
duration?: number

The duration (in seconds) of the time interval.

published?: boolean

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

start?: number

The starting point (in seconds) of the time interval.

track?: Track { analysis_channels, analysis_sample_rate, code_version, 23 more }
analysis_channels?: number

The number of channels used for analysis. If 1, all channels are summed together to mono before analysis.

analysis_sample_rate?: number

The sample rate used to decode and analyze this track. May differ from the actual sample rate of this track available on Spotify.

code_version?: number

A version number for the Echo Nest Musical Fingerprint format used in the codestring field.

codestring?: string

An Echo Nest Musical Fingerprint (ENMFP) codestring for this track.

duration?: number

Length of the track in seconds.

echoprint_version?: number

A version number for the EchoPrint format used in the echoprintstring field.

echoprintstring?: string

An EchoPrint codestring for this track.

end_of_fade_in?: number

The time, in seconds, at which the track's fade-in period ends. If the track has no fade-in, this will be 0.0.

key?: number

The key the track is in. Integers map to pitches using standard Pitch Class notation. E.g. 0 = C, 1 = C♯/D♭, 2 = D, and so on. If no key was detected, the value is -1.

minimum-1
maximum11
key_confidence?: number

The confidence, from 0.0 to 1.0, of the reliability of the key.

minimum0
maximum1
loudness?: number

The overall loudness of a track in decibels (dB). Loudness values are averaged across the entire track and are useful for comparing relative loudness of tracks. Loudness is the quality of a sound that is the primary psychological correlate of physical strength (amplitude). Values typically range between -60 and 0 db.

formatfloat
mode?: number

Mode indicates the modality (major or minor) of a track, the type of scale from which its melodic content is derived. Major is represented by 1 and minor is 0.

mode_confidence?: number

The confidence, from 0.0 to 1.0, of the reliability of the mode.

minimum0
maximum1
num_samples?: number

The exact number of audio samples analyzed from this track. See also analysis_sample_rate.

offset_seconds?: number

An offset to the start of the region of the track that was analyzed. (As the entire track is analyzed, this should always be 0.)

rhythm_version?: number

A version number for the Rhythmstring used in the rhythmstring field.

rhythmstring?: string

A Rhythmstring for this track. The format of this string is similar to the Synchstring.

sample_md5?: string

This field will always contain the empty string.

start_of_fade_out?: number

The time, in seconds, at which the track's fade-out period starts. If the track has no fade-out, this should match the track's length.

synch_version?: number

A version number for the Synchstring used in the synchstring field.

synchstring?: string

A Synchstring for this track.

tempo?: number

The overall estimated tempo of a track in beats per minute (BPM). In musical terminology, tempo is the speed or pace of a given piece and derives directly from the average beat duration.

formatfloat
tempo_confidence?: number

The confidence, from 0.0 to 1.0, of the reliability of the tempo.

minimum0
maximum1
time_signature?: number

An estimated time signature. The time signature (meter) is a notational convention to specify how many beats are in each bar (or measure). The time signature ranges from 3 to 7 indicating time signatures of "3/4", to "7/4".

minimum3
maximum7
time_signature_confidence?: number

The confidence, from 0.0 to 1.0, of the reliability of the time_signature.

minimum0
maximum1
window_seconds?: number

The length of the region of the track was analyzed, if a subset of the track was analyzed. (As the entire track is analyzed, this should always be 0.)

Get Track's Audio Analysis

import Spotted from 'spotted-ts';

const client = new Spotted({
  accessToken: process.env['SPOTIFY_ACCESS_TOKEN'], // This is the default and can be omitted
});

const audioAnalysis = await client.audioAnalysis.retrieve('11dFghVXANMlKmJXsNCbNl');

console.log(audioAnalysis.bars);
{
  "bars": [
    {
      "confidence": 0.925,
      "duration": 2.18749,
      "published": true,
      "start": 0.49567
    }
  ],
  "beats": [
    {
      "confidence": 0.925,
      "duration": 2.18749,
      "published": true,
      "start": 0.49567
    }
  ],
  "meta": {
    "analysis_time": 6.93906,
    "analyzer_version": "4.0.0",
    "detailed_status": "OK",
    "input_process": "libvorbisfile L+R 44100->22050",
    "platform": "Linux",
    "status_code": 0,
    "timestamp": 1495193577
  },
  "published": true,
  "sections": [
    {
      "confidence": 1,
      "duration": 6.97092,
      "key": 9,
      "key_confidence": 0.297,
      "loudness": -14.938,
      "mode": -1,
      "mode_confidence": 0.471,
      "published": true,
      "start": 0,
      "tempo": 113.178,
      "tempo_confidence": 0.647,
      "time_signature": 4,
      "time_signature_confidence": 1
    }
  ],
  "segments": [
    {
      "confidence": 0.435,
      "duration": 0.19891,
      "loudness_end": 0,
      "loudness_max": -14.25,
      "loudness_max_time": 0.07305,
      "loudness_start": -23.053,
      "pitches": [
        0.212,
        0.141,
        0.294
      ],
      "published": true,
      "start": 0.70154,
      "timbre": [
        42.115,
        64.373,
        -0.233
      ]
    }
  ],
  "tatums": [
    {
      "confidence": 0.925,
      "duration": 2.18749,
      "published": true,
      "start": 0.49567
    }
  ],
  "track": {
    "analysis_channels": 1,
    "analysis_sample_rate": 22050,
    "code_version": 3.15,
    "codestring": "codestring",
    "duration": 207.95985,
    "echoprint_version": 4.15,
    "echoprintstring": "echoprintstring",
    "end_of_fade_in": 0,
    "key": 9,
    "key_confidence": 0.408,
    "loudness": -5.883,
    "mode": 0,
    "mode_confidence": 0.485,
    "num_samples": 4585515,
    "offset_seconds": 0,
    "rhythm_version": 1,
    "rhythmstring": "rhythmstring",
    "sample_md5": "sample_md5",
    "start_of_fade_out": 201.13705,
    "synch_version": 1,
    "synchstring": "synchstring",
    "tempo": 118.211,
    "tempo_confidence": 0.73,
    "time_signature": 4,
    "time_signature_confidence": 0.994,
    "window_seconds": 0
  }
}
Returns Examples
{
  "bars": [
    {
      "confidence": 0.925,
      "duration": 2.18749,
      "published": true,
      "start": 0.49567
    }
  ],
  "beats": [
    {
      "confidence": 0.925,
      "duration": 2.18749,
      "published": true,
      "start": 0.49567
    }
  ],
  "meta": {
    "analysis_time": 6.93906,
    "analyzer_version": "4.0.0",
    "detailed_status": "OK",
    "input_process": "libvorbisfile L+R 44100->22050",
    "platform": "Linux",
    "status_code": 0,
    "timestamp": 1495193577
  },
  "published": true,
  "sections": [
    {
      "confidence": 1,
      "duration": 6.97092,
      "key": 9,
      "key_confidence": 0.297,
      "loudness": -14.938,
      "mode": -1,
      "mode_confidence": 0.471,
      "published": true,
      "start": 0,
      "tempo": 113.178,
      "tempo_confidence": 0.647,
      "time_signature": 4,
      "time_signature_confidence": 1
    }
  ],
  "segments": [
    {
      "confidence": 0.435,
      "duration": 0.19891,
      "loudness_end": 0,
      "loudness_max": -14.25,
      "loudness_max_time": 0.07305,
      "loudness_start": -23.053,
      "pitches": [
        0.212,
        0.141,
        0.294
      ],
      "published": true,
      "start": 0.70154,
      "timbre": [
        42.115,
        64.373,
        -0.233
      ]
    }
  ],
  "tatums": [
    {
      "confidence": 0.925,
      "duration": 2.18749,
      "published": true,
      "start": 0.49567
    }
  ],
  "track": {
    "analysis_channels": 1,
    "analysis_sample_rate": 22050,
    "code_version": 3.15,
    "codestring": "codestring",
    "duration": 207.95985,
    "echoprint_version": 4.15,
    "echoprintstring": "echoprintstring",
    "end_of_fade_in": 0,
    "key": 9,
    "key_confidence": 0.408,
    "loudness": -5.883,
    "mode": 0,
    "mode_confidence": 0.485,
    "num_samples": 4585515,
    "offset_seconds": 0,
    "rhythm_version": 1,
    "rhythmstring": "rhythmstring",
    "sample_md5": "sample_md5",
    "start_of_fade_out": 201.13705,
    "synch_version": 1,
    "synchstring": "synchstring",
    "tempo": 118.211,
    "tempo_confidence": 0.73,
    "time_signature": 4,
    "time_signature_confidence": 0.994,
    "window_seconds": 0
  }
}