Krotos Modules 3
Loading...
Searching...
No Matches
PresetBundler.h
Go to the documentation of this file.
1#pragma once
2namespace krotos
3{
28 {
29 public:
35 PresetBundler(File preset);
36
42 PresetBundler(ValueTree presetData);
43
47 static const String BundleFileExtension;
48
50 {
51 // local audio asset filepath
52 String assetPath; // e.g. "C:\myPath\elements\WIND.wav"
53 // filename and subdirectory ID to be used in bundle
54 String assetID; // e.g. Asset1\WIND.wav
55 };
56
62 bool createBundle(File outputLocation, String& errors);
63
71 static File openBundle(File bundleArchive);
72
78 static File getPresetFromBundleDirectory(File bundleDirectory);
79
86 static bool validateBundleDirectory(File bundleDirectory);
87
95 static bool isABundlePreset(const File& preset);
96
101 int setMaximumBundleSizeInMegaBytes(int newSizeMb) { m_maxSizeMegaBytes = newSizeMb; }
102
107 void setPresetFileExtension(String fileExtension);
108
113 static File getSandboxDirectory();
121 static File getSandboxDirectoryForBundle(const File& bundleFile);
122
130 static File getAudioAssetDirectoryForBundle(const File& bundleFile);
131
139 static File getPresetDirectoryForBundle(const File& bundleFile);
140
141 // Folder name for bundle preset, including a '/' suffix
142 static const String PresetSubdirectory;
143 // Folder name for audio files, including a '/' suffix
144 static const String AudioAssetsSubdirectory;
145
146 protected:
147 // Get the bundle root path for the preset export
148 File getExportBundleRoot();
149 // Create a directory in temp as the bundle root
151 // Clean up the temp bundle root
153 // Collects asset data using the preset
154 std::vector<AudioAsset> getAssetsListFromPreset();
155 // Copy the preset file into the bundle root
156 File copyPresetForExport(String nameForPresetFile);
157 // Copy audio files into the bundle root (.wav, .aif, .aiff, .ogg, .flac)
159 // Updates the file paths in the bundled preset to match the bundled assets
160 void processExportedPresetFile(File exportPreset);
161 // Creates the .kspb archive file
162 File buildBundleArchive(String outputDirectoryPath);
163 // Provides an estimate of the bundle size. Does not include any file compression
164 // excludes the preset file
166 // Returns a list of any files in the preset that cannot be found on the computer
167 String listMissingFiles();
168 // Used for unit testing the asset file paths
169 std::vector<AudioAsset> getAssetFilepaths() { return m_assetFilepaths; };
170 // Users custom factory assets directory path
172
173 private:
174 void initialise(ValueTree presetData);
175
176 void clenseExportIDs();
177 bool isValueAudioFile(String value);
178 bool isValueMultipleFiles(String value);
179
180 void getPresetFilepaths(StringArray& listOfFiles, XmlElement widgetElement);
181 void findPathAttributesRecursive(StringArray& listOfFiles, XmlElement customParamsElement);
182 // Note: This function will not replace paths in an xml tag that contains multiple paths
183 // e.g. <TAG value="/My/File/path.wav&#10;/My/File/path2.wav">
184 // At present this is only the case in a deprecated parameter in the coreEngine kwidget.
185 // These do not require replacing as the kwidget duplicates them into SAMPLES child
186 // elements which nicely contain a single path each, these elements will be replaced successfully.
187 void replacePaths(XmlElement& widgetElement);
188 void replacePathRecursive(XmlElement& widgetElement);
189 // converts OS style & checks for custom factory asset paths
190 String convertFilepath(String filepathFromPreset);
191
194 ValueTree m_presetFile;
195 std::vector<AudioAsset> m_assetFilepaths;
197 };
198} // namespace krotos
Definition PresetBundler.h:28
void copyAudioAssetsForExport()
Definition PresetBundler.cpp:138
static File getAudioAssetDirectoryForBundle(const File &bundleFile)
Returns the path to the audio assets directory for a particular bundle based on the name of the file ...
Definition PresetBundler.cpp:415
static const String AudioAssetsSubdirectory
Definition PresetBundler.h:144
static File getSandboxDirectory()
Returns the path to the sandbox directory where the preset bundles are temporarily stored.
Definition PresetBundler.cpp:405
void initialise(ValueTree presetData)
Definition PresetBundler.cpp:18
static File openBundle(File bundleArchive)
Extracts the contents of a bundle archive to the temporary "sandbox" directory.
Definition PresetBundler.cpp:80
static File getSandboxDirectoryForBundle(const File &bundleFile)
Returns the path to the sandbox directory for a particular bundle based on the name of the file being...
Definition PresetBundler.cpp:410
void getPresetFilepaths(StringArray &listOfFiles, XmlElement widgetElement)
Definition PresetBundler.cpp:212
static File getPresetFromBundleDirectory(File bundleDirectory)
Locates the preset file within a given bundle directory.
Definition PresetBundler.cpp:119
int setMaximumBundleSizeInMegaBytes(int newSizeMb)
Definition PresetBundler.h:101
String m_bundleRootId
Definition PresetBundler.h:193
void cleanUpFileStructure()
Definition PresetBundler.cpp:175
std::vector< AudioAsset > m_assetFilepaths
Definition PresetBundler.h:195
int getEstimatedAssetsSizeMB()
Definition PresetBundler.cpp:200
void processExportedPresetFile(File exportPreset)
Definition PresetBundler.cpp:295
int m_maxSizeMegaBytes
Definition PresetBundler.h:196
File copyPresetForExport(String nameForPresetFile)
Definition PresetBundler.cpp:126
bool createBundle(File outputLocation, String &errors)
Definition PresetBundler.cpp:32
bool isValueMultipleFiles(String value)
Definition PresetBundler.cpp:430
void clenseExportIDs()
Definition PresetBundler.cpp:390
std::vector< AudioAsset > getAssetsListFromPreset()
Definition PresetBundler.cpp:268
void replacePaths(XmlElement &widgetElement)
Definition PresetBundler.cpp:309
PresetBundler(File preset)
Definition PresetBundler.cpp:9
static bool isABundlePreset(const File &preset)
Returns whether this preset file is part of a bundle. This is just a simple check for that the provid...
Definition PresetBundler.cpp:425
static const String BundleFileExtension
The file extension for the bundle archive.
Definition PresetBundler.h:47
String convertFilepath(String filepathFromPreset)
Definition PresetBundler.cpp:432
File buildBundleArchive(String outputDirectoryPath)
Definition PresetBundler.cpp:354
String listMissingFiles()
Definition PresetBundler.cpp:375
void findPathAttributesRecursive(StringArray &listOfFiles, XmlElement customParamsElement)
Definition PresetBundler.cpp:236
static bool validateBundleDirectory(File bundleDirectory)
Validates that a given directory is a valid bundle directory by checking it is a child file of the sa...
Definition PresetBundler.cpp:102
void replacePathRecursive(XmlElement &widgetElement)
Definition PresetBundler.cpp:326
static File getPresetDirectoryForBundle(const File &bundleFile)
Returns the path to the preset directory for a particular bundle based on the name of the file being ...
Definition PresetBundler.cpp:420
ValueTree m_presetFile
Definition PresetBundler.h:194
static String m_presetFileExtension
Definition PresetBundler.h:192
void setPresetFileExtension(String fileExtension)
Definition PresetBundler.cpp:403
String m_factoryAssetsDirectory
Definition PresetBundler.h:171
static const String PresetSubdirectory
Definition PresetBundler.h:142
bool isValueAudioFile(String value)
Definition PresetBundler.cpp:184
std::vector< AudioAsset > getAssetFilepaths()
Definition PresetBundler.h:169
bool createBundleFileStructure()
Definition PresetBundler.cpp:166
File getExportBundleRoot()
Definition PresetBundler.cpp:159
Definition AirAbsorptionFilter.cpp:2
Definition PresetBundler.h:50
String assetPath
Definition PresetBundler.h:52
String assetID
Definition PresetBundler.h:54