There is quite some literature and code on pitch detection.
Basic question: do they also work with multiple sound sources?
-
Wikipedia: https://en.wikipedia.org/wiki/Pitch_detection_algorithm
-
Here is a paper with an overview: https://pdfs.semanticscholar.org/ff04/0316f44eab5c0497cec280bfb1fd0e7c0e85.pdf
-
A python package: https://github.com/YannickJadoul/Parselmouth
-
Some discussions on stackoverflow with several hints to other sources: