The Audio Search Coda Pack provides a set of utility formulas that help you format and manipulate data related to Spotify properties/data. These formulas offer convenient ways to enhance the presentation and usability of the retrieved information in your Coda docs.
FormatDuration(duration)
Description: Converts a duration value from milliseconds to a human-readable format.
Parameters:
duration (number): The duration in milliseconds.
Returns: A string representing the duration in the format "X minutes Y seconds" (e.g., "3 minutes 30 seconds").
Description: Formats the release date of an item based on the provided release date precision.
Parameters:
releaseDate (string): The release date of the item.
releaseDatePrecision (string): The precision of the release date. Possible values are "year", "month", or "day".
Returns: A string representing the formatted release date based on the precision.
Example usage:
FormatReleaseDate("2024-09-08","year")
Output: January 1, 2024 → accurate to the year, January 1 as placeholders
FormatReleaseDate("2024-05-31","month")
Output: May 1, 2024 → accurate to the month, the 1st as a placeholder for the day
FormatReleaseDate("2024-10-15","day")
Output: October 15, 2024 → the exact, accurate date
Why is this necessary? Sometimes Spotify has incomplete release date information, usually for older albums. This is where the property Release date precision comes into play. If the precision is set to year - what that means is Spotify is only sure about the release date.
FormatKey(key)
Description: Converts a key number to its corresponding pitch class notation.
Parameters:
key (number): The key number (integer from 0 to 11).
Returns: A string representing the pitch class notation of the key (e.g., "C", "C♯/D♭", "D").
Example usage:
FormatKey(0)
Output: C
Audio Formulas
GetAudioFeatures(trackId)
Description: Retrieves the audio features of a specific Spotify track.
Parameters:
trackId (string): The Spotify ID of the track.
Returns: An object containing the audio features of the track, such as danceability, energy, tempo, and more.
Example:
AudioFeatures
GetAudioAnalysis(trackId)
Description: Retrieves the audio analysis of a specific Spotify track.
Parameters:
trackId (string): The Spotify ID of the track.
Returns: An object containing the audio analysis of the track, including detailed information about bars, beats, sections, and segments – each their own object, with loads of information.
Example:
AudioAnalysis
Summary
These utility formulas provide additional functionality to format and analyze data related to Spotify items. By leveraging these formulas, you can enhance the presentation and insights derived from the retrieved information in your Coda docs.