Talk:Ambient generic

From Valve Developer Community
Revision as of 09:03, 5 August 2018 by Pinsplash (talk | contribs) (help notice)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Is it possible to stop a music MP3 playing? I've got a section of my map where if the player goes very quickly, they'll trigger the next track before the previous one has ended. Ideally, I'd fade the old one out and start the new one, but that doesn't appear to work - instead I get both playing simultaneously. Any ideas? --Cargo Cult 14:58, 29 Aug 2005 (PDT)

Found that the stopsound command does the trick, in a rather hacky manner - it stops everything playing. I've got a point_clientcommand to do this - a logic_relay timer counts down so that if the first music track finishes playing naturally, it disables the logic_relay thingy which would send the stopsound command. If that makes sense. The second, command-sending logic thingy also starts up the relevant soundscape and ambient sounds... --Cargo Cult 13:46, 30 Aug 2005 (PDT)
I know it's most likely too late, but wouldn't it be easier to just kill the entity? --Vaarscha 14:22, 19 Mar 2006 (PST)
FadeIn and FadeOut are in as of Episode One. --TomEdwards 12:29, 5 Aug 2006 (PDT)
My hacky way of stopping a sound - set the Volume to 0. Works like a charm. --Campaignjunkie (talk) 21:32, 10 Sep 2006 (PDT)
NONE of this seems to work for me. I even tried manually doing it using the ent_fire command. --Darthkillyou 19:11, 19 Apr 2007 (PDT)

Definition List

I've converted this article to use the Wiki's DL system, which simplifies markup considerably. There are a few minor problems:

  • The table breaks the list into three due to a Wiki limitation
  • Another Wiki limitation means that the Flags had to have their semicolons replaced with dashes
  • I couldn't convert the Template:I Targetname, as that would have messed up other articles

Nothing too major. What do people think? With some find/replacing (perhaps even at Valve's end) the conversion could be fairly quick. --TomEdwards 12:29, 5 Aug 2006 (PDT)

Personally I think it's a bit much to save a few bytes of bandwidth as I am happy with the current template—ts2do 12:42, 5 Aug 2006 (PDT)
In terms of reading the pages, I see no significant positives or negatives. In terms of editing the pages, I can see that it's simpler and easier to visually parse. However, the Input/Output/Flag listings are basically "finished" (in that I can't imagine any significant improvements in information content that could be made), excepting new entities.
Given that, (and given that the '''s straddle the word and so would require regular expressions to change automatically, instead of just simple find/replace?), I can't see the change being worthwhile in cost:benefit terms. But if you want to volunteer ... --Giles 12:55, 5 Aug 2006 (PDT)
You could catch them with the *''' pattern, but honestly I have no idea about regular expressions. --TomEdwards 13:06, 5 Aug 2006 (PDT)

SourceEntityName

In a map I'm currently working on, I need to play a sound and it must follow the object that is supposed to make this sound. After realizing that there's no "parent" property for this entity I tried to use the "SourceEntityName" one. Actually it works well in the way that the sound is following the object, but the problem is that the sound's volume has been lowered and can't be heard at all. You must put the player 30 units away from the ambient_generic to hear it properly. It's really strange because it's volume is set to 10 (the maximum) and if I delete the "SourceEntityName" field, the sound's volume reverts to normal.. Is there a way to have a sound following a moving entity without having to duplicate it 10 times in order to multiply the volume by 10 ? --NykO18

The only way i can think of is making the sound itself louder.

Is it a Raw sound or a game sound? Raw sounds tend to be a bit buggy with ambient generic. --Mzullos5 10:21, 28 April 2013 (PDT)

Templates

I have another problem: When I spawn a prop_physics via point_template and env_entity_maker, Source Entity Name set to the Template. But the Sound is only played where the Template is, even when I use the name fixup (also tried <entityname>&0000-&0002 for Source Entity Name). When the Template is removed, the ambient_generic plays the Sound where the ambient_generic is. Puchi 12:11, 4 Dec 2007 (PST)

I made a disco room with multiple func_walls named "speakers" to which I had an ambient_generic with the SourceEntityName set to the speakers. The outcome was only one of the func_walls had music coming from it and it was very low. I tried the same but instead of func_walls I used ambient_generics and this did not work. It seems this does option does not work properly. I was able to get what I wanted by adding more ambient_generics with the same name and same sound file playing at the same time. --MongoTheMad 17:08, 22 July 2009 (UTC)

Seems to me that you should try to find the name of the entity that's actually spawned. Try turning on developer mode and +using it: the name should appear in the console. --TomEdwards 17:22, 22 July 2009 (UTC)

Starting Silent

I've noticed that you cannot get this entity to actually start on map spawn - not automatically, on its own - making the Start Silent flag a mystery. ...or am I wrong? I can't hear anything at least. Can you? --Andreasen 18:32, 10 Sep 2006 (PDT)

In theory, having this flag off starts the sound automatically only if it's a looping sound. If this is not what you observe, (complete guess:) the problem may be because it is trying to start the sound before the player is in the map.—ts2do 19:36, 10 Sep 2006 (PDT)
I always thought it was to make the sound fade in rather than start playing at 100% immediately. --TomEdwards 02:13, 11 Sep 2006 (PDT)
If it is, you might want to go through the trouble of retesting the functions of the PlaySound, StopSound and Volume I/O, because I think those sounds were started silently when I tested them. --Andreasen 09:42, 11 Sep 2006 (PDT)
Researched it: The Is NOT Looped flag will cancel out the cleared Start Silent flag. Whether the sample itself is looped or not, you must always have the Is NOT Looped flag cleared for it to play at the beginning. --Andreasen 12:05, 11 Sep 2006 (PDT)

Which is sorta exactly what I said—ts2do 13:46, 11 Sep 2006 (PDT)

Yes, but now I've confirmed it too. :P ("In theory" sounded so vague.) --Andreasen 14:13, 11 Sep 2006 (PDT)

Needs clarifications

Descriptions like "<integer> Spin up time (0-100)" mean nothing. This page needs actual descriptions of what the different values do. Thelonesoldier 00:10, 5 Feb 2007 (PST)

Many of the entity descriptions on support pages are like this I had hoped this place would build up real descriptions to clarify more. This has been an ongoing problem since HL1 SantagausS 21:42, 16 Feb 2007 (PST)

Sounds not working on dedicated servers

I have noticed that sound scripts do not seem to work on dedicated servers only raw sounds will work? This happens in hl2dm on linux servers. Can anyone confirm this and if so I think I will add a note as it caused me to lose quite a bit of time screwing with it. SantagausS 21:42, 16 Feb 2007 (PST)

This is something to do with server and client soundscripts being different, IIRC. Most script sounds ought to work, unless you're doing them custom and not shipping your script along with the map. --TomEdwards 03:21, 17 Feb 2007 (PST)

Music Previews

Um... How do you preview music? I can preview .wav sounds but not any of the .mp3 (music) sounds. I hate having to go in-game to figure out how each music file sounds like. --Darthkillyou 18:49, 19 Apr 2007 (PDT)

GCFScapets2do 21:15, 19 Apr 2007 (PDT)
Thanks, sorry it took so long to reply. --Darthkillyou 16:11, 6 Jul 2007 (PDT)

Using ambient_generic (or any other means) to create a global ticking sound in Portal

I have a func_button with "Use Activates", to start a logic_relay to open a door, play a sound, and activate a timer_relay, of which drives an ambient_generic that plays the Portal ticking noise every second.

The ambient_generic is set with all three flags checked... but the sound still acts as if the "Play Everywhere" flag was not checked. What gives? And how else could I make the desired effect?--volt 02:33, 22 Nov 2007 (PST)

Instead use a logic_choreographed_scene.--Gear 04:02, 22 Nov 2007 (PST)

How to use the FadeIn input

Does someone ever managed to use this input ? I'd like to start a sound by rising its volume slowly, but it seems there's no way do to so. I tried almost everything, a WAV, a looping WAV, a MP3, FadeIn alone, PlaySound then FadeIn, Volume then FadeIn, PlaySound then Volume and FadeIn. Nothing works, the sound does not start or starts immediately. Surprisingly, the FadeOut input works like a charm.. --NykO18 14:49, 1 Mar 2008 (PST)

You're right, it's broken. The "Fade in time" keyvalue still works, at least. I've looked at the source code and it appears that fadein doesn't work because the sound has to be playing to fade in - and if you start it at full volume, there's no fading to do! I'll look into a fix, but there's all sorts of low-level maths in this code (sound.cpp ln601)... --TomEdwards 00:47, 2 Mar 2008 (PST)
I'm out of ideas. --TomEdwards 01:23, 2 Mar 2008 (PST)
Can't you try setting Volume at 0, starting the sound with FadeIn, and then setting Volume at the desired amount? Solokiller 04:11, 2 Mar 2008 (PST)
That's what I tried! --TomEdwards 05:12, 2 Mar 2008 (PST)
To make FadeIn work, fire both PlaySound and FadeIn at the same time, seems to work for me! --Pandaboy 02:19, 31 October 2011 (PDT)

Sound sample rate

Hi there everyone, I was compressing a song to crappy sample rate, to give it the impression it was being played on a radio. It seems like the lowest bit rate (I think) .wav files support is 8KHz, (or apparently 8,000 something), so I chose that. But when I try to play the audio ingame, it says it's sample rate is not supported! So I'm just wondering if someone can clarify to me the supported range of sample rates.

44KHz and nothing else AFAIK. --TomEdwards 15:36, 3 August 2009 (UTC)
What a range that is :P If anyone else would like to add, please do.--Tgp1994 15:44, 3 August 2009 (UTC)
Microsoft ADPCM 22050Hz mono 89Kbps seems to work too (for wav). --Hoofd 15:35, 18 August 2010 (UTC)

Making a sound not loop

I'm trying to play a raw wave file. When I start it with a trigger, it loops. I have "is NOT looped" checked but from the article it sounds as if this doesn't actually make it not loop. Is there a way to prevent looping without using an input to stop the sound? Thelonesoldier 05:27, 19 October 2010 (UTC)

  • It seems that the flag works inverted.

Strange Fading Behavior

I was having serious trouble getting the fade in and fade out values to work, and the information in this page was not very helpful or accurate in figuring out the problem. Now that I've found a solution, I thought I'd share it here.

I had a looping piece of music that I wanted to fade out when a StopSound input was triggered. Instead, StopSound would just abruptly cut off the music, regardless of what I put in the fade in or fade out time values.

The problem appears to have been this: in order for fading in and out to work, the Start Volume has to be zero and the Volume has to be nonzero. Since I wasn't fading in, I had both values set to 10. I changed Start Volume to 0 and suddenly fading out worked.

The descriptions of the FadeIn and FadeOut inputs are very misleading in this respect, as they seem to imply that the behavior of fading an ambient_generic in and out is independent of the volume values.

I would need to do more testing to confirm the exact mechanism by which this works in order to feel comfortable adding this information to the main article, but this should at least get the information out there. Catsy 08:30, 9 July 2012 (PDT)

Polyphony Limit

I believe I found a very annoying limit to the amount of ambient_generics that can be played at once. I was trying to make a "virtual" surround sound system by using 5 audio files, and emitting them from 5 "speakers" at the same time. But whenever I would play all five at once, the framerate would drop and all sound in the game, including menu sounds, would cease working. Emitting four sounds works fine. This is information that should probably be included in the entity's description.


Emitter and Wildcard/same-named entities (possibly CS:S only)

It's worth noting that an ambient_generic will not play/is silent if the designated targetname to emit from is either specified as a wildcard (even if this would resolve to only a single entity), or is not unique to a single entity.

You must have uniquely identifiable names for entities that use that sound and either change the specified targetname emitter using AddOutput, or duplicate the ambient_generic, with each targetting a specific entity. This can also be accomplished in many scenarios by using a point_template with name fixups to spawn the ambient_generic and its emitter target.

How can I add more music to use them on my map?

I'm building a custom Portal 1 map for Portal 2 and I'm in trouble with the music because I want to use the original music's like: "Self Esteem Fund".Unsigned comment added by FIRE-Buzzard (talkcontribs). Please use four tildes (~~~~) to sign your username.

Super easy. First, you wanna download GCFScape or a similar program (if you haven't already).
Go into the files for Portal 1 and look for portal_pak_dir.vpk and open it in GCFScape. Find the music file you want, and drag it onto your desktop for now.
Now go into your Portal 2 files, and in the "portal2" folder, make a folder called "sound" (it may already exist). Inside the sound folder, make a folder called "music". Insert your music file in this music folder.
That should be it. You may have to re-open Hammer before it recognizes the new file. Pinsplash (talk) 13:36, 20 July 2018 (UTC)


Thank you, it works. I got another problem though. When I set the ambient_generic to play a .wav file (from the new, imported Portal 1 musics) and run the map I don't hear it. The console says: "[Sound] S_StartSound(): Failed to load sound 'music\portal_self_esteem_fund.wav'. File is missing from disk/repository." (I also can't hear the preview while I set the music, if I use .mp3 I can hear it in the preview and also in the game but I can't loop it) FIRE-Buzzard (talk) 08:41, 5 August 2018 (UTC)

Try typing snd_rebuildaudiocache in the console. Pinsplash (talk) 14:06, 22 July 2018 (UTC)

Thank you. Everything works now! FIRE-Buzzard (talk) 08:41, 5 August 2018 (UTC)