PDA

View Full Version : Play random music



Toxys
12th November 2020, 17:47
How can I play random music? I know I need to define the .mp3 files which I want to play in the soundaliases/iw_soun2.csv, I want to play to all players at the same time but once so I need to add local or for ex.:
music1,,,music/music1.mp3,1,1,,,,1000000,,auto,streamed
music2,,,music/music2.mp3,1,1,,,,1000000,,auto,streamed
music3,,,music/music3.mp3,1,1,,,,1000000,,auto,streamed
will be okay?

And maybe I need to create a table with "music1", "music2", "music3" ... so the random function can select one of them?

voron00
12th November 2020, 18:36
The 'sequence' param is what you're looking for.



name,sequence,file,vol_min,vol_max,vol_mod,pitch_m in,pitch_max,dist_min,dist_max,channel,type,probab ility,loop,masterslave,loadspec,subtitle,compressi on,secondaryaliasname,volumefalloffcurve,startdela y,speakermap,reverb,lfe percentage

dr_music,1,music/88ridge_approaching_ridge2_GRFINAL.mp3,,,,,,,,musi c,streamed,,,,all_mp,,,,,,local
dr_music,2,music/british_action_artillery_GRFINAL.mp3,,,,,,,,music, streamed,,,,all_mp,,,,,,local
dr_music,3,music/british_decoytown_intro_short_GRFINAL.mp3,,,,,,,,m usic,streamed,,,,all_mp,,,,,,local
dr_music,4,music/british_decoytrenches_dump2_GRFINAL.mp3,,,,,,,,mus ic,streamed,,,,all_mp,,,,,,local
dr_music,5,music/demolition_soviet_charge_GRFINAL.mp3,,,,,,,,music, streamed,,,,all_mp,,,,,,local
dr_music,6,music/downtownsniper_soviet_tension_GRFINAL.mp3,,,,,,,,m usic,streamed,,,,all_mp,,,,,,local
dr_music,7,music/libya_charge_crusader_long_GRFINAL.mp3,,,,,,,,musi c,streamed,,,,all_mp,,,,,,local
dr_music,8,music/toujane_armoredcar_crash_GRFINAL.mp3,,,,,,,,music, streamed,,,,all_mp,,,,,,local
dr_music,9,music/toujane_vehicle_danger_loop_GRFINAL.mp3,,,,,,,,mus ic,streamed,,,,all_mp,,,,,,local
dr_music,10,music/toujane_vehicle_ride_GRFINAL.mp3,,,,,,,,music,stre amed,,,,all_mp,,,,,,local

Toxys
12th November 2020, 18:44
Thank you for your reply,

Okay but I still don't know how to play these sounds randomly... I know I need these functions: self playLocalSound("music1") , random in the gsc where I want to play the music but how can I make a table with the sounds which was set in the csv file and call it in the playLocalSound with the random function?

maxdamage99
12th November 2020, 19:40
Thank you for your reply,

Okay but I still don't know how to play these sounds randomly... I know I need these functions: self playLocalSound("music1") , random in the gsc where I want to play the music but how can I make a table with the sounds which was set in the csv file and call it in the playLocalSound with the random function?

use


ambientPlay("dr_music"); //example from Voron
//
self playLocalSound("dr_music");


you no need use random()

Toxys
12th November 2020, 19:44
... I talking about random sounds in the whole topic. I don't want to just play one sound... That's why I need to use random() because I will add about 5-6 sounds and want to play randomly from that 5-6 sounds.

IzNoGoD
13th November 2020, 15:27
... I talking about random sounds in the whole topic. I don't want to just play one sound... That's why I need to use random() because I will add about 5-6 sounds and want to play randomly from that 5-6 sounds.

which
is
what
the
sequence
thing
is
for

maxdamage99
13th November 2020, 21:18
... I talking about random sounds in the whole topic. I don't want to just play one sound... That's why I need to use random() because I will add about 5-6 sounds and want to play randomly from that 5-6 sounds.

MEEEEEEEEEEEEEEEN
if you using .csv from voron, need ONLY

use


ambientPlay("dr_music"); //example from Voron
//
self playLocalSound("dr_music");


you no need use random()

pls check in game, test, before write some ok? :)

Toxys
13th November 2020, 22:36
I did check... I added these lines to .csv:



test_music,1,music/music1.mp3,,,,,,,,music,streamed,,,,all_mp,,,,,,lo cal
test_music,2,music/music2.mp3,,,,,,,,music,streamed,,,,all_mp,,,,,,lo cal

Added music1.mp3 and music2.mp3 to sound/music folder

In sd.gsc added this into spawnPlayer():


spawnPlayer()
{
...
self playLocalSound("test_music");
...
}

but doesn't work.

IzNoGoD
15th November 2020, 07:31
but doesn't work.

please refer to my signature.

WHAT does not work? Did your pc explode? Did you not hear any sound? Did it not play randomized? Did it only start another, randomized, song after respawn? Is it not looping?

Seriously, you're bringing your car to the mechanic and are like "its not working optimally" and expect him to guess that you dont like the color.

Toxys
15th November 2020, 10:11
I didn't hear any sound...

IzNoGoD
15th November 2020, 11:05
Have you checked whether the playlocalsound script is actually being called?

Toxys
15th November 2020, 12:28
Ummm , I added the playlocalsound in sd.gsc into spawnPlayer() function so that's must being called when player spawned... after the playlocalsound I wrote iprintlnBold("Music playing") and that's working ... but I didn't hear any sound.

pollo
16th November 2020, 00:45
Could be some things:
- Soundalias pointing to a non-existing sound in "sounds" folder -> check the "file" column points to the right file (also, in console you should see an error like "Couldn't find sound xxxxx.mp3"
- Sound being overlapped by another sound which is also played in the same channel (eg. if you play music on the local channel and then shoot your weapon, it might kill the previous sound)-> try using another channel, I'd say "auto".
- Problem with the sound itself: I had trouble months ago with some sounds, apparently it happened because they were being played at 48Khz and in stereo channel; changing the frequency to 44KHz, forcing them to be mono, and making sure they are at least 4 seconds-length (you can generate silence), with the help of an audio editing program (eg. Audacity) fixed it. Just check out how sounds from other mods (or stock ones) are, and edit yours like them.

maxdamage99
16th November 2020, 12:36
Ummm , I added the playlocalsound in sd.gsc into spawnPlayer() function so that's must being called when player spawned... after the playlocalsound I wrote iprintlnBold("Music playing") and that's working ... but I didn't hear any sound.

1. attach playing sound on other event
2. test other sounds
3. try self playSound() before it's be working

vanfreddy
17th November 2020, 03:38
make sure your folder structure is correct, with the examples posted here your folders should look like this:
modfoldername(preffered) or main / sound / music / soundfile.xxx
and offcourse the csv in the soundaliases folder with the header too

here is a snippet of my file if it looks like this and is placed like described it should work ("my folder name here is fmj")

name,sequence,file,vol_min,vol_max,vol_mod,pitch_m in,pitch_max,dist_min,dist_max,channel,type,probab ility,loop,masterslave,loadspec,subtitle,compressi on,secondaryaliasname,volumefalloffcurve,startdela y,speakermap,reverb,lfe percentage

deathx,1,fmj/death01.mp3,1,1,,,,1000000,,auto,streamed
deathx,2,fmj/death02.mp3,1,1,,,,1000000,,auto,streamed
deathx,3,fmj/death03.mp3,1,1,,,,1000000,,auto,streamed
deathx,4,fmj/death04.mp3,1,1,,,,1000000,,auto,streamed
deathx,5,fmj/death05.mp3,1,1,,,,1000000,,auto,streamed
deathx,6,fmj/death06.mp3,1,1,,,,1000000,,auto,streamed
deathx,7,fmj/death07.mp3,1,1,,,,1000000,,auto,streamed
deathx,8,fmj/death08.mp3,1,1,,,,1000000,,auto,streamed
deathx,9,fmj/death09.mp3,1,1,,,,1000000,,auto,streamed

maxdamage99
17th November 2020, 13:06
:)

Prawy
23rd November 2020, 07:54
just do randomint maybe?