What is causing some custom sounds to not follow the player? [duplicate]

In theory the minimumVolume parameter should fulfil exactly this purpose, but I couldn't get it to work. Maybe that's a bug.

But the volume parameter of /playsound can in a way actually be used to specify a spatial volume instead of an audio volume! The trick, as described in the wiki (archive):

For values greater than 1.0, the sound will not actually grow louder, but its audible range (a 16-block radius at 1.0) will be multiplied by volume. There will always be a gradual falloff to silence based on distance from the center of the sphere.

That means that you can just enter the maximum value of a Float, except that it's for some reason slightly different in Minecraft. By just trying out values I found that the maximum value is:

340282356779733661637539395458142568447.99999…

So you can use this command to play a sound everywhere:

/playsound <sound> <channel> <selector> <x> <y> <z> 340282356779733661637539395458142568447.9999999999

That way it only gets 0.000000000000000000000000000024936% quieter when you go to the other end of the world.

This even works across dimensions for some reason. But when you go through a portal, the sound stops.