Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /storage/content/49/145849/famitracker.com/public_html/forum/classes/dbHandler.php on line 29 FamiTracker
Login:
Menu:
Post: Author:
FamiTracker > General > Source and development > What as impact on size of song Owner: banshaku New post
Page 1 of 1 Sort:  
What as impact on size of song Posted: 2009-07-14 05:16 Reply | Quote
banshaku

Avatar

Member for: 5010 days
Location: Japan
Status: Offline

#3307
Argg.. I lost my message because of a timeout.. It was a long one. I have to rewrite again..

Since I will use the song in a nes project and in some case I cannot just put all songs together since it could become too big and cannot bank switch it, I need to know a few overview detail about the format.

First, I modified the driver so it can point to a collection of song. I need to know when it does make sense to put then together and when it doesn't.

About size, I would like a little bit more details about each part. Sequenses seems to be variable size, maybe 1 byte per MML entry. As for instrument, they seems to be 10 bytes each.

For the patterns of each song, I'm not sure what affect the size. For example, more effects row should make them bigger. Smaller frames (32 instead of 64) should make the song smaller if a lot of repetitive patterns are used.

When you add the 3 together, the size is smaller then the resulting bin file. I would like to know what is left, I guess init data? Is that size variable? Why I need to know is if I save all music in single file only, in the end it could become bigger because of that data. So I have to be careful for that aspect and know when to group them together or not.

Sorry for the lengthy message. I do believe (I seems to be the only one thought) that the driver can be use in a game and want to make sure how to best make use of it.

If I can re-use some of the code or adapt if for the sound fx engine, I will be more than happy to share it but I guess because of time constraints and because I don't really know the driver well, I may have to make them separately. I would prefer that they be together thought since it make more sense.

Thanks for any information on the subject.



Posted: 2009-07-15 21:11 Reply | Quote
jsr
Administrator

Avatar

Member for: 5924 days
Location: Sweden
Status: Offline

#3315
I don't have this documented clearly, but as I remember:

Instruments: In the latest version it depends on the settings activated. It's 1 byte + 2 bytes for each setting.

Sequences is 1 byte/entry and 2 bytes for length and loop. Lots of space can probably be earned by compressing those, but the best would probably be to use a completely different system (to decrease both RAM and ROM usage). Something like nerdtrackers way of defining instruments? (That would involve some work, but I've been putting some effort in modularization of the tracker so it is possible.)

Patterns has some optimization, and works like this: notes takes one bytes each, and then it's either followed by 1 byte for the duration, or, a predefined duration setting is used. Predefined durations is activated if many notes in following rows have the same duration (the same amout of empty rows between the notes). Volume changes takes 1 byte each, instrument changes are 1 byte for instruments < 15 and 2 bytes above. (So if you change instrument often keep those below 15). Effects each takes 2 bytes (1 for type and 1 for parameter). Adding more columns doesn't automatically generate bigger files.

I'm open for suggestions on this. I'm gonna try the 4 bit note + 4 bit duration format and see if it's better. There's also a (unfinished) routine to compress repeating parts in patterns, but the results depends much on the song and it also fails sometimes for some reason.

Then there's the frame (order) list. Each channel takes 2 bytes, or (I think) 4 bytes if bankswitching is enabled.

I believe these was the most important parts, but there's also some other information stored, mostly lookup tables. And there's of course room for optimization, both CPU and RAM/ROM wise. The files created now assumes that all features can be used, but everything that's not can be removed from the player and exporter.

And speaking of sound effects, I've actually been working on some support for it now. It's not finished yet, but the idea is to use the instruments as effects. It works by defining a table that specifies the instrument, channel, note number and duration for each effect, then it can interrupt the channel automatically and play when triggered. I got the idea from this song: http://2a03.free.fr/dl.php?file=2007, and I believe it's gonna work well.

_______________________
Programmer and developer
Posted: 2009-07-16 06:19 Reply | Quote
banshaku

Avatar

Member for: 5010 days
Location: Japan
Status: Offline

#3320
Damn, I lost my message again. grr.. It was so detailed. I will have to write it over gain. I will see if I can remember everything.

Thanks for the comment about the data.

I will just write the big lines of what I wrote just before. Here's my comment if you intent to make it more game friendly.

Make sure the song data address is not static and you can define the address in a variable. In a game, you cannot let the music engine do the bank switching and have to do everything manually. This is always the first thing I modify in the engine. It has no impact on a nsf, just a few extra line of code at the beginning to set the address.

For the removing effects at compile time, this is a good thing. Don't put any validation code for removed effects, just do nothing in that case. It's the programmer responsibility to set the right flags when compiling and to his job to figure out what when wrong when it set by accident the wrong flag.

Regarding the soundfx, this is an interesting idea and let me chip in some extra details at the same time.

Sound fx cannot be an instrument 100% per se since you have to define the priority of it. For example, if you take megaman 9, the magma column as higher priority than a gun shot. If it didn't, just a single gun shot would stop that sound, which is wrong.

Another thing, hard to make but it would be useful if the data for them can be defined at another place than the current song data. I cannot put all songs together since the size would be too big and have to separate them so I can bank switch the song or song groups when required. If they have to be with the main playing song then this mean that I have to duplicate them. That could be a compromise in some case.

If you go forward with the sound fx idea, make sure that most sound fx can be reproduced. Still keep the option of allowing to deactivate a channel when a sound fx cannot be done directly in FT.

If you want to talk more about sound fx idea, I will be more than glad to talk about it. Right now I'm using that driver in my projects so I'm more than happy to talk on the subject.


Posted: 2009-07-18 02:43 Reply | Quote
jsr
Administrator

Avatar

Member for: 5924 days
Location: Sweden
Status: Offline

#3330
The priority can easily be handled as an extra column (or bit) in the effect table, or as an parameter when playing the effect. The possibility to turn off effects will still be present. I'll keep working on it and see how it turns out.

Regarding song data address, it's supposed be easy to have multiple song data blocks. The address can be changed by moving the label ft_music_addr to RAM, and there store the address to music data before calling init.
One other thing that would be useful is to go back to exporting music data as text files instead of just a binary block. That would make it easy to customize bankswitching.

_______________________
Programmer and developer
Posted: 2009-07-18 04:22 Reply | Quote
banshaku

Avatar

Member for: 5010 days
Location: Japan
Status: Offline

#3331
[quote=jsr]The priority can easily be handled as an extra column (or bit) in the effect table, or as an parameter when playing the effect. The possibility to turn off effects will still be present. I'll keep working on it and see how it turns out.[/quote]

Just one bit is not enough. 16 values or more is important to define the priorities of FX between them. Maybe that column hack with a value in it is a good idea actually. Or an effect like ?0F (? representing the letter/number you decide to assign to it) could maybe do the trick?

[quote=jsr]Regarding song data address, it's supposed be easy to have multiple song data blocks. The address can be changed by moving the label ft_music_addr to RAM, and there store the address to music data before calling init. [/quote]

This is exactly what I'm doing at the moment. I have a LUT of song data block and load the right one before the init in the var I defined in the driver.

[quote=jsr]One other thing that would be useful is to go back to exporting music data as text files instead of just a binary block. That would make it easy to customize bankswitching.[/quote]

Maybe, it depends. If you can modify the content inside manually then it has some value. Right now, I import binary blocks in the right bank and the linker does the rest.

RE: What as impact on size of song Posted: 2009-07-18 18:58 Reply | Quote
Dafydd

Avatar

Member for: 5304 days
Location: Uppsala, Sweden
Status: Offline

#3341
[quote=banshaku]Argg.. I lost my message because of a timeout.. It was a long one. I have to rewrite again..[/quote]

Christmas comes early this year.

[url=]https://addons.mozilla.org/sv-SE/firefox/addon/6984

RE: What as impact on size of song Posted: 2010-07-13 23:51 Reply | Quote
xolroc

Avatar

Member for: 4373 days
Location: Here
Status: Offline

#7245
And what if he uses Chrome?

_______________________
If there is evil in this world, it lurks in the hearts of man.
--Trinicus D. Morrison

The Final Fantasy IX 8-bit project: 3 complete
http://famitracker.shoodot.net/forum/posts.php?id=1624
RE: What as impact on size of song Posted: 2010-07-14 05:04 Reply | Quote
retrotails

Avatar

Member for: 4581 days
Status: Offline

#7264
[quote=xolroc]And what if he uses Chrome?[/quote]
You should have waited a few days to make it a full year bump...

RE: What as impact on size of song Posted: 2010-07-14 05:06 Reply | Quote
xolroc

Avatar

Member for: 4373 days
Location: Here
Status: Offline

#7266
Um, oops.

_______________________
If there is evil in this world, it lurks in the hearts of man.
--Trinicus D. Morrison

The Final Fantasy IX 8-bit project: 3 complete
http://famitracker.shoodot.net/forum/posts.php?id=1624
Page 1 of 1 Sort: