Presumably you looked at https://learn.adafruit.com/usb-audio-cards-with-a-raspberry-pi/recording-audio from Adafruit. Once you get your data with the microphone, what you want is an "audio spectrum analyzer" . You will need to do Fourier Transforms to convert the time series data from the microphone into frequency data. You can look for the standard musical note frequencies in the Fourier Transforms. There is a computationally fast way of doing Fourier Transforms aptly named FFT, i.e. Fast Fourier Transform. See https://www.raspberrypi.org/blog/accelerating-fourier-transforms-using-the-gpu/ for info on how to do that on a Raspberry PI.
There is a LOT to understand about FFTs and spectrum analysis. For example, the frequency resolution of the FFT depends on the number of samples that are processed. You also need to understand windowing. See https://www.edn.com/electronics-news/4383713/Windowing-Functions-Improve-FFT-Results-Part-I .
For this specific example, if there are multiple notes playing at the same time and the same note is played in different octaves, you will have to distinguish between overtones from lower frequency notes and the fundamental frequency of higher notes. For actual music versus isolated instruments, this is non-trivial.