adding music to a campaign

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

adding music to a campaign

Post by Helmet »

My campaign is almost done, so I need to select music. Not being a musical person, I'd appreciate some help with this part. Right now I'm using the {DEFAULT_MUSIC_PLAYLIST}, which is awesome music. But I'd like to customize the music anyway with some other awesome music that the player might not have heard as much.

Can music be changed within the middle of a scenario, to highlight when something significant happens? Like...when a map is swapped with another map? How? Just drop a music macro wherever?

Any recommendations of music for these events?
  • Music for the animated title (30 seconds), followed by the player choosing their team color.
  • Music for cut-scenes where characters talk. (There are several long-ish conversations.)
  • Music for battles against nagas.
  • Music for battles against chaotic humans.
  • Music for battles against saurians.
  • Music for battles against drakes.
  • Music for a short, scary cut-scene.
  • Ominous music for a battle in a cave against a horrifying monster.
  • Defeat music when the player loses.
  • Victory music when the player beats a scenario.
  • Victory music when the player beats the campaign.
  • Music for when the happy characters exit a mountain in the early morning light.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: adding music to a campaign

Post by Pentarctagon »

You can change the music during any event with append=no probably along with immediate=yes (from here).
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: adding music to a campaign

Post by Helmet »

Pentarctagon wrote: December 18th, 2020, 7:28 pm You can change the music during any event with append=no probably along with immediate=yes (from here).
Thanks, Pentarctagon. I just read the wiki, and evidently the append=no is the default, so any new music is immediately started.

Wow, this doesn't seem as hard as I thought it would be (so far.)

Pentarctagon, on the add-on server, I recall that you had added a lot of music files. If I wanted to use one, do I download it and put it in my add-ons music folder? Is it that easy?

This is what I did...

Code: Select all

		{FADE_TO_BLACK} 		
		[music]
			journeys_end.ogg
			immediate=yes
		[/music]
		[replace_map]
			map_file=5_exit.map    
		[/replace_map]	
		{FADE_IN}
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: adding music to a campaign

Post by Pentarctagon »

You would need to add the music pack add-on's [binary_path] to your add-on's _main.cfg, then after that using it is the same as using mainline music. You'd also want to add the music pack add-on as a dependency in your _server.pbl.

Alternatively, you could take just the tracks you want, put them directly in your add-on, and then just use them that way.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: adding music to a campaign

Post by Helmet »

Pentarctagon wrote: December 18th, 2020, 10:26 pm You would need to add the music pack add-on's [binary_path] to your add-on's _main.cfg, then after that using it is the same as using mainline music. You'd also want to add the music pack add-on as a dependency in your _server.pbl.

Alternatively, you could take just the tracks you want, put them directly in your add-on, and then just use them that way.
Okay, thanks.

I have one more problem. Audacity assumes I want to edit every Wesnoth track it plays. I can't figure out how to add the tracks to Amazon Music, where I listen to streaming radio. My Quicktime Player refuses to play ogg. And I can't find where the tracks went on iTunes, which keeps trying to sell me popular albums.

Can you recommend a music-app-thing to play my Wesnoth music? Or is there already a website with a playlist of Wesnoth music that I can access through a browser?
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: adding music to a campaign

Post by WhiteWolf »

VLC plays ogg just fine.

Two comments: you're missing name= before journeys_end.ogg in your code.
Also, play_once=yes may be arguably better for this than immediate=yes, because... well, it does what it says: it plays the track once, then the scenario returns to its playlist that is left unchanged. So play_once=yes may be a better option to immediately play a track to highlight a scene or something.

As for recommendations, I have some additional defeat and victory tracks from another GPL source I don't even remember, but I can add it as an attachment if I find it.
EDIT: found it.
music.zip
(330.55 KiB) Downloaded 139 times
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: adding music to a campaign

Post by Helmet »

WhiteWolf wrote: December 18th, 2020, 10:53 pm VLC plays ogg just fine.
I just tried VLC. It works well except for one thing. Before some tracks play, VLC makes a loud sound, like a pop in a microphone, for a fraction of a second. I checked the tracks in Audacity and there are no defects in the track, so it must be VLC. Not every track makes the sound, and no track does it every time. It's pretty odd behavior. I'm using the Mac version, so maybe this is a Mac problem.
WhiteWolf wrote: December 18th, 2020, 10:53 pm Two comments: you're missing name= before journeys_end.ogg in your code.
Thanks for noticing that. I had to comb through my code and fix the missing name= in several places. I was making the same mistake everywhere.
WhiteWolf wrote: December 18th, 2020, 10:53 pm Also, play_once=yes may be arguably better for this than immediate=yes, because... well, it does what it says: it plays the track once, then the scenario returns to its playlist that is left unchanged. So play_once=yes may be a better option to immediately play a track to highlight a scene or something.
That sounds exactly like the way I want the music to work, so I implemented that change. Thanks.
WhiteWolf wrote: December 18th, 2020, 10:53 pm As for recommendations, I have some additional defeat and victory tracks from another GPL source I don't even remember, but I can add it as an attachment if I find it.
EDIT: found it.
music.zip
Nice tracks, short but emotionally effective. Thanks. Picking music is more fun than I expected.

EDIT: I found a free, open-source media player for Mac called IINA. It works well and makes playlists.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Celtic_Minstrel
Developer
Posts: 2222
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: adding music to a campaign

Post by Celtic_Minstrel »

If you want to add the track to iTunes or some other music library system that doesn't support ogg, I'd suggest using ffmpeg to convert it to another format that it does support. Although VLC can also do this conversion, its conversion facilities are confusing and sometimes buggy and error-prone, so I'd definitely recommend ffmpeg instead (probably via some GUI wrapper - the core ffmpeg program is just a command-line tool).

But if all you want to do is listen to them, then what you've found is surely good enough.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: adding music to a campaign

Post by Helmet »

At the complete ending of my campaign, I use [fire_event] to do several things to fashion a more enjoyable conclusion. One of the things that happens is the playing of a music track.

Unfortunately, the default victory music which is eventually played by [endlevel] clashes with my final track.

I tried replacing it with silence.ogg, but that is only slightly less jarring.

Is there a way to allow my track to keep playing, even after the victory window appears and the game ends?

Code: Select all

		[fire_event]
			name=closing # 				see SotA for usage
		[/fire_event]
					
		[endlevel]
			music=silence.ogg # 				10 seconds of silence, mainline
			result=victory
		[/endlevel]
	[/event]
I guess I could have the music track start over. But it might sound like somebody bumped the record player.

One more question. Is there a way to turn music off during an event and then turn it back on? Like a pause button? I want silence for a particular scene, but I don't know how long the scene might last (message tags), so I can't simply play 10 seconds of silence.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: adding music to a campaign

Post by Pentarctagon »

It won't pause, but you could use [volume] to silence the current music/sound.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: adding music to a campaign

Post by Helmet »

Pentarctagon wrote: December 27th, 2020, 7:01 pm It won't pause, but you could use [volume] to silence the current music/sound.
Volume is better than pause, thanks. A creative usage of volume even solved my original problem.

Has anybody written some code I could borrow to gradually turn down the volume? Otherwise I'll use the code below. It works, but I hear the steps as the volume is turned down in chunks.

Code: Select all

		[volume]
			music=80
		[/volume]
		
		{DELAY 500}

		[volume]
			music=60
		[/volume]
		
		{DELAY 500}

		[volume]
			music=40
		[/volume]
		
		{DELAY 500}

		[volume]
			music=20
		[/volume]
		
		{DELAY 500}
		
		[volume]
			music=00
		[/volume]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: adding music to a campaign

Post by Helmet »

After I turn the volume down, turning it back to 100 does not return the volume to the previous level. It's quieter.

What do I need to do to make it return to the previous level? I thought 100 was the volume set by the player in Preferences.
Wiki
Values can go from 0 to 100.
Thanks.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: adding music to a campaign

Post by Pentarctagon »

You could try wesnoth.music_list.volume from here. They should be the same thing though.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: adding music to a campaign

Post by Helmet »

Pentarctagon wrote: December 27th, 2020, 11:26 pm You could try wesnoth.music_list.volume from here. They should be the same thing though.
I've never done a thing with Lua before. I might give it a try, though.

I wonder if lowering the volume several times in a row actually lowered the player's Preference for volume somehow. That's what it seems to be doing. But I'm not sure.

Thanks for the link.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: adding music to a campaign

Post by WhiteWolf »

To your other question in:
Helmet wrote: December 27th, 2020, 6:38 pm Unfortunately, the default victory music which is eventually played by [endlevel] clashes with my final track.

I tried replacing it with silence.ogg, but that is only slightly less jarring.

Is there a way to allow my track to keep playing, even after the victory window appears and the game ends?
I think the only way to do that is to set

Code: Select all

[endlevel]
    carryover_report=no
[/endlevel]
in your code. This does just exactly what you want - when the level ends, the screen is just greyed out, and your currently played track won't be interrupted, it will just keep playing like nothing happened.
Keep in mind - you're actually not showing the player their carryover report. Get ready for the dozens of "bug reports" that "hey I'm not getting my carryover report at the end of level X and that's a mean move because player needs to see that!!". :lol:
To prevent that, you might also want to set linger_mode=no, which will just immediately end the level, no lingering grey map thing. Experiment and see which combination works best for you, but to disable the "victory music", carryover_report must be set to no.

To the other subject - according to the wiki, [volume]'s value is the percentage multiplier of the settings-value, so I haven't a clue about what's wrong.
The lua equivalent of your volume setting code is just:

Code: Select all

# place this where you would place [volume]
[lua]
    code=<<
wesnoth.music_list.volume = 10 
    >>
[/lua]
I tried setting it to 10 and back to 100 with this, and it seems to work, I get back to the same loudness level.

EDIT it also works with your inital step-by-step decrease variant:

Code: Select all

[lua]
    code=<<
wesnoth.music_list.volume = 80
wesnoth.delay(500)
wesnoth.music_list.volume = 60
wesnoth.delay(500)
wesnoth.music_list.volume = 40
wesnoth.delay(500)
wesnoth.music_list.volume = 20
wesnoth.delay(500)
wesnoth.music_list.volume = 0
    >>
[/lua]
For me it got back the original loudness level just fine after setting it back to 100 at a later point.
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Post Reply