Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in chroma plugin when recording was merged #5535

Open
marksdestiny opened this issue Dec 4, 2024 · 0 comments
Open

Bug in chroma plugin when recording was merged #5535

marksdestiny opened this issue Dec 4, 2024 · 0 comments

Comments

@marksdestiny
Copy link

Problem

I've found a bug within the chroma plugin which can cause the recordings returned by an acoustid lookup to be suggested with an incorrect distance when those recording have been merged.

For example, the fingerprint AQADtJmYJYsSKQry5... of this music file results in an acoustid response:

{
    "results": [
        {
            "id": "ad580b8c-ff11-4656-83a5-7e7915ac5c9e",
            "recordings": [
                {
                    "id": "a63c1288-7247-4d3b-8ca0-453d8a38e2ed"
                },
                {
                    "id": "de8c09f3-0f69-4c39-93dd-e0964b0f8492"
                }
            ],
            "score": 0.9669699
        },
        ...

Both recordings have been merged into the recording with the id 79d185cc-8453-4020-85f3-0c53d4a2ebd1.

However, when importing the music file using beets, the recording 79d185cc-8453-4020-85f3-0c53d4a2ebd1 might not be the best candidate. This is because of the variable recording_ids in the track_distance function of the chroma plugin does not contain the id 79d185cc-8453-4020-85f3-0c53d4a2ebd1.

    def track_distance(self, item, info):
        dist = hooks.Distance()
        if item.path not in _matches or not info.track_id:
            # Match failed or no track ID.
            return dist

        recording_ids, _ = _matches[item.path]
        dist.add_expr("track_id", info.track_id not in recording_ids)
        return dist

Step to reproduce

The import of the music file from above with the chroma plugin enabled does not confidently suggest the recording 79d185cc-8453-4020-85f3-0c53d4a2ebd1.

$ beet import -s song.mp3 

/media/.../song.mp3

Finding tags for track "Phantom Planet - California".
  Candidates:
  1. (58.3%) Phantom Planet - California
             ≠ id
             MusicBrainz, Index None, Track None, 
  2. (58.3%) Phantom Planet - California
             ≠ id
             MusicBrainz, Index None, Track None, 
  3. (58.3%) Phantom Planet - California
             ≠ id
             MusicBrainz, Index None, Track None, 
  4. (54.3%) Phantom Planet - California
             ≠ id, length
             MusicBrainz, Index None, Track None, 
  5. (54.1%) Phantom Planet - California (Tchad Blake mix)
             ≠ id, title
             MusicBrainz, Index None, Track None, 
  6. (41.9%) Phantom Planet - California
             ≠ id, length
             MusicBrainz, Index None, Track None, 
➜ # selection (default 1), Skip, Use as-is, Enter search, enter Id, aBort? 

Proposed solution

This commit seems to fix the issue.
image

$ beet import -s song.mp3 

/media/.../song.mp3

  Match (95.8%):
  Phantom Planet - California (Tchad Blake mix)
  ≠ title
  MusicBrainz, Index None, Track None, 
  https://musicbrainz.org/recording/79d185cc-8453-4020-85f3-0c53d4a2ebd1
  * Artist: Phantom Planet
  ≠ Title: California -> California (Tchad Blake mix)
➜ [A]pply, More candidates, Skip, Use as-is, Enter search, enter Id, aBort

Setup

  • OS: Ubuntu 24.04.1 LTS
  • Python version: 3.12.3
  • beets version: 2.2.0
  • Turning off other plugins made problem go away (yes/no): no

My configuration (output of beet config) is:

# --------------- Plugins ---------------

plugins: chroma
directory: /media/markus/DataLinux/Temp/BeetsBug
# --------------- Main ---------------

library: /media/markus/DataLinux/Temp/BeetsBug/library.db
chroma:
    auto: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant