[TUTORIAL] Adding background music

Mods, guides how to use and install mods go right in here.
Post Reply
User avatar
Darkness1000
Posts: 12
Joined: 04 Mar 2012, 00:39

Post » 08 Mar 2012, 03:34

I thought this might be useful, rather than just leaving the instructions in a PM.

1. Insert whatever.ogg (in this case preciousmoon.ogg)
2. In main.lua, I put this right under princessmusic:

Code: Select all

moonmusic = love.audio.newSource("sounds/preciousmoon.ogg", "stream");moonmusic:setLooping(false)
2A. Then, a bit further down, in musiclist:

Code: Select all

-- musiclist = {overworldmusic, undergroundmusic, castlemusic, underwatermusic, starmusic, moonmusic}
-- musiclistfast = {overworldmusicfast, undergroundmusicfast, castlemusicfast, underwatermusicfast, starmusicfast, moonmusic}
Note the moonmusic at the end of the list. Also, the moonmusic is in both because it needs to play during low time too. The fast version would normally go in musiclistfast.
3. Then in musicloader.lua, I add this line after princessmusic:

Code: Select all

"preciousmoon",
What we're doing here is putting the music's filename, not it's nickname.
4. Finally, in editor.lua:

Code: Select all

guielements["musicdropdown"] = guielement:new("dropdown", 17, 110, 11, changemusic, musici, "none", "overworld", "underground", "castle", "underwater", "star", "moon")
The nickname without the "music" ending is here for the dropdown list in the music chooser in the level editor.

That's pretty much it!

DarkEdit: Still works for 1.4
Last edited by Darkness1000 on 09 Mar 2012, 01:21, edited 1 time in total.

User avatar
EntranceJew
Posts: 93
Joined: 05 Mar 2012, 05:37

Post » 08 Mar 2012, 03:44

We should look into making music redistributable with maps like tiles currently are, perhaps by using the music=* and checking if the file exists with the maps.

User avatar
Kjulo
Posts: 43
Joined: 04 Mar 2012, 22:32

Post » 08 Mar 2012, 14:47

Good tutorial, very helpful and kept it simple.

Maurice
Stabyourself.net
Posts: 2145
Joined: 01 Feb 2012, 20:19

Post » 08 Mar 2012, 15:40

Problem with custom music for mappacks is that they would be huge then.

User avatar
Pyrosaur
Posts: 769
Joined: 03 Feb 2012, 00:15
Contact:

Post » 08 Mar 2012, 15:42

Maurice wrote:Problem with custom music for mappacks is that they would be huge then.
Yeah. :/

User avatar
Kjulo
Posts: 43
Joined: 04 Mar 2012, 22:32

Post » 08 Mar 2012, 17:07

Maurice wrote:Problem with custom music for mappacks is that they would be huge then.
It could be optinal.

User avatar
EntranceJew
Posts: 93
Joined: 05 Mar 2012, 05:37

Post » 08 Mar 2012, 17:15

If Mari0 could read from a zip file using existing embeddable Lua libraries from elsewhere it could solve the large mappacks problem while removing the tedium of manually extracting and fixing all the improperly packaged mappacks people seem to be sharing. (Seriously, select all the folder contents and zip them, don't zip the folders.)

User avatar
trosh
Posts: 1594
Joined: 03 Feb 2012, 08:36

Post » 08 Mar 2012, 23:46

btw, be sure to use a proper .ogg file, not just a media file with mp3 audio container or such - the game will crash. You need something like the libvorbis library to properly convert audio to .ogg on Linux.

enemy_killer
Posts: 3
Joined: 04 Mar 2012, 01:12

Post » 10 Mar 2012, 19:52

Thanks to darkness I was able to get it to play the song "Still Alive" upon startup just by adding these two lines of code to the menu.lua file near the top: playsound(bgsa)
soundenabled = true where bgsa is taking the place of his moonmusic

User avatar
ZenX2
Posts: 30
Joined: 07 Mar 2012, 06:23

Post » 11 Mar 2012, 08:55

Just so you know, steps 2 and 2A don't do anything. The code you're changing is commented out.

User avatar
ClipHead
Posts: 2
Joined: 11 Mar 2012, 22:33

Post » 12 Mar 2012, 00:41

Since this is my first post...
Hello everyone!
Thanks for this tutorial.
I love the idea of adding custom music to Mari0 and I know that the files used are *.ogg.
I just started composing songs with FamiTracker and was wondering if it would possible to implement a nsf-file support/player. This would keep the music real (to the 8 bit feel) and the files small.

On the other hand: I'm not a programmer and this could sound silly. So forgive me in advance.

User avatar
trosh
Posts: 1594
Joined: 03 Feb 2012, 08:36

Post » 12 Mar 2012, 00:46

I guess that's not stupid but it would be an unnecessary complication - ogg is a loss of space but it's easier to control I think. Also an .ogg player is built in straight into LOVE, while I think you would have to reprogram an .nsf player. But I see where you're going.

Camewel
Posts: 2996
Joined: 02 Feb 2012, 21:32

Post » 12 Mar 2012, 00:49

Using .nsf files would be really good from a design perspective, but it would mean you'd need to code in support for it by hand, which would be hellish.

User avatar
ClipHead
Posts: 2
Joined: 11 Mar 2012, 22:33

Post » 12 Mar 2012, 01:02

Hey trosh, hey Camewel.

I hoped that it would be "not stupid" and agree that it "would be really good from a design perspective".
But "Unnecessary complication" and "hellish" sounds like: A lot of work to be done. Don't call us...we call you. ;)

So for now on I'll keep converting my files to ogg.

User avatar
trosh
Posts: 1594
Joined: 03 Feb 2012, 08:36

Post » 12 Mar 2012, 01:13

yeah, that's just how LOVE works. People making simple games wouldn't want to get muddled up with trackers and stuff.

Camewel
Posts: 2996
Joined: 02 Feb 2012, 21:32

Post » 12 Mar 2012, 01:15

I'm sure if someone made a .nsf file reader, we would be able to have lovely low file size music and Maurice would add it to the game and everyone would be happy. I'll look into it.

It'll probably go much better than these bloody slopes I've been tooling around with for ages.

Oh I need to stop saying I'll look into things before finding out how hard they really are.

User avatar
trosh
Posts: 1594
Joined: 03 Feb 2012, 08:36

Post » 12 Mar 2012, 01:20

except if you're making a real nsf player and that means a lot of programming to make a correct soundwave controller. I think.

Camewel
Posts: 2996
Joined: 02 Feb 2012, 21:32

Post » 12 Mar 2012, 01:26

Yeah, I was hoping I could approximate that with sound fonts, but I'm not sure.

User avatar
Baf
Posts: 96
Joined: 12 Mar 2012, 11:20

Post » 12 Mar 2012, 11:42

Bonjour tout le monde !

First of all, MariO is an amazing game (Merci Maurice ! Thank you), especially the level editor. It gives me the will to create easily a game by myself, and it's something I always wanted to do. Actually, I never program anything and it was very complicated to understand how to put customs skins and sprites, but now it's okay because it's very simple with the tutorial in that forum.

My problem is : I creates some musics and I really would like to use them to me project. Unfortunatly, after searching during hours (literally), I've never be able to understand how to do that, ending my journey of knowledge with headache. I don't understand anything, I tryed to install some "love_stuff" and other things, but no one on this forum made a tutorial that is understandable to me.

Could some one would be nice by explaining me how to put my musics into this great game, step by step, from the very very beginning ? For example, I don't understand were I'm supposed to insert the "moonmusic" code. Also, sorry being a noob.

Thank you !

User avatar
trosh
Posts: 1594
Joined: 03 Feb 2012, 08:36

Post » 12 Mar 2012, 15:07

Camewel wrote:Yeah, I was hoping I could approximate that with sound fonts, but I'm not sure.
that would be wayyy too heavy

User avatar
xPi
Posts: 28
Joined: 11 Mar 2012, 13:17

Post » 12 Mar 2012, 21:42

someone try .xm .it .mod .s3m music

User avatar
SpocKirk
Posts: 160
Joined: 03 Feb 2012, 02:48

Post » 13 Mar 2012, 00:27

Baf wrote:Bonjour tout le monde !

First of all, MariO is an amazing game (Merci Maurice ! Thank you), especially the level editor. It gives me the will to create easily a game by myself, and it's something I always wanted to do. Actually, I never program anything and it was very complicated to understand how to put customs skins and sprites, but now it's okay because it's very simple with the tutorial in that forum.

My problem is : I creates some musics and I really would like to use them to me project. Unfortunatly, after searching during hours (literally), I've never be able to understand how to do that, ending my journey of knowledge with headache. I don't understand anything, I tryed to install some "love_stuff" and other things, but no one on this forum made a tutorial that is understandable to me.

Could some one would be nice by explaining me how to put my musics into this great game, step by step, from the very very beginning ? For example, I don't understand were I'm supposed to insert the "moonmusic" code. Also, sorry being a noob.

Thank you !
your music file needs to be in .ogg format. The "moonmusic" is just a created name. You could name it anything.

dwarvenbuffet
Posts: 1
Joined: 13 Mar 2012, 03:30

Post » 13 Mar 2012, 03:32

This tutorial is so much win. I added the SMB2 overworld theme.

User avatar
Baf
Posts: 96
Joined: 12 Mar 2012, 11:20

Post » 13 Mar 2012, 14:50

"your music file needs to be in .ogg format. The "moonmusic" is just a created name. You could name it anything."

This part is okay, but what I don't understand is where do I put my anything.ogg file ?

User avatar
SpocKirk
Posts: 160
Joined: 03 Feb 2012, 02:48

Post » 14 Mar 2012, 08:06

Baf wrote:"your music file needs to be in .ogg format. The "moonmusic" is just a created name. You could name it anything."

This part is okay, but what I don't understand is where do I put my anything.ogg file ?
the "sounds" directory inside the mari0 source directory

User avatar
Baf
Posts: 96
Joined: 12 Mar 2012, 11:20

Post » 14 Mar 2012, 09:04

That sounds good, and thank you for helping, but the "sounds" directory inside the mari0 source directory is obviously the stuff I can't find in my computer. Could you tell me where is that "sounds" thing ? Because in the "User/roaming/love/mariO", there only is a mappack file (with texts files, about the game's levels) and the only thing that's working is when I put a tiles.png (for the custom graphics) and an icon.png (for the logo of my mappack).

To my mind (and I might be wrong), by reading some topic in the Modding forum, I understood that I have to install Löve and coding some stuff, but I'm not sure and I wasted four hours trying coding stuff (and I only be abble to coding a short "Hello, I'm a noob" box linked to nothing). I don't know, maybe I have to link a code to the MariO.love icon... Whatever, I might doing it wrong, I hope that the answer is more easy to do than this, but I really don't know what to do with my anything.ogg.

For example, you could tell me : Put your anything.ogg in = User/löve/mariO/etc or whatever. But, the fact is there is no "sounds" files inside the "MariO" files in "User" (and I can see all hidden files). Or... I don't know = download Löve, open it, inser that code, do that, link that to this.

Thank again for being nice and full of patience.

User avatar
xPi
Posts: 28
Joined: 11 Mar 2012, 13:17

Post » 14 Mar 2012, 10:22

install latest build https://love2d.org/builds/

download mari0 source (.love is a .zip)

modify contents of .love to have sound

or extract .love to folder and modify etc

User avatar
Baf
Posts: 96
Joined: 12 Mar 2012, 11:20

Post » 16 Mar 2012, 23:49

Yeah ! Thank you very much !

Now I'm playing with power !

Mari0_Is_Awsome
Posts: 8
Joined: 03 Mar 2012, 19:33

Post » 18 Mar 2012, 23:15

Baf wrote:Yeah ! Thank you very much !

Now I'm playing with power !
SUPER POWER!

User avatar
xPi
Posts: 28
Joined: 11 Mar 2012, 13:17

Post » 19 Mar 2012, 10:46

well I went ahead and tried .xm and .it music as "music.ogg" in a mappack. froze the game :(

this would have been extremely beneficial because the file size for a song can be extremely small!
examples: smb-x.xm, strshine.s3m and uhhhh this... xmplay, vlc media player, winamp and modplug are good players that can play these formats, as well as love2d.

Post Reply