New .nbs format is missing data, which prevents external programs from reading the file properly #67
Labels
C: Bug
Something isn't working
S: Resolved in next release
This bugfix or suggestion has been applied to the code
While updating a Python library that deals with NBS files, I found a few issues with the current format, which goes from removal of vital data from the file, to a few mistakes in the current documentation.
The screenshot below is an NBS file opened in a hex editor, where I highlighted some pertinent info:
Removal of layer count breaks external programs
The song length and layer count are no longer stored because, according to this, they are not used anywhere in the program. Though, the reason why it used to save that info was so that programs reading the NBS file can know where to stop reading the layer data, and start reading the custom instrument data (if present). This is shown in the original NBS format specification, as well as the new one, despite the format itself not showing any signs of it:
The removal of this data prevents external programs from reading the file properly. For example, in pynbs, a Python module I used to work with a lot, the number of layers, which is obtained from the header prior to reading the layer data, is passed as a parameter to the function that reads the actual layers, so the program knows how many layers it should look for. Without that info, the program isn't able to tell where the layer data stops and the instrument data starts, which prevents it from reading the file properly.
So, even though the layer count may not actually be used in the program itself, it's vital for external programs reading the files.
Unnecessary removal of song length in the file format
In a similar fashion, the song length, which was a very handy value to have, is no longer stored in the file. Basically everything you could ever want to do with a NBS file involves the song length in some way, and although it's still possible to calculate it while iterating over the notes, it has become unnecessarily complicated. Since the program already keeps track of that value, it's just a matter of writing it to the file.
I'm aware that, as of issue #18, the bytes which used to store the song length are now 0 as a way to determine if the file was saved in the new format. Though, since there's already a way to detect it, I see no problem in adding it back somewhere further down the header.
(It's a bit incoherent for the file to store cosmetic stuff such as the number of right-clicks, but NOT the song length, don't ya think? :P)
Missing info on documentation:
endnb2
short in the headerAfter the vanilla instrument count, and before the integer that stores the length of the title string, there are two bytes being written which are not shown in the documentation. These come from a short that's referred to as
endnb2
in the code (fromscripts/save_song/save_song.gml
). What is that doing?'Note blocks removed'
Looking at the code, 'Note blocks removed' still seems to be saved, though it's absent from the documentation.
How the actual note blocks are stored
From what I've seen there were no changes in the way note blocks are stored; though, it's not shown on the new documentation.
The text was updated successfully, but these errors were encountered: