Skip to content

Support for using multiple reference tracks#82

Open
soundsnep wants to merge 6 commits intosergree:masterfrom
soundsnep:multireference
Open

Support for using multiple reference tracks#82
soundsnep wants to merge 6 commits intosergree:masterfrom
soundsnep:multireference

Conversation

@soundsnep
Copy link
Copy Markdown

@soundsnep soundsnep commented Mar 29, 2026

First, thanks to all the authors who contributed to Matchering and got it where it is!

I had a hard time getting a satisfactory result when matching to a reference track that sounded good, although it was a bit bass-heavy and rather aggressively compressed (EDM, partially what I aimed for, but not to that extent). I was thinking if perhaps the spectrum contains peaks related to the key of the reference, which break how the matched result sounds, or something similar. Also I was not very happy with the bass-heaviness and wondered if I can avoid manually applying an EQ (and then fixing the levels/dynamics). I had a second reference track that was a bit "weaker", but too weak on its own .... getting a match somewhere "in between" was my goal.

Hypothesis: Blending multiple reference tracks should help with getting a better balanced result.

Implementation TL;DR: the intermediate "stats" of the reference tracks (outputs of analyze_levels() and get_fir()) are averaged before applying them to the target track.

Now we can get in-between results for multiple reference tracks. It's also possible to specify custom weights separately for levels (dynamics) and frequency response. This way we can use one track as a frequency response reference, and other track for levels/dynamics/loudness, or any mix of any number of tracks. See the README change for an example.

Some examples:

target track matched to reference track A (result identical to unmodified Matchering), screenshot of Audacity's "Plot Spectrum" command:
target multiref-just_A_16bit

target track matched to reference track B (result identical to unmodified Matchering):
target multiref-just_B_16bit

target track matched to an equal blend of A and B (result enabled by this contribution):
target multiref-A+B_16bit
Indeed, the spectrum looks like an average of the two above.

I did not find a nice+easy way to visualize the results for levels/dynamics, but can do more tests if needed.

more plots original spectrum of the target track target

spectrum of reference A
ref_A

spectrum of reference B
ref_B

Disclaimer: AI was used for the initial implementation, mainly to test the capabilities of the free tier GitHub Copilot in the Codespace online VSCode, and to avoid wasting time on debugging my stupid typos. It needed a few bumps to push it in the right direction - e.g. it proposed to mix the raw samples of reference tracks, which would break transients etc., but turned out good in the end - see the full chat transcript in the first commit if interested. The follow-up changes (weights splitting etc.) were done manually.

Testing done: in my experiments the results with one reference are identical to the the results before any code changes. As expected, with more references their order does not matter (as long as their weights are the same). I tested with up to 3 reference tracks, but there is no limit (as long they fit in your RAM ... using the whole Spotify library recently scraped by filthy pirates as reference tracks is probably not a good idea, lol). Sorry, I did not bother with proper unit tests as this was just a fun Sunday project for me :3 I can make some later if you want.

It worked reasonably well for my use-case, but I would be interested in others' thoughts.
I hope you find it useful.

@soundsnep soundsnep marked this pull request as ready for review March 29, 2026 23:38
@soundsnep
Copy link
Copy Markdown
Author

I realized that this somewhat gives the "how much should the matchering apply" control that #65 and #72 ask for. It should be possible to set two references:

  1. the actual reference track
  2. the original target track

and set their reference_weights_levels and reference_weights_frequencies as desired to get a blend in between the reference track and the original.

I might try it later this week if I have some time.

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

Successfully merging this pull request may close these issues.

1 participant