Skip to main content
Glama

chroma_cqt

Analyze audio signals to extract chromatic content with chroma CQT, identifying note names, time positions, and amplitudes for music analysis. Saves results to a CSV file for detailed examination.

Instructions

Computes the chroma CQT of the given audio time series using librosa. The chroma CQT is a representation of the audio signal in terms of its chromatic content, which is useful for music analysis. The chroma CQT is computed using the following parameters: - path_audio_time_series_y: The path to the audio time series (CSV file). It's sometimes better to take harmonics only - hop_length: The number of samples between frames. - fmin: The minimum frequency of the chroma feature. - n_chroma: The number of chroma bins (default is 12). - n_octaves: The number of octaves to include in the chroma feature. The chroma CQT is saved to a CSV file with the following columns: - note: The note name (C, C#, D, etc.). - time: The time position of the note in seconds. - amplitude: The amplitude of the note at that time. The path to the CSV file is returned.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fminNo
hop_lengthNo
n_chromaNo
n_octavesNo
path_audio_time_series_yYes

Implementation Reference

  • The chroma_cqt tool handler: loads audio time series from CSV, computes chroma CQT using librosa.feature.chroma_cqt with given parameters, converts to CSV format with note, time, amplitude columns, and returns the path to the CSV file.
    @mcp.tool() def chroma_cqt( path_audio_time_series_y: str, hop_length: int = 512, fmin: float = None, n_chroma: int = 12, n_octaves: int = 7, ) -> str: """ Computes the chroma CQT of the given audio time series using librosa. The chroma CQT is a representation of the audio signal in terms of its chromatic content, which is useful for music analysis. The chroma CQT is computed using the following parameters: - path_audio_time_series_y: The path to the audio time series (CSV file). It's sometimes better to take harmonics only - hop_length: The number of samples between frames. - fmin: The minimum frequency of the chroma feature. - n_chroma: The number of chroma bins (default is 12). - n_octaves: The number of octaves to include in the chroma feature. The chroma CQT is saved to a CSV file with the following columns: - note: The note name (C, C#, D, etc.). - time: The time position of the note in seconds. - amplitude: The amplitude of the note at that time. The path to the CSV file is returned. """ y = np.loadtxt(path_audio_time_series_y, delimiter=";") chroma_cq = librosa.feature.chroma_cqt( y=y, hop_length=hop_length, fmin=fmin, n_chroma=n_chroma, n_octaves=n_octaves, ) # Save the chroma_cq to a CSV file name = path_audio_time_series_y.split("/")[-1].split(".")[0] + "_chroma_cqt" chroma_cq_path = os.path.join(tempfile.gettempdir(), name + ".csv") notes = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"] time_frames = np.arange(chroma_cq.shape[1]) time_seconds = librosa.frames_to_time(time_frames, hop_length=hop_length) with open(chroma_cq_path, "w") as f: f.write("note,time,amplitude\n") for i, note in enumerate(notes): for t_index, amplitude in enumerate(chroma_cq[i]): t = time_seconds[t_index] f.write(f"{note},{t},{amplitude}\n") # Return the path to the CSV file return chroma_cq_path
  • Type hints defining the input schema (parameters with types and defaults) and output (str path) for the chroma_cqt tool.
    def chroma_cqt( path_audio_time_series_y: str, hop_length: int = 512, fmin: float = None, n_chroma: int = 12, n_octaves: int = 7, ) -> str:
  • Registration of the chroma_cqt tool using the FastMCP @mcp.tool() decorator.
    @mcp.tool()

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hugohow/mcp-music-analysis'

If you have feedback or need assistance with the MCP directory API, please join our Discord server