MCPcopy Create free account
hub / github.com/davy7125/polyphone / copy

Method copy

sources/core/duplicator.cpp:55–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55EltID Duplicator::copy(EltID idSource, EltID idDest)
56{
57 if (idDest.typeElement != elementSf2 && idDest.typeElement != elementInst &&
58 idDest.typeElement != elementInstSmpl && idDest.typeElement != elementRootInst &&
59 idDest.typeElement != elementPrst && idDest.typeElement != elementPrstInst &&
60 idDest.typeElement != elementRootPrst && idDest.typeElement != elementRootSmpl &&
61 idDest.typeElement != elementSmpl)
62 return EltID();
63
64 EltID newId;
65 if (idSource.indexSf2 == idDest.indexSf2)
66 {
67 // Link in the same file
68 switch (idSource.typeElement)
69 {
70 case elementSmpl:
71 if (idDest.typeElement == elementInst || idDest.typeElement == elementInstSmpl)
72 newId = linkSmpl(idSource, idDest);
73 break;
74 case elementInst:
75 if (idDest.typeElement == elementPrst || idDest.typeElement == elementPrstInst)
76 newId = linkInst(idSource, idDest);
77 else if (idDest.typeElement == elementInst || idDest.typeElement == elementInstSmpl)
78 {
79 // Copy the global division
80 copyGlobal(idSource, idDest);
81
82 // Link all samples of an instrument to the other instrument (can be the same instrument)
83 idSource.typeElement = elementInstSmpl;
84 foreach (int i, _sm->getSiblings(idSource))
85 {
86 idSource.indexElt2 = i;
87 copy(idSource, idDest);
88 }
89
90 newId = idDest;
91 }
92 break;
93 case elementInstSmpl:
94 if (idDest.typeElement == elementInst || idDest.typeElement == elementInstSmpl)
95 newId = copyLink(idSource, idDest);
96 break;
97 case elementPrst:
98 if (idDest.typeElement == elementPrst || idDest.typeElement == elementPrstInst)
99 {
100 // Copy the global division
101 copyGlobal(idSource, idDest);
102
103 // Link all instruments of a preset to the other preset (can be the same preset)
104 idSource.typeElement = elementPrstInst;
105 foreach (int i, _sm->getSiblings(idSource))
106 {
107 idSource.indexElt2 = i;
108 copy(idSource, idDest);
109 }
110
111 newId = idDest;
112 }

Callers

nothing calls this directly

Calls 1

EltIDClass · 0.85

Tested by

no test coverage detected