I want to make an ambient music that plays when hostile mobs are nearby. I already have the appropriate sound event ready in the custom sounds.json of the resourcepack I'm using and now want to repeatedly play it to all players within a 10-block radius of every creeper, skeleton, zombie etc. (using /execute), but only if neither an enemy ambient nor a boss music is playing to that player. While for the boss music I could repeatedly stop the ambient sound event for everyone in the boss area, the ambient sound itself is more of an issue, because I'm pretty sure it would overlap, and if I stopped it every time I relaunch it the music would loop quite oddly. I also want the music to start playing as immediately as possible when a player gets within the radius, and not only at the beginning of the next loop. So is there a way to achieve what I need, and if yes, how does it work?
Oh, almost forgot to mention, I'm still using 1.8 because that's my Forge version, so please take this into account. (No, that doesn't mean I'd be OK with using mods. I have Forge in primarily because of WorldEdit, and want the map to be playable in Vanilla.)
hearing zombie
,hearing_skeleton
etc. score to every player, set it to 0 under the same conditions as the sound plays, increment it once per tick and not play another sound (and not reset the score) again until the score is above the length of the sound (in ticks). As another idea, you could actually use the ambient sounds of zombies, skeletons, etc, except if that's different from what you need.