This article's documentation is for anything that uses the Source engine. Click here for more information.

Env microphone: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(56 intermediate revisions by 31 users not shown)
Line 1: Line 1:
Records sound from a location for either playback or monitoring.
{{LanguageBar}}
{{TabsBar|main=s2|base=env_microphone}}
[[File:env_microphone.png|left]]
{{CD|CEnvMicrophone|file1=envmicrophone.cpp}}
{{this is a|point entity|name=env_microphone}} It acts as a microphone. In "Speaker mode", it picks up sound and rebroadcasts it at a '''Speaker target'''. It ignores the ''Hears X'' spawnflags and does not fire the SoundLevel output. In "Measuring mode", it measures the sound level at a '''Measure target''' and outputs the sound level as a value between 0 and 1. It only hears sounds that match the ''Hears X'' spawnflags.
 
 
__TOC__
{{clr}}
 
== Flags ==
{{fl|1|Hears combat sounds}}
{{fl|2|Hears world sounds}}
{{fl|4|Hears player sounds}}
{{fl|8|Hears bullet impacts}}
{{fl|16|Swallows sounds routed through speakers}}
:{{note|In speaker mode, sounds heard by the microphone will not play from their source, instead only being heard through this microphone's speaker.}}
{{fl|32|Hears explosions}}
{{fl|64|Ignores non-attenuated sounds}}


==Keyvalues==
==Keyvalues==
* '''Measure target:''' The location from where sound levels are to be monitored. If blank, the env_microphone's own position will be used.
{{KV Targetname}}
* '''Speaker:''' The entity from which recorded sounds will come. If this is not set, the microphone will monitor sound levels instead. '''Cannot be an env_speaker!'''
{{KV|Speaker target|intn=SpeakerName|targetname|The name of an {{ent|info_target}} at which to play any sounds heard by this microphone. If specified, the microphone will consider itself in Speaker mode. This should not be an {{ent|env_speaker}}.}}
* '''Listen Filter:''' The microphone will only hear sounds coming from the entites covered by this filter entity. Must be <code>[[filter_activator_class]]</code>, <code>[[filter_activator_name]]</code>, or <code>[[filter_multi]]</code>.
:{{bug|If the speaker entity is moving, sounds will start playing at the correct position, but they will not follow the speaker as they continue playing.}}
* '''Speaker DSP Preset:''' Adds Digital Sound Processing to this microphone's recordings:
:{{note| If multiple {{ent|info_target}} with the same name are referenced only one will output sounds.}}
** '''Use Default:''' Adds basic the speaker DSP effect. This decreases the playback's quality as a cheap microphone/speaker setup might.
{{KV|Measure target|intn=target|targetname|If the speaker is in Measuring mode, this is the name of the entity where the sound level is to be measured.}}
** '''1 NO EFFECT:''' Sounds are played back at the exact quality they are recorded
{{KV|Listen Filter|intn=ListenFilter|filter|The name of a filter entity which specifies the only entities the microphone can hear. Sounds emitted by other entities will not be heard.}}
** '''2-5 (DUPLICATE OF 1):''' Obsolete?
{{KV|Speaker DSP Preset|intn=speaker_dsp_preset|choices|Only useful in Speaker mode. If specified, sounds played back through speakers will be affected by the selected [[DSP]].}}
** '''6 SPEAKER, LOUDER:''' The basic speaker DSP, plus extra volume
:{{bug|Having multiple <code>env_microphone</code>s with different DSP presets active at the same time will cause only one of the DSP presets to work, even if the microphones are nowhere near each other. This is because this entity just sets a [[ConVar]] called <code>dsp_speaker</code>.}}
** '''7 SPEAKER VERY SMALL:''' Simulates a very small speaker
:*0: Use environment default
** '''8 LOUDSPEAKER, ECHO:''' Forcibly adds echo to the playback
:*50: ''(No effect)''
** '''9 SPEAKER SMALL:''' A weaker version of 7
:*51: ''(No effect)''
** '''10 SPEAKER TINY:''' A stronger version of 7
:*52: ''(No effect)''
* '''Sensitivity (0-10):''' If the speaker is being used to monitor sound levels, this keyvalue dictates its sensitivity.  
:*53: ''(No effect)''
** '''0:''' deaf
:*54: ''(No effect)''
** '''1:''' normal  
:*55: Loud speaker
** '''2-10:''' increasing sensitivity
:*56: Very small speaker
* '''Smoothing (0-1):''' Smooths the microphone's readout if it is being used to monitor.
:*57: Echoing speaker
* '''Maximum hearing range (0-infinite):''' How far away the microphone should record sounds from.
:*58: Small speaker
:*59: Tiny speaker
:{{note|This keyvalue can also use the settings seen on the [[DSP]] page.}}
{{KV|Sensitivity (0-10)|intn=Sensitivity|float|Sensitivity in measuring mode. 1 is normal, and anything between there and 10 is increasingly sensitive.}}
{{KV|Smoothing (0-1)|intn=SmoothFactor|float|How much to smooth the output value of measuring mode.}}
{{KV|Maximum hearing range (0{{=}}infinite)|intn=MaxRange|float|Sounds beyond this range won't be heard.}}
:{{warning|setting this to 0, or greater 1024 when the microphone is in Speaker mode can be very bad for performance!}}
{{KV|Sound Mask|intn=SoundMask|int|nofgd=1}}
:{{todo|Some kind of alternative to the Hears X spawnflags?}}
{{KV StartDisabled}}


==Inputs==
==Inputs==
* '''SetSpeakerName:''' Alter the output speaker for this microphone.
{{I|SetSpeakerName|param=targetname|Sets the <code>info_target</code> through which the microphone should emit what it hears.}}
{{I EnableDisable}}


==Outputs==
==Outputs==
* '''SoundLevel:''' Fires if the sound level of an area changes when the microphone is in measuring mode.
{{O|SoundLevel|ac-is-this=1|param=float|Fired in Measuring mode whenever the sound level changes.}}
* '''OnRoutedSound:''' Fires when a sound is routed through the microphone's speaker.
{{O|OnRoutedSound|ac-is-this=1|Fired whenever a sound is routed out through the specified speaker (if any).}}
* '''OnHeardSound:''' Fires when the microphone hears any sound it cares about, regardless of how it is handled.
{{O|OnHeardSound|ac-is-this=1|Fired whenever this microphone hears any sound it cares about.}}
 
==See also==
* {{ent|point_camera}}


[[Category:Sound System]]
[[Category:Sound System]]
[[Category:Entities]]

Latest revision as of 08:49, 28 June 2025

English (en)Русский (ru)中文 (zh)Translate (Translate)
Env microphone.png
C++ Class hierarchy
CEnvMicrophone
CPointEntity
CBaseEntity
C++ envmicrophone.cpp

env_microphone is a point entity available in all Source Source games. It acts as a microphone. In "Speaker mode", it picks up sound and rebroadcasts it at a Speaker target. It ignores the Hears X spawnflags and does not fire the SoundLevel output. In "Measuring mode", it measures the sound level at a Measure target and outputs the sound level as a value between 0 and 1. It only hears sounds that match the Hears X spawnflags.


Flags

Hears combat sounds : [1]
Hears world sounds : [2]
Hears player sounds : [4]
Hears bullet impacts : [8]
Swallows sounds routed through speakers : [16]
Note.pngNote:In speaker mode, sounds heard by the microphone will not play from their source, instead only being heard through this microphone's speaker.
Hears explosions : [32]
Ignores non-attenuated sounds : [64]

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Speaker target (SpeakerName) <targetname>
The name of an info_target at which to play any sounds heard by this microphone. If specified, the microphone will consider itself in Speaker mode. This should not be an env_speaker.
Icon-Bug.pngBug:If the speaker entity is moving, sounds will start playing at the correct position, but they will not follow the speaker as they continue playing.  [todo tested in ?]
Note.pngNote: If multiple info_target with the same name are referenced only one will output sounds.
Measure target (target) <targetname>
If the speaker is in Measuring mode, this is the name of the entity where the sound level is to be measured.
Listen Filter (ListenFilter) <filter>
The name of a filter entity which specifies the only entities the microphone can hear. Sounds emitted by other entities will not be heard.
Speaker DSP Preset (speaker_dsp_preset) <choices>
Only useful in Speaker mode. If specified, sounds played back through speakers will be affected by the selected DSP.
Icon-Bug.pngBug:Having multiple env_microphones with different DSP presets active at the same time will cause only one of the DSP presets to work, even if the microphones are nowhere near each other. This is because this entity just sets a ConVar called dsp_speaker.  [todo tested in ?]
  • 0: Use environment default
  • 50: (No effect)
  • 51: (No effect)
  • 52: (No effect)
  • 53: (No effect)
  • 54: (No effect)
  • 55: Loud speaker
  • 56: Very small speaker
  • 57: Echoing speaker
  • 58: Small speaker
  • 59: Tiny speaker
Note.pngNote:This keyvalue can also use the settings seen on the DSP page.
Sensitivity (0-10) (Sensitivity) <float>
Sensitivity in measuring mode. 1 is normal, and anything between there and 10 is increasingly sensitive.
Smoothing (0-1) (SmoothFactor) <float>
How much to smooth the output value of measuring mode.
Maximum hearing range (0=infinite) (MaxRange) <float>
Sounds beyond this range won't be heard.
Warning.pngWarning:setting this to 0, or greater 1024 when the microphone is in Speaker mode can be very bad for performance!
Sound Mask (SoundMask) <integer> !FGD
Todo: Some kind of alternative to the Hears X spawnflags?
Start Disabled (StartDisabled) <boolean>
Stay dormant until activated (with theEnableinput).

Inputs

SetSpeakerName <targetnameRedirectInput/string>
Sets the info_target through which the microphone should emit what it hears.

EnableDisable:

Enable / Disable
Enable/disable this entity from performing its task. It might also disappear from view.

Outputs

SoundLevel <floatRedirectOutput/float>
!activator = !caller = this entity
Fired in Measuring mode whenever the sound level changes.
OnRoutedSound
!activator = !caller = this entity
Fired whenever a sound is routed out through the specified speaker (if any).
OnHeardSound
!activator = !caller = this entity
Fired whenever this microphone hears any sound it cares about.

See also