New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asset System Rewrite #7138
Comments
I think this might also help with #6909 |
Just looking through this quickly, the first thing I'm inclined to ask is what the deal with As for the names, |
I had been thinking it would be so that
Yeah, good point. I meant it in that this new asset system would use
How about |
I don't think this is true.
Surely leaving serialisation to individual classes is the right approach? The idea here is to have an extensible system that doesn't require
Supported audio file formats are already dynamically detected in
Ways to reduce the core Qt dependency are always good. I too dislike that
This is a reasonable point. As |
Please note that there is also pull request #6866 by @consolegrl which intends to improve the structure of the upgrade routines with regards to @TechnoPorg, how do you want to deal with loading existing files? |
Another idea for the default samples and presets shipping with LMMS: I think of having one lump of sqlite database that contains current snapshot of ogg, xpf and xiz, and .ds data. There are roughly 1400 tiny files scattered in places. The current assets files compose around 15mb. A rough database would be:
Every time a resource is required, it would query the database and cache it optionally. Introducing an embedded database is about ~1.5mb overhead with sqlite3.h. But It could help a lot in enhancing directory browser, assets navigation, searches, configurations, svgs, themes and many more by putting them in a single file. The only drawback is 15mb (aka, the final assets as sqlite) to be under version control. (I have already connected to the sqlite with native c++ to test it, and might help if in case we want to migrate to using database, including current assets.) |
Enhancement Summary
For all kinds of data, from projects to plugins to samples, LMMS currently manages most of its saving and loading of that data through the
DataFile
class.DataFile
does not offer its own built-in serialization methods, but rather relies on individual classes to write to and read from a separateDataFile
that then gets serialized as XML.In short, the
DataFile
workflow was something that grew, rather than being engineered. From what I gather, most parts ofDataFile
are written in a way that is inflexible and outdated; I don't think some of that code has seen the light of day in years 🥲. LMMS as a whole would benefit from a more modular, extensible, and flexible asset handling system to replace it.Justification
This will allow us to do several things much more easily:
DataFile
is hard-coded with enums and fixed lists of file extensions, and the code does not lend itself well to changes to those. A system where the asset importer is decoupled from the asset types themselves would make it far easier to do this.DataFile
uses it, and removing it would be beneficial to the goal of Plan for the core: Removing Qt, Decoupling, and Modernization #6472.DataFile
API is pretty convoluted, and when I tried to write tests for it in Add unit tests for DataFile #7121, I found it was not easy to try and write comprehensive tests, which makes it hard to guard the system against regressions.Mockup
I've been thinking about how the new system would need to be designed to address the above points, and this is what I've come up with:
Asset
All types that can be considered "project data objects" will inherit from the
Asset
base class. TheAsset
class will have away of indicating what type of asset it is, and a specific way of binding properties that are to be serialized, with an API something like this:Basically, it would be similar in concept to Blender's RNA system, or Godot's
Object
class.AssetLoader
Asset loading will be handled by the
AssetLoader
(maybeAssetReader
, but I don't like that as much) abstract class, with an API something like this at minimum:I see
AssetLoader
s being implemented in a hierarchical, modular way. The base asset loader used by LMMS would beAssetLoaderDefault
, which would be a wrapper around severalAssetCategoryLoader
s, which load specific file types. There will also be anAssetLoaderText
base class which loads serialized properties of previously saved assets. This diagram illustrates it best:AssetWriter
Asset saving will be handled by the
AssetWriter
class. There will be anAssetWriterDefault
which takes the exposed properties and stores them in a structured format (probably text), and will recursively serialize allAsset
properties of anAsset
. This could be further specialized into something like anAssetTextWriterXML
/AssetTextWriterJSON
class if desired.Example API:
Here's a diagram broadly illustrating how the saving of a song might work in practice:
Both this and
AssetLoader
would ideally be based onstd::filesystem
.In conclusion, this would be a major change and represent a significant amount of effort, but I believe it is something that needs to happen if LMMS is to move forward.
I would very much appreciate feedback and debate on the idea, because I am under no illusions that the design I have laid out here is the best possible one, and it could be made even better with input from other, more experienced developers.
Thank you!
The text was updated successfully, but these errors were encountered: