Scripts / Play sound

Author
Message
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 20th Apr 2020 13:33 Edited at: 20th Apr 2020 14:08
HI all , just want to know is there a function out that can detect if a song has finished playing if you have started it with PlaySound(e,0)

edited
Can someone please explain the following:
g_SoundState = {}
PlaySoundIfSilent(e,v) -- does this mean play sound if there is no sound from entity or no sound at all in the game.?
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 20th Apr 2020 14:07
Nope. You has to use globalsound to achieve it.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 20th Apr 2020 14:38
About "g_SoundState = {}" I have not idea what it does. It looks like array variable to control looping sound as global.lua says.
About "PlaySoundIfSilent(e,v)" afaik it is intended to be played when not sound is playing, like "finalassault.ogg" or something like that, ignore if it works yet.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 20th Apr 2020 17:04 Edited at: 20th Apr 2020 17:05
would it be possible to , lets say load 5 song that is in a specific folder and then play them one by one?
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 20th Apr 2020 17:24
If you want to go via (PlaySound(e,0)) then you just have to define the paths in the slots via properties panel, and play the melodies by pressing a key, of course this depends on how you want to play the melodies.

For example you can have a jukebox and wait for all the melodies to play one after the other just by pressing a key, or through the mouse.

Could you clarify this point?
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 20th Apr 2020 17:29
Not actually, the idea i am after is to have a play list of a couple of songs, and these song would then be played from 1 to 4 over and over, like in a club , so every time the player get there a different song will play, and if you stand long enough there then they will just repeat one after the other.
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 20th Apr 2020 17:35
So I recommend you to use these LUA commands:

Quote: "
LoadGlobalSound: LoadGlobalSound (filename, iID) - where iID is an index greater than zero and filename points to a WAV file in your game installation
DeleteGlobalSound: DeleteGlobalSound (iID) - where iID is the index of the sound loaded in the load command
PlayGlobalSound: PlayGlobalSound (iID) - where iID is the index of the sound to be played
LoopGlobalSound: LoopGlobalSound (iID) - where iID is the index of the sound to be looped
StopGlobalSound: StopGlobalSound (iID) - where iID is the index of the sound to be stopped
SetGlobalSoundSpeed: SetGlobalSoundSpeed ​​(iID, speed) - where iID is the index of the sound to change the speed of
SetGlobalSoundVolume: SetGlobalSoundVolume (iID, volume) - where iID is the index of the sound to change the volume of
GetGlobalSoundExist: GetGlobalSoundExist (iID) - where iID is the index of the sound to check existence of
GetGlobalSoundPlaying: GetGlobalSoundPlaying (iID) - where iID is the index of the sound to check if playing
GetGlobalSoundLooping: GetGlobalSoundLooping (iID) - where iID is the index of the sound to check if looping"


If you have any questions let me know.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
AmenMoses
GameGuru Master
8
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 20th Apr 2020 17:37
Use global sounds would be my suggestion.

If you want to play sounds attached to an entity then you would need to work out how long each track is and use timer code to play them.
Been there, done that, got all the T-Shirts!
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 20th Apr 2020 18:32
it would have been so nice if Lee could program GG so that you have a loop sound function that can play all your entitle sound blocks
some thing like LoopSound (e,0 ,1 ,2 , 3 ,4)
The main problem is there is no function that can tel you if a sound file has finished playing.

Maybe the best is to join 6 sounds as one and then loop them.
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 20th Apr 2020 19:29 Edited at: 20th Apr 2020 19:30
I haven't tested it but this should work.

Attach however many sounds to the entity (i.e. soundslots 0 to 4) then append the length of the samples in seconds to the name of the entity separated by commas.
e.g. entityname,230,447,123

The script will simply play the sounds, wait the number of seconds and then play the next one.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 20th Apr 2020 21:28
Thanks AmenMoses.
There were small issues , witch i could fix but i don't know what this is.

Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 20th Apr 2020 21:38
Try this one



Just attach the script to a dynamic entity, make it "AlwaysActive = yes".
You most likely has to replace paths with your own in the script - I'm using 5 sounds there.
It works for me.

NJote: Please try it as is before do any chage.
hth
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
AmenMoses
GameGuru Master
8
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 20th Apr 2020 21:58
Oops, try this one.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 20th Apr 2020 22:13
Great !
Thank you AmenMoses and 3Com
Both the scripts work 100%
Thanks so much.

This Is the best forum any ware on the net.
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 21st Apr 2020 21:00
Thread has been moved to Scripts.
Store Assets - Store Link

i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce GTX 960
AmenMoses
GameGuru Master
8
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 21st Apr 2020 22:06
Horse has bolted!
Been there, done that, got all the T-Shirts!
PM
Pink Panther
14
Years of Service
User Offline
Joined: 1st Feb 2010
Location:
Posted: 23rd Apr 2020 21:50
Thank you both! Great scripts!
PM

Login to post a reply

Server time is: 2024-04-26 13:32:55
Your offset time is: 2024-04-26 13:32:55