I'm currently working on my leaving qualification paper and its main purpose is to develop my own algorithm of finding similarities in musical compositions but firstly i need to learn more about already existing methods.
There are decades of research into this. You can just go to Google Scholar and input your search terms.
If you want the actual code, you usually have to go to theses (doctoral or masters) that have attempted the topic. most approaches use models like k-Nearest Neighbors (k-NN), Linear Regression, and Support Vector Machines Regression (SVR)