<commit_before>--[[
 The Wire Sound Emitter emits a sound whose parameters can be tweaked.
 See http://wiki.garrysmod.com/page/Category:CSoundPatch
--]]

AddCSLuaFile()
DEFINE_BASECLASS( "base_wire_entity" )
ENT.PrintName       = "Wire Sound Emitter"
ENT.WireDebugName = "Sound Emitter"

if CLIENT then return end

local DefaultSamples = {
	"synth/square.wav",
	"synth/saw.wav",
	"synth/tri.wav",
	"synth/sine.wav"
}
for _, str in pairs(DefaultSamples) do util.PrecacheSound(str) end

function ENT:Initialize()
	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	self:SetSolid( SOLID_VPHYSICS )

	self.Inputs = Wire_CreateInputs(self, { "A", "Toggle", "Volume", "Play", "Stop",
		"PitchRelative", "Sample", "SampleName [STRING]" })
	self.Outputs = Wire_CreateOutputs(self, { "Duration", "Property Sound", "Properties [ARRAY]", "Memory" })

	self.Samples = table.Copy(DefaultSamples)

	self.Active = false
	self.Volume = 5
	self.Pitch = 100
	self.sound = self.Samples[1]
	-- self.sound is a string, self.SoundObj is a CSoundPatch

	self.NeedsRefresh = true

	hook.Add("PlayerConnect", self:GetClass() .. self:EntIndex(), function()
		self.NeedsRefresh = true
	end)
end

function ENT:OnRemove()
	hook.Remove("PlayerConnect", self:GetClass() .. self:EntIndex())
	self:StopSounds()<commit_msg>Sound Emitter: Changed initial volume from 5% -> 100% Re: #670<commit_after>--[[
 The Wire Sound Emitter emits a sound whose parameters can be tweaked.
 See http://wiki.garrysmod.com/page/Category:CSoundPatch
--]]

AddCSLuaFile()
DEFINE_BASECLASS( "base_wire_entity" )
ENT.PrintName       = "Wire Sound Emitter"
ENT.WireDebugName = "Sound Emitter"

if CLIENT then return end

local DefaultSamples = {
	"synth/square.wav",
	"synth/saw.wav",
	"synth/tri.wav",
	"synth/sine.wav"
}
for _, str in pairs(DefaultSamples) do util.PrecacheSound(str) end

function ENT:Initialize()
	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	self:SetSolid( SOLID_VPHYSICS )

	self.Inputs = Wire_CreateInputs(self, { "A", "Toggle", "Volume", "Play", "Stop",
		"PitchRelative", "Sample", "SampleName [STRING]" })
	self.Outputs = Wire_CreateOutputs(self, { "Duration", "Property Sound", "Properties [ARRAY]", "Memory" })

	self.Samples = table.Copy(DefaultSamples)

	self.Active = false
	self.Volume = 100
	self.Pitch = 100
	self.sound = self.Samples[1]
	-- self.sound is a string, self.SoundObj is a CSoundPatch

	self.NeedsRefresh = true

	hook.Add("PlayerConnect", self:GetClass() .. self:EntIndex(), function()
		self.NeedsRefresh = true
	end)
end

function ENT:OnRemove()
	hook.Remove("PlayerConnect", self:GetClass() .. self:EntIndex())
	self:StopSounds()
{'fraction_non_alphanumeric': 0.14307060141949943, 'fraction_numerical': 0.007097497198356369, 'mean_word_length': 5.0588235294117645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7235195', 'n_tokens_mistral': 1009, 'n_tokens_neox': 945, 'n_words': 216}