Ambience Mini adds a custom music engine to Minecraft that allows you to play custom music based on various parameters such as the state of the player, the state of the world, some currently open menus, and similar game states.
You can find more information about the mod on the wiki-page here on GitHub.