beat_track
Analyze the rhythmic content of audio time series by computing its beat track. Use customizable parameters like hop length, start BPM, tightness, and units to extract precise rhythmic analysis for music applications.
Instructions
Computes the beat track of the given audio time series using librosa.
The beat track is a representation of the audio signal in terms of its
rhythmic content, which is useful for music analysis.
The beat track is computed using the following parameters:
- hop_length: The number of samples between frames.
- start_bpm: The initial estimate of the tempo (in BPM).
- tightness: The tightness of the beat tracking (default is 100).
- units: The units of the beat track (default is "frames"). It can be frames, samples, time.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hop_length | No | ||
| path_audio_time_series_y | Yes | ||
| start_bpm | No | ||
| tightness | No | ||
| units | No | frames |
Implementation Reference
- src/mcp_music_analysis/server.py:168-198 (handler)The primary handler implementation for the 'beat_track' tool. Decorated with @mcp.tool() for registration. Loads audio y from CSV file, calls librosa.beat.beat_track to compute tempo and beats, returns dict with results. Includes detailed docstring describing parameters.@mcp.tool() def beat_track( path_audio_time_series_y: str, hop_length: int = 512, start_bpm: float = 120, tightness: int = 100, units: str = "frames", ) -> str: """ Computes the beat track of the given audio time series using librosa. The beat track is a representation of the audio signal in terms of its rhythmic content, which is useful for music analysis. The beat track is computed using the following parameters: - hop_length: The number of samples between frames. - start_bpm: The initial estimate of the tempo (in BPM). - tightness: The tightness of the beat tracking (default is 100). - units: The units of the beat track (default is "frames"). It can be frames, samples, time. """ y = np.loadtxt(path_audio_time_series_y, delimiter=";") tempo, beats = librosa.beat.beat_track( y=y, hop_length=hop_length, start_bpm=start_bpm, tightness=tightness, units=units, ) return { "tempo": tempo, "beats": beats, }
- Schema definition for 'beat_track' tool parameters and return type, as listed in the @mcp.prompt() generated user instructions."- beat_track(path_audio_time_series_y: str, hop_length: int = 512, start_bpm: float = 120, " "tightness: int = 100, units: str = 'frames') -> dict\n"
- src/mcp_music_analysis/server.py:168-168 (registration)The @mcp.tool() decorator registers the beat_track function as an MCP tool with the FastMCP server.@mcp.tool()