Playing sound from a moving entity

Jusa

aa
May 28, 2013
377
618
I've been trying to get some elevator music to play on my elevator.

Ambient generic cant be parented so I tried using info_target as the ambinet generics source entity but that does not seem to work (its acting really weird, it works when I first load the map up, but as soon as I join a team the sound starts to play from the ambient generic itself.)

Is there no other way to get a moving entity to play a sound? For the love of god, my elevator needs some music in it.


asd.JPG


I'll upload a video in a moment >
 

Jusa

aa
May 28, 2013
377
618
Did you look at what trains do? It's the same as a train.
Why the fuck did I not think of that. Will check >

edit: well I guess I am not allowed to use info_target as a sound source entity. Something funky going on with that. Seems to be fine if I use the elevator itself as a source.

edit2: or not, now the sound is gone again. I have no idea whats causing this. It played fine the first time I loaded the map, and now its just complete silence. I even tried to set up a logic auto to play the sound on every possible scenario but still nothing.

edit3: Jeez I'm stoopid. I didn't realize the sound wasnt looping (even tho I set it to loop. I thought it will force loop anything.) and that was causing all this sillyness.
 
Last edited:

worMatty

Repacking Evangelist
aa
Jul 22, 2014
1,257
999
If you parent an info_target, then it will be removed from the map on load. If you prefer to place the sound origin yourself rather than use the origin of the train, you can use an env_spark in the Off state, that is parented to your train.
 

Jusa

aa
May 28, 2013
377
618
If you parent an info_target, then it will be removed from the map on load. If you prefer to place the sound origin yourself rather than use the origin of the train, you can use an env_spark in the Off state, that is parented to your train.
I see, thanks a lot! I was afraid I wouldn't be able to tune the sound to come from a set of speakers.
 

Jusa

aa
May 28, 2013
377
618
So now that I know the problem is the sound only playing once, I ran into another problem.
The sound is 60 seconds long so I made a logic_timer with the output "play sound" after every 60 seconds.
The music will still only play once.

I am using the unused mvm music loop : items/tf_music_upgrade_machine.wav

edit: So it seems like I have to stop the sound playing first to make it play again. (So I made the logic_timer stop the sound after 60 seconds and added playsound outputs with a 0.5 second delay every 60 seconds. Seems like that did the trick.)
 
Last edited:

Jusa

aa
May 28, 2013
377
618
Never thought it would take me actual hours the set up music for an elevator. I guess this day had to come one day.
 

Jusa

aa
May 28, 2013
377
618
And the next problem:

The sound will not play to the played if the player has been outside of the sounds maximum range when the sound started playing.

So, if the loop starts every 60 seconds, the player is outside the maximum range just before the sound is triggered to start again, the player will only hear the sound after the next trigger, 60 seconds later.

Anyone care to explain why the hell is making elevator music work so hard ;-;
 
Last edited:

Jusa

aa
May 28, 2013
377
618
Would it be possible to use the "items/tf_music_upgrade_machine.wav" sound file as a soundscape or create a soundscape that uses the file included in the game already?
 

worMatty

Repacking Evangelist
aa
Jul 22, 2014
1,257
999
I have multiple suggestions.

If a sound is initiated out of earshot of a player, they will begin to hear it when they come in to contact with it. However, if a sound is initiated before a player loads the map, then he will not hear it until it is played again.

I checked that sound file in GoldWave, and it is not actually a looping wav. It is a straight wav, the sort of thing that would ordinarily be treated as a single sound effect, that when used with an ambient_generic, should not require stopping before being played again. This means that you should make sure that the spawnflag Is NOT looped is ticked, for your ambient_generic. If you remove the tick from that box, it means that the behaviour you describe, where the sound must be stopped before it can be played again, is exhibited. Treating the sound like an unlooped wav allows you to use the playsound input exclusively. I have just tested that and found it to be true.

You could indeed make the sound in to a soundscape. You can parent soundscape entities. But be mindful that players would continue to hear the elevator music until they were exposed to another soundscape. I think using the ambient_generic is the cleanest way, and it also allows players to hear the music from a distance without it interfering with their soundscape.
 

Jusa

aa
May 28, 2013
377
618
Never would have realized that "Is NOT looped" could cause that.
I tried this, but one problem remains:

I have two elevators, on both sides of the map. If I am in the other elevator when the sounds are triggered, I hear the music in that elevator. But if I move to the other elevator before another trigger happens, I will not hear anything. So I'm guessing if I am out of the ambient generics maximum range when the trigger happens, I will not hear the music playing until another trigger happens? Thats what it seems like to me and it really boggles my mind.

This is why I was thinking about using soundscapes, so I can make sure the music is played when the player is in the elevator.
 

worMatty

Repacking Evangelist
aa
Jul 22, 2014
1,257
999
No, that shouldn't happen, unless it's a bug. Only thing I can recommend you try is to double check your logic, make sure you are using one ambient_generic for each train and that the trains have unique names. Then try playing one of the ambs slightly later than the first. If that doesn't work you could try turning the sounds in to game sound names in your own custom sound script. Do the sound scape thing as a last resort.
 

Jusa

aa
May 28, 2013
377
618
Well I checked and double checked but can't figure a way my logic could cause this. If I am riding one of the elevators the music will play all the time. So it should play in both all the time. I can upload a video, maybe that would explain it better.

The elevators are both named unique and the both have their own ambient generics.

Will try having two different timers as soon as I get home.
 

Jusa

aa
May 28, 2013
377
618
So I guess it is just how ambient generic works?

Some people at chat suggested using a trigger brush, but that will cause its own problems.

case1
1. P1 enters the elevator and triggers the music, while P2 was outside the ambient generics maximum range.
2. P2 enters the elevator to ride it with P1, but hears no music.

case2
Or, if the music was set to start from the begining every time a player touches the trigger, P1 would hear a silly cut in the music as P2 would enter the cozy ride.


What if the soundfile was edited to be a looping sound? Would it still be silent to those who were outside of the maximum range during the trigger?

THIS REALLY SHOULD NOT BE SO DIFFICULT
 
Last edited: