Skip to content

[Feature enhancement] Let's Remove Legacy Baggage: Refactoring Variable Names #152

@sylvia-leaf

Description

@sylvia-leaf

Is your feature enhancement request related to a problem? Please describe.
The variable names are often difficult to understand because of historical limitations and terminology.

For example, it might not be clear what the w in wBank means. Of course it meant WORD but we've replaced it in 4.0.31 with the cross-platform stdint.h fixed-width integer type uint16_t to make it clear that it is two bytes and not something else, as WORD sizes can vary between platforms. Of course the legacy specification defined the widths of these values, but stdint.h types are likely to be more well-recognised by developers that are new to the SoundFont or SFE file formats.

Similarly, all references to DWORD (dw), BYTE (by), SHORT (sh) and CHAR (ch and ach) have been replaced by their stdint.h fixed-width integer equivalents.

Additionally, there is a lot of legacy terminology, for example the instrument and preset "bags," which would benefit from getting a more descriptive name, for example instrument and preset list. Of course we wouldn't replace ibag and pbag in chunk headers because this would break compatibility but we want people to think of them as a list.

Variable names like wInstGenNdx also have very poor readability, because it might be unclear that Ndx is intended to mean "index".

Describe the solution you'd like
This strategy aims to solve the legacy baggage related to terminology in three steps:

  • Remove type prefixes (w, dw, by, sh, ch, ach, etc.)
  • Replace legacy terminology with more descriptive names to the extent permitted by compatibility constraints
  • Replace difficult-to-read variable names with more descriptive and consistent variable names

Describe alternatives you've considered
Just keeping the legacy terminology.

This would mean that there would be no need for developers to adapt, but at the same time, it would make the specification look old, and developers new to the SoundFont or SFE file formats may get confused at old legacy terms.

Work has also been done to replace Win32-specific typedefs with stdint.h typedefs, and completing the rest of the modernisation process would be beneficial by reducing inconsistencies.

Additional context
This would not be done all at once, but starting in version 4.2 and ending in version 4.5. This would prevent users from getting surprised at all the terminology being different.

Version 4.0 already replaced legacy Win32 typedefs with stdint.h typedefs because it is possibly important for developers of software not designed for Win32.

Metadata

Metadata

Assignees

Labels

ISFe-listAnything related to the "ISFe-list" chunkfeature enhancementEnhancement of existing featuresinfo-listAnything related to the "info-list" chunkpdta-listAnything related to the "pdta-list" chunksdta-listAnything related to the "sdta-list" chunkstyle fixFormatting style needs to be fixed

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions