Apple just bought Shazam for $400 million, and it has a lot to gain from the acquisition.

Apple confirmed Monday it bought the company known for its music recognition software, calling it a "natural fit." The purchase is Apple's latest move toward enhancing its music services. It bought music company Beats in 2014.

Now, Apple can incorporate Shazam's music recognition technology more thoroughly into the iPhone, including its integration with Siri. Siri can already tell you what song is playing, but you have to ask first.

Shazam wasn't very profitable on its own, but it used to earn commissions by sending users to Apple Music and Apple's competitor, Spotify. Now, Apple could find a way to cut Spotify out of the equation altogether.

That's a big deal: As of September, Spotify had more than four times the users Apple Music did, according to TechCrunch.

Spotify reportedly also looked into buying Shazam.

And both Apple and Shazam have been moving into the realm of augmented reality. Shazam launched new AR features earlier this year that could help Apple expand even more in that arena.