beat_track
Analyze audio rhythmic content by computing beat tracks for music analysis. Uses librosa to detect tempo and beat positions from audio time series.
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 |
|---|---|---|---|
| path_audio_time_series_y | Yes | ||
| hop_length | No | ||
| start_bpm | No | ||
| tightness | No | ||
| units | No | frames |
Implementation Reference
- src/mcp_music_analysis/server.py:168-198 (handler)The beat_track tool handler function. Decorated with @mcp.tool() for registration. Loads audio time series, computes tempo and beat frames using librosa.beat.beat_track, and returns a dictionary with tempo (BPM) and beats.@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, }
- Tool schema definition in the analyze_audio prompt, listing parameters and return type."- beat_track(path_audio_time_series_y: str, hop_length: int = 512, start_bpm: float = 120, " "tightness: int = 100, units: str = 'frames') -> dict\n"
- Core librosa.beat.beat_track call that performs the beat tracking computation.tempo, beats = librosa.beat.beat_track( y=y, hop_length=hop_length, start_bpm=start_bpm, tightness=tightness, units=units, )