Banner
Views: 896,121,363
Time:
5 users online: cyphermur9t, LadiesMan217,  MarioFanGamer, Metalis, Wolfguy423 - Guests: 46 - Bots: 182 Users: 50,269 (2,282 active)
Latest: BooTheBun
Tip: Doors and pipes act strange near screen boundaries. See this to avoid strange issues.
Not logged in.
Rests in loops
Forum Index - SMW Hacking - SMW Hacking Help - Custom Music - Rests in loops
Pages: « 1 » Link
I've often seen that some people put a single rest in a loop, so for example [r1]16 instead of r1^1^1^1^1^1^1^1^1^1^1^1^1^1^1^1^1

However, I've read several times that you shouldn't put extremely short sequences of notes or just a single note in a loop, because that increases the insert size.
Doesn't that apply to a single rest?
You’re right, it does. r^1^1… has a smaller insert size than [r1]16.
The issue isn't short sequences or single notes per se but rather that loops themselves take up some space as well. Each loop command takes up in total four bytes in addition to the note data—label loops take one byte for the command and three for the parameters (loop point, loop count) and superloops take one paramter but need to be placed twice.
Each note (including rest and ties) take two bytes, one for the note data itself and one for the length.

As a result, [[r2]]2 is actually less optimised than r2^2 because the former takes 2 + 2 + 2 bytes (four for label loop and two for the rest) while the latter takes only 2 + 2 (four for both rests).
Once again, this only applies for very short sequences. Three loops is the general minimum loop count where it makes sense to use them regardless of the loop's sequence and chances are, two are already sufficient. In general, you shouldn't even really care for this issue unless you see very short pattern repeated only two, at most three times.

(There are some complications regarding loops in N-SPC —and as such AMK— but I leaved the details out because these get a bit complicated and I don't know them enough anyway.)

--------------------
Okay, my layout looks ugly.
Just to nitpick for accuracy, I will point out that normal loops take 5 bytes: 4 for the command, 1 for the null-byte that terminates the loop's data; thus just the first loop is 5 bytes, calling an already-defined loop's label is still 4 bytes. This is why it's recommended to use superloops over loops always, unless you need the loop specifically for reuseability.

One reason why you would (and should) want to use short rests in a loop:
Consider having a song that's 16 whole notes long, which uses only 5 channels, and one of the used channels has 8 whole notes of rest in the middle. If you do r1^1^1^1^1^1^1^1 once and r1^1^1^1^1^1^1^1^1^1^1^1^1^1^1^1 thrice, that's 18+34+34+34 = 120 bytes. Yikes! Instead, if you use (somelabel)[r2]16 once and (somelabel)32 thrice, that's 8+4+4+4 = 20 bytes. Yowzers!

Note that I use r2 instead of r1 to save a further byte; if you have multiple instances of needing more than 255 repeated r2 you could use r1 instead.
Pages: « 1 » Link
Forum Index - SMW Hacking - SMW Hacking Help - Custom Music - Rests in loops

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2021 - SMW Central
Legal Information - Privacy Policy - Link To Us


Menu

Follow Us On

  • YouTube
  • Twitch
  • Twitter

Affiliates

  • Super Mario Bros. X Community
  • ROMhacking.net
  • Mario Fan Games Galaxy
  • sm64romhacks