Skip to content

Interaction Sounds

Alex Smith edited this page Jan 1, 2024 · 1 revision

Interaction sounds determine the sound effects players hear when pressing buttons. They are activated using the SOUND action in user commands.

By default, Photon 2 has multiple controller "beep" sounds, each one based on sounds by real manufacturers.

As a part of Photon 2's library, you can create new interaction sound profiles and easily export them as standalone addons. They are also integrated with Photon 2's Equipment system, which allows them to be swappable in-game when configured.

gmod_t5lTpQPJlG.mp4

Enable sound on the video above to hear the demonstration.

Usage

Interaction sounds are configured in the vehicle file's Equipment table.

VEHICLE.Equipment = {
   {
      Category = "Controller Sound",
      Options = {
         {
            Option = "Whelen",
            InteractionSounds = {
               { Class = "Controller", Profile = "whelen_cencom" }
            }
         }
      }
   }
}

Creation

Interaction sound files should be created in the following directory:

garrysmod/addons/my_custom_addon/lua/photon-v2/library/interaction_sounds/my_sounds.lua
Photon2.RegisterInteractionSound({
   -- Defines the sound's type (usually "Click" or "Controller")
   Class = "Controller",
   -- Unique name used to reference the profile
   Name = "unique_identifier",
   -- User friendly name
   Title = "Display Name",
   -- Profile's default sound file/parameters
   Default = {
      Sound = "photon/generic/click1.wav",
      -- Sound duration in seconds (to prevent overlapping)
      Duration = 0.025,
      -- 0-100
      Volume = 50,
      -- Pitch
      Pitch = 100
   },
   -- If this sound should play on a button-down event
   Press = true,
   -- If sound should play when a button is released
   Release = true,
   -- If sound should play when a button is released after a "momentary" action (e.g. manual siren)
   Momentary = true,
   -- If sound should play when a button was pressed and held
   Hold = true
})

Also note that multiple interaction sounds can be registered in a single file (unlike components and vehicles).

Key Activities

On real world control boxes, the precise action that plays a sound varies and is sometimes configurable, depending on the manufacturer of the control box and the precise model.

For example, Whelen controllers beep when a button is pressed and then again when the button is released (giving them a distinctive click-click sound). On modern Federal Signal controllers, buttons only beep once when pressed, unless the button is specifically configured for a "momentary" function (meaning only as long as the operator has their finger pressing it), in which case it will beep again when the button is released. On modern Code 3 controllers, buttons beep only beep once altogether.

By configuring the key activities options, Photon 2 is able to simulate all of this behavior.

Classes

Photon uses two classes by default: "Click" and "Controller". Click is intended for generic vehicle interactions (e.g. turn signals) while Controller is for the "beep" sounds of a controller keypad.

Additional classes can be defined, but will only activate when a command action is configured to utilize it.

Advanced

If desired, an interaction sound profile can be configured to play a different sound based on the press event.

Photon2.RegisterInteractionSound({
   Class = "Controller",
   Name = "unique_identifier",
   Title = "Display Name",
   Default = {
      Sound = "photon/generic/click1.wav",
      Duration = 0.025,
      Volume = 50,
      Pitch = 100
   },
   Press = true,
   Release = false,
   Momentary = true,

   -- Different sound will play when button is held
   Hold = {
      Sound = "my_sounds/hold_beep.wav",
      Duration = 0.1
   }

})

When a press event is only set to true, it simply inherits Default.