Author Topic: Limited-range music that doesn't fade with distance  (Read 1576 times)

Okay, so here's the deal: We all know that music bricks can be used to give music to certain areas of builds.  Covering large areas with one piece of music is made much easier with long-range music brick add-ons as well.

However, this is a pretty stuffty way to accomplish area-specific background music, as volume varies depending on distance from the source brick, and depending on which way you're facing you may only hear the music in one ear or the other.  Server-wide music bricks accomplish even volume regardless of location, but obviously have unlimited range and cannot be used for specific areas.  There's also client-side 2D music events, but this requires clients to have the add-on in order to hear the event-based music.

What I'm wondering is if there's a way to get the best of both worlds; Music that only plays in specific areas, but is the same volume regardless of where you are and is heard from both sides regardless of direction.  I do know that Blockland used to allow stereo music loops, and said loops would work exactly as described when used.  Now it seems that Blockland recognizes stereo music datablocks and removes them automatically.  Would there be a way to accomplish this or something like it now?

Not without an add-on or Badspot implementing 2D music ingame. 3D music calculates your player's rotation and their distance towards the source and adjusts the balance and volume accordingly. To he able to hear music in both speakers (L and R), it needs to be 2D. You can modify the existing 2D music add-on to only play music when the player is in a certain position/within a certain range.

Not without an add-on or Badspot implementing 2D music ingame. 3D music calculates your player's rotation and their distance towards the source and adjusts the balance and volume accordingly. To he able to hear music in both speakers (L and R), it needs to be 2D. You can modify the existing 2D music add-on to only play music when the player is in a certain position/within a certain range.
Which would require a client sided add-on because there is no way to stop a 2d looping sound if you played it to just one client.

That's really  the only reason it needs a client sided add-on, because you can't stop the music.

What really bugs me about this problem is that it would be really easily solved if stereo music loops weren't automatically detected and disabled.  Is there maybe a way to force Blockland to load and use music loops regardless of stereo status?  Filesize, even?

What really bugs me about this problem is that it would be really easily solved if stereo music loops weren't automatically detected and disabled.  Is there maybe a way to force Blockland to load and use music loops regardless of stereo status?  Filesize, even?
It would be easy to bypass the stereo check, however I don't know how the file size check works and am not on my computer to check.

It would be easy to bypass the stereo check, however I don't know how the file size check works and am not on my computer to check.

An add-on to bypass stereo check would be great.  Filesize check too, if anyone can find out how it works, as stereo would effectively double the filesize of a single loop and really limit loop length.

An add-on to bypass stereo check would be great.  Filesize check too, if anyone can find out how it works, as stereo would effectively double the filesize of a single loop and really limit loop length.
As long as it isn't part of the engine I can find a way to bypass it, however I am quite busy so that won't happen soon. Maybe someone else can get to do it faster.

Set the max distance to the same as the reference distance.

Set the max distance to the same as the reference distance.
Still doesn't fix the 3d aspect of it, where if you look to the left, you only hear it on the right side.

So really, a script to by pass stereo and/or filesize check would be great.

So really, a script to by pass stereo and/or filesize check would be great.
As long as you aren't using game modes, this should work.

function createMusicDatablocks()
{
   updateMusicList();

   %dir = "Add-ons/Music/*.ogg";
   %fileCount = getFileCount(%dir);
   %filename = findFirstFile(%dir);

   for(%i = 0; %i < %fileCount; %i++)
   {
      %base = fileBase(%filename);
      %uiName = strreplace(%base, "_", " ");
      %varName = getSafeVariableName(%base);

      if(!$Server::Dedicated && (getRealTime() - $lastProgressBarTime) > 200)
      {
         LoadingProgress.setValue(%i / %fileCount);
         $lastProgressBarTime = getRealTime();
         Canvas.repaint();
      }

      if(!isValidMusicFilename(%filename))
      {
         %filename = findNextFile(%dir);
         break;
      }

      if($Music__[%varName] == 1)
      {
         %dbName = "musicData_" @ %varName;
         %command = "datablock AudioProfile(" @ %dbName @ ") {filename = \"" @ %filename @ "\"; description = AudioMusicLooping3d; preload = true; uiName = \"" @ %uiName @ "\";};"
         eval(%command);
      }

      %filename = findNextFile(%dir);
   }
}