MCPcopy Create free account
hub / github.com/TheWaveWarden/odin2 / migratePatch

Method migratePatch

Source/PluginProcessorMigratePatch.cpp:20–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18#include "PluginProcessor.h"
19
20void OdinAudioProcessor::migratePatch(ValueTree &p_patch) {
21
22 //this is where the dirty patch hacking takes place!!
23
24 for (int i = 0; i < p_patch.getNumChildren(); ++i) {
25 // all children which are an audio param have two properties (name and value)
26 if (p_patch.getChild(i).getNumProperties() == 2) {
27
28 //HACK #1:
29 // carrier ratio, modulator ratio, and pitchbend amount where audio-params for some reason
30 // now we read them as audio params and set them back as non-audio-params where they belong
31
32 if (p_patch.getChild(i).getProperty(p_patch.getChild(i).getPropertyName(0)).toString() ==
33 "osc1_carrier_ratio") {
34 p_patch.getChildWithName("osc").setProperty(
35 "osc1_carrier_ratio",
36 p_patch.getChild(i).getProperty(p_patch.getChild(i).getPropertyName(1)),
37 nullptr);
38 } else if (p_patch.getChild(i).getProperty(p_patch.getChild(i).getPropertyName(0)).toString() ==
39 "osc2_carrier_ratio") {
40 p_patch.getChildWithName("osc").setProperty(
41 "osc2_carrier_ratio",
42 p_patch.getChild(i).getProperty(p_patch.getChild(i).getPropertyName(1)),
43 nullptr);
44 } else if (p_patch.getChild(i).getProperty(p_patch.getChild(i).getPropertyName(0)).toString() ==
45 "osc3_carrier_ratio") {
46 p_patch.getChildWithName("osc").setProperty(
47 "osc3_carrier_ratio",
48 p_patch.getChild(i).getProperty(p_patch.getChild(i).getPropertyName(1)),
49 nullptr);
50 } else if (p_patch.getChild(i).getProperty(p_patch.getChild(i).getPropertyName(0)).toString() ==
51 "osc1_modulator_ratio") {
52 p_patch.getChildWithName("osc").setProperty(
53 "osc1_modulator_ratio",
54 p_patch.getChild(i).getProperty(p_patch.getChild(i).getPropertyName(1)),
55 nullptr);
56 } else if (p_patch.getChild(i).getProperty(p_patch.getChild(i).getPropertyName(0)).toString() ==
57 "osc2_modulator_ratio") {
58 p_patch.getChildWithName("osc").setProperty(
59 "osc2_modulator_ratio",
60 p_patch.getChild(i).getProperty(p_patch.getChild(i).getPropertyName(1)),
61 nullptr);
62 } else if (p_patch.getChild(i).getProperty(p_patch.getChild(i).getPropertyName(0)).toString() ==
63 "osc3_modulator_ratio") {
64 p_patch.getChildWithName("osc").setProperty(
65 "osc3_modulator_ratio",
66 p_patch.getChild(i).getProperty(p_patch.getChild(i).getPropertyName(1)),
67 nullptr);
68 } else if (p_patch.getChild(i).getProperty(p_patch.getChild(i).getPropertyName(0)).toString() ==
69 "pitchbend_amount") {
70 p_patch.getChildWithName("misc").setProperty(
71 "pitchbend_amount",
72 p_patch.getChild(i).getProperty(p_patch.getChild(i).getPropertyName(1)),
73 nullptr);
74 }
75 }
76 }
77}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected