I don't know if this is the right place to post, since this is an application thread, but I'd like to share what I found out about adding custom music to maps.
The music field in the .info file seems to be broken. (at least I didn't get it to work with 2.502)
Although you can still use some SCAR coding to get custom music.
First of all, you need a .bsc and a .smf file with your custom music. You can easily create this files with Mannerheims SMF converter which can be downloaded
here.
It only converts .wav files, so you have to convert them first into that format, in case you have a .mp3 or something else as a source.
Then save the .bsc file to sound/music/mycustommusic.bsc relatively to your data folder and the .smf file to sound/wav/music/mycustommusic.smf (also relatively to your data folder).
Example: If you created your map in WW2/Data/scenarios/mp/mycustommap.sgb, your file paths would be WW2/Data/sound/music/mycustommusic.
bsc and WW2/Data/sound/
wav/music/mycustommusic.
smfTo get the music ingame you'll have to create a mycustommap.scar file and use this SCAR code:
import("ScarUtil.scar")
import("wcutil.scar") -- this seems to be neccessary, because maps with SCAR code do not end properly since 2.502
function OnInit()
g_CheckAnnihilate = true -- this seems to be neccessary, because maps with SCAR code do not end properly
Sound_PreCacheSound("sound/music/mycustommusic") --("path of the .bsc file relative to data folder" without the file ending)
Rule_AddOneShot(PlayMusic, 0)
end
Scar_AddInit(OnInit)
function PlayMusic()
Util_PlayMusic("sound/music/mycustommusic", 0, 0) --("path of the .bsc file relative to data folder", fade in, delay)
end
One problem with this method is, that the music is not treated as "game music" (which can be adjusted through the music volume slider under the options menu). So the music can't be turned off manually.
Moreover, since the new patch all multiplayer maps play a default music (defined in the WW2Data archive under the path data/scenarios/mp/ambientaudiodefaultpresets.scar). (Maybe that's why the music field in the .info file doesn't work any more)
So you will need to change that, too. Otherwise you will hear both music files playing at the same time.
AmbientAudio=
{
-- sample default audio file, uncomment the following lines or replace with the right defaults
"ambiences/ambiences_streamed/cxp2/GenericAmbiences/BackGrounds/Wind/Layers/generic_wind_rain",
"SpecialFX/RadioFuzz",
"SpecialFX/Tiger_Radio_BG",
"MasterEffects/reverbs/Reverb_Master",
-- "Music/genericmissionmusic_CXP", -- comment this line out to prevent the default music from being played
}
Just save the changed ambientaudiodefaultpresets.scar where your mapfiles are (data/scenarios/mp/) to fix this.
I guess you could also change the default file path to your custom music file path, but that would result in all multiplayermaps playing the same custom music.
One last thing I noticed was, that the custom music might stop playing, if too many other sounds are playing. It happened on my custom map when a heavy artillerybarrage hit the town.
So all in all this is more like a workaround than a real solution, but maybe someone can work out why the "custom music" is not "game music" but something like a long "custom sound".
Cheers