Author Topic: Support_EngineSounds Concept  (Read 5311 times)

I have another question, is it possible for sound VOLUME to be manipulated with vehicle speed?

If it's possible, another possible idea we can have is a transition between an idling engine sound and a running engine sound.

Picture the muscle speedkart sound: You got the idling noise when you aren't moving, but as you start to roll, it slightly pitches up but ALSO quiets down. The faster you go, the running sound will become audible and additionally change pitch.

This would be controlled similarly to a velocity scale factor identical to how the engine sounds are developed.

Maybe shifting simulator via the engine sounds? IE: High RPM engine noise then "shift" to low RPM engine sound then back up like it would be when you are driving

audio emitters volume use a float (0 being muted and 1 being full volume)

you could apply different sounds and volume levels based on speed or shifting, etc

Would these sounds play directly from the vehicle or no? In other words, if you had one of those vehicle radio mods, would this affect that? I remember the Hydric's sound did.

I have another question, is it possible for sound VOLUME to be manipulated with vehicle speed?
Couldn't find a method do to this using alxSourceF for whatever reason

audio emitters volume use a float (0 being muted and 1 being full volume)
Don't think this applies to the method im using Vehicle.playAudio(slot, DB)

I wanted to add volume adjustment but not sure of how to change it

Does this help? From https://forum.blockland.us/index.php?topic=312575.0

Quote
function changeMusicPlayerVolume(%box) {
   if(%box) {
      %value = MusicPlayerVolumeValue.getVal ue();
      MusicPlayerVolume.setValue(%value);
   } else {
      %value = MusicPlayerVolume.getValue();
      MusicPlayerVolumeValue.setTex t(%value);
   }

   alxSourcef($MusicPlayer::CurrentMusic, "AL_GAIN_LINEAR", %value);
}

Does this help? From https://forum.blockland.us/index.php?topic=312575.0
ive tested AL_GAIN_LINEAR and AL_GAIN but they both seem to do nothing
« Last Edit: December 14, 2020, 04:24:42 PM by Buddy! »

Would these sounds play directly from the vehicle or no? In other words, if you had one of those vehicle radio mods, would this affect that? I remember the Hydric's sound did.
I assume that it would. However, there is a Boombox addon that plays music from the player instead of the vehicle. The command is /boombox, and I think it's a server-sided mod (not client sided)

Maybe shifting simulator via the engine sounds? IE: High RPM engine noise then "shift" to low RPM engine sound then back up like it would be when you are driving
thats the damned suggestion i made like 6 years ago wtf


I assume that it would. However, there is a Boombox addon that plays music from the player instead of the vehicle. The command is /boombox, and I think it's a server-sided mod (not client sided)
The vehicle stereo mod plays sounds from audio thread 0, which is the most used one. I always use thread 1, 2 or 3 for vehicle sounds for just that reason, so if you play this sound from thread 1, 2 or 3 you can still play the vehicle stereo music at the same time.

This code from Shock might be useful?
Code: [Select]
// note: theoretically, this add-on is not compatible with any other add-on (e.g. a gamemode) which uses the setTimescale() function (*not* serverCmdTimescale()).
// any add-on which uses setTimescale() must set $oldTimescale before calling it, or else any future playPitchedSound event that is activated is going to
// reset it back to the previous ($oldTimescale) timescale.
//
// if I could package setTimescale() to add another arg to make this more compatible, I would,
// but setTimescale() isn't packageable.

function pitchedSoundLegibility(%obj, %sound) {
  if(!isObject(%obj) || !isObject(%sound) || %sound.getClassName() !$= "AudioProfile")
    return false;

  if(%sound.description.isLooping)
    return false;

  if($oldTimescale $= "")
    $oldTimescale = getTimescale();

  return true;
}

function FxDTSBrick::playPitchedSound(%brick, %sound, %pitch) {
  if(!pitchedSoundLegibility(%brick, %sound))
    return;

  setTimescale(%pitch);

  serverPlay3D(%sound, %brick.getPosition());

  setTimescale($oldTimescale);
}

registerOutputEvent("FxDTSBrick", "playPitchedSound", "dataBlock Sound" TAB "float 0.2 2 0.01 1", 0);

function GameConnection::playPitchedSound(%client, %sound, %pitch) {
  if(!pitchedSoundLegibility(%client, %sound))
    return;

  setTimescale(%pitch);

  %client.play2D(%sound);

  setTimescale($oldTimescale);
}

registerOutputEvent("GameConnection", "playPitchedSound", "dataBlock Sound" TAB "float 0.2 2 0.01 1", 0);

if(isPackage(playPitchedSound))
  deactivatePackage(playPitchedSound);

package playPitchedSound {

  function serverCmdTimescale(%client, %timescale) {
    if(%client.isAdmin)
      $oldTimescale = mClampF(%timescale, 0.2, 2.0);

    parent::serverCmdTimescale(%client, %timescale);
  }

  function disconnectedCleanup(%doReconnect) { // non-dedis
    $oldTimescale = "";

    parent::disconnectedCleanup(%doReconnect);
  }

  function disconnect(%doReconnect) { // non-dedis
    $oldTimescale = "";

    parent::disconnect(%doReconnect);
  }

};

activatePackage(playPitchedSound);

Bump. How's progress?
basically done
This code from Shock might be useful?
Code: [Select]
this code only plays a new sound in a certain pitch, for this mod to work you need to actively change the pitch using something like
Code: [Select]
alxSourcef( audioHandleID , "AL_PITCH", %value);