Krotos Modules 3
Loading...
Searching...
No Matches
RelativeSamplePathRewriteHook.cpp
Go to the documentation of this file.
1namespace krotos
2{
4
6 {
8 {
9 ValueTree kwidgetsTree = request.newState.getChildWithName(XmlType::Tag::kwidgets);
10
11 // Predicate to check if a tree node is a kwidget of a given type
12 auto isType = [](const juce::ValueTree& node, const String& type) {
13 if (node.hasType(XmlType::Tag::kwidget))
14 {
15 auto kwidgetType = node.getProperty(XmlType::Property::type, juce::var()).toString();
16 return type == kwidgetType;
17 }
18 return false;
19 };
20
21 // Iterate through the tree and rewrite the paths as required for each kwidget
22 for (auto node : kwidgetsTree)
23 {
26 {
27 const auto newAudioAssetPath = PresetBundler::getAudioAssetDirectoryForBundle(request.presetFile);
28
29 const Result engineRewriteResult(SamplesTree::rewriteSamplePaths(node, newAudioAssetPath));
30
31 if (engineRewriteResult.failed())
32 {
33 response.success = false;
34 response.message += "\n" + engineRewriteResult.getErrorMessage();
35 }
36 }
37 // KST-2636: removed as part of hotfix to remove IRs from inclusion in exported preset bundles
38// else if (isType(node, KwidgetFactory::KwidgetType::ConvolutionReverb))
39// {
40// const Result reverbRewriteResult(Kwidget_ConvolutionReverb::rewriteImpulseParameterPath(
41// node, PresetBundler::getAudioAssetDirectoryForBundle(request.presetFile).getFullPathName()));
42//
43// if (reverbRewriteResult.failed())
44// {
45// response.success = false;
46// response.message += "\n" + reverbRewriteResult.getErrorMessage();
47// }
48// }
49 };
50
51 if (response.success)
52 {
53 response.message = "RelativeSamplePathRewriteHook executed successfully";
54 }
55 else
56 {
57 std::cout << "RelativeSamplePathRewriteHook failed with errors: \n\t" << response.message << std::endl;
58 }
59 }
60 }
61} // namespace krotos
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 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
void onPresetLoad(PresetLoadRequest &request, PresetLoadResponse &response)
Handles the preset load event, potentially rewriting relative sample paths.
Definition RelativeSamplePathRewriteHook.cpp:5
void onKwidgetLoad(KwidgetLoadRequest &request, KwidgetLoadResponse &response) override
Handles the Kwidget load event, potentially rewriting relative sample paths.
Definition RelativeSamplePathRewriteHook.cpp:3
static Result rewriteSamplePaths(ValueTree &engineKwidgetTree, File newAbsolutePath)
Rewrite relative SamplePath path values created by the PresetBundler into absolute ones of a given pa...
Definition SampleDataTree.cpp:281
Definition AirAbsorptionFilter.cpp:2
static const String Reformer
Definition KwidgetFactory.h:14
static const String CoreEngine
Definition KwidgetFactory.h:13
A middleware request object for a Kwidget load event.
Definition PresetEventMiddleware.h:36
A middleware response object for the Kwidget load operation.
Definition PresetEventMiddleware.h:47
A middleware request object for a preset load event.
Definition PresetEventMiddleware.h:7
File presetFile
Definition PresetEventMiddleware.h:12
ValueTree newState
The new preset state value tree.
Definition PresetEventMiddleware.h:11
A simple middleware response object containing the success status and a message.
Definition PresetEventMiddleware.h:19
String message
A message describing the result of the middleware operation.
Definition PresetEventMiddleware.h:29
bool success
Indicates whether the middleware was successful in processing the preset load request,...
Definition PresetEventMiddleware.h:24
static const Identifier type
Definition XmlType.h:43
static const Identifier kwidgets
Definition XmlType.h:22
static const Identifier kwidget
Definition XmlType.h:23