Making one big .IT file with several songs

Started by Reenen, January 26, 2007, 06:19:39

Previous topic - Next topic

Reenen

Hi

In my discussion on this topic.  LPChip gave me a possible solution of my problem (duplicating instruments in several .it files).

The solution basically creating one BIG file with all the music in it, seperated by --- patterns.

Now how, from a programming point of view, would you skip to certain songs?  I'm very interested in this solution, and would like generally to know more on how it would be done.

CrazyAznGamer

Most programming APIs offer methods to manipulate the song's position, allowing one to jump around the song. I know FMOD definitely does this.

A lot of engines include scripting controls to use these API's position skipping methods et. al. I would suggest constructing a system where you connect certain keys to certain positions in order to make distinguishing the song in code easier.

The end result is it's a bit more work and that's magnified as one tries to write maintainable code, but it is nevertheless fairly easy to code.

LPChip

First, make sure that the .IT file is properly constructed.

This means that the last pattern of each (sub)song has a Bxx command which means: jump to order xx.

This way, playing from a position inside the song will guarantee that only that part of the song is being played. If you make those looped, then its even better (but not required ofcource)

In your program, you need to start playing and then jump to order to change song.

---- [ EXAMPLE ] -----------------------------
Lets say your orderlist looks like this:

00 01 02 03 -- 04 05 06 07 -- 08 09 10 11

3 songs of each 4 patterns.

Lets say you start the main menu on pattern 04, which is the first you will hear when fireing up the game. What you'll need to do is start the song and immediatelly jump to the right order.

Since order 4 has --, you need to take order 5 to start playing from pattern 04.

In pattern 07 you'll have a b05 command on the last row which will loop your song back to pattern 04 without you worrying about it in the code.

You can use this trick on all (sub) songs to get the result you're after.

I can't tell you how to program this, but no doubt there's a function that jumps to an order of choise.
"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs

Reenen

Must the patterns follow so "closely" to each other?

I was thinking of starting song 1 on pattern 0, and song 2 at say, 500, and so on... Just incase someone adds some length to a song, and then I might be in trouble...

LPChip

Quote from: "Reenen"Must the patterns follow so "closely" to each other?

I was thinking of starting song 1 on pattern 0, and song 2 at say, 500, and so on... Just incase someone adds some length to a song, and then I might be in trouble...

There are only 239 orders for .IT files, so good luck with that :P But indeed, you can simply keep many [--] 's in between, and you can always insert a pattern in between too, so its not necessary to keep the space reserved. Only know that if you indeed change the space, you'll need to edit the last patterns and change the Bxx aswell as the game.

Therefor, it might be best to not set the looppoints until the songs has been finished.
"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs

residentgrey

hey how go you put those -- thingies in the pattern list in mpt anyway, +++ for that matter?
No two people are not on fire...AWWW!

Web and Graphic Design just for you!
I r GhostMech on there, forever scouting.

LPChip

You can drag a [--] pattern to the left to insert one of those, and you can use num+ and num- to change its number. If you get past the last item, it will show a [++] pattern, and if you + another time, it will show [--]. You can also enter pattern 0, then press - twice (which is what I usually do)

I want to add another tip for this topic.

If you don't want to touch your code ever again, you can begin your song with pattern orders so you can direct your code to a fixed order which will then change the order to the right one.

That means that if you play order 0, you always play song 0, if you play order 4, you always play song 4.

Make several unique empty patterns at the beginning of the song. In each add a Bxx command that will jump to the 1st pattern of that sequence.

This allows you to make song packs where each song pack uses a predefined layout in the song, usefull for any type of game situation.

Eg. You can have it so that you have one beginning tune for a level, several variations dependend on an item you carry and a win and loose song. You can then say: song 0 is always beginning, song 1 is always ending, 2 to 8 are variations.

Keeping all songs identical on the first 8 patterns allows you just link a filename to a level and your script can handle the rest. :)
"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs

Reenen

If I understand you correctly... Basically have a the first X patterns of you file an "Index"... so 1 would start song 1, 2 would start song 2 and so on.

And then start your first song on pattern 50 or so...

Sounds like a great idea.

The code can then just say "Play(2)" to play song 2.

Or better "Play(Greensleeves)", and in another piece of code have
"Const Greensleeves = 2".

LPChip

"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs

Reenen

Can I jump to patterns more than 255?  Ie. FF

Because I have a feeling I might need it...

LPChip

Quote from: "Reenen"Can I jump to patterns more than 255?  Ie. FF

Because I have a feeling I might need it...

No you can't.

In OpenMPT, you can, but those commands are not being understood outside OpenMPT.

But I believe there's a limit of 239 orders.

You can always make 2 songs even though they have the same samples. Sometimes thats your only option, but I find it strange how you require so many orders per song, cus usually a good gamesong has no more than 20 orders, before it loops.
"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs

Reenen

(I thought I'll combine all my previous posts, and then delete them... but apparently you can't delete a post except if it was the last one... can admin do it?)

It may be a big game.

I'll maybe try to have songs with drums in one file and files without in the other. Something like that.

I do think that 2 or maybe 3 songs may be enough.

Also, at the moment I opened 50 patterns for "index", and I doubt there'll be 50 songs.

One can also increase the SIZE of the pattern. But that will be a lot of effort with the current way the copy and pasting works. But should be do-able.


Also... the game can directly jump to a pattern...

So maybe I should keep my "index" external (like a text file), and let the program worry about jumping to the right spot.

Can I then jump past 255? Well you'll not know would you... Smile


2 last things...  the [---] pattern seems to cut off my other patterns (or it just does funny things with the scroll bar).  What does the [+++] pattern mean?

LPChip

[--] is an empty place in the pattern and most players see that as the end of a song.

[++] is just a space filler. Any player that finds one will skip it and move directly to the next order.
"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs

Relabsoluness

Quote from: "LPChip"But I believe there's a limit of 239 orders.
The order/pattern limit in MPTm-format in the latest test builds have tentatively been set to 65000 - this should do for a while :)

LPChip

Quote from: "Relabsoluness"
Quote from: "LPChip"But I believe there's a limit of 239 orders.
The order/pattern limit in MPTm-format in the latest test builds have tentatively been set to 65000 - this should do for a while :)

Yes, but normal .IT players cannot understand this, now can they? Reenen wants to use this for his game.
"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs