The burden of proof of infringement is on the plaintiff in either case.
If you have an obscure patent nobody has ever heard of, you can win the suit by showing that the defendant had the same idea you did - you don't need to show their work derives from yours.
If you have an obscure song nobody has ever heard (or even an unpublished one!) you are going to have a difficult time proving infringement for a similar riff.
Perhaps you're most familiar with litigation around very famous songs, like the Under Pressure / Ice Ice famous case? In those cultural-saturation cases the court may make the assumption that the later party could have been exposed to the work of the earlier one, but that is not the case universally.
Harrison's song was "My Sweet Lord", the song allegedly infringed was "He's So Fine" by some girl group in the 1950s or 1960s. It shouldn't be hard to hear either one. My recollection is that the songs did some pretty much alike.
If you have an obscure patent nobody has ever heard of, you can win the suit by showing that the defendant had the same idea you did - you don't need to show their work derives from yours.
If you have an obscure song nobody has ever heard (or even an unpublished one!) you are going to have a difficult time proving infringement for a similar riff.
Perhaps you're most familiar with litigation around very famous songs, like the Under Pressure / Ice Ice famous case? In those cultural-saturation cases the court may make the assumption that the later party could have been exposed to the work of the earlier one, but that is not the case universally.