Creating new tracks & changing instrument/sound programatically #19431
-
Hi, I'm trying to programmatically create new parts (this works) and change their instrument (not working) directly in this C++ function. // Added in .h
INJECT(notation::IInstrumentsRepository, instrumentsRepository)
// Added in .c ConverterController::fileConvert
mu::notation::IMasterNotationPtr master = notationProject->masterNotation();
mu::notation::INotationPtr notation = notationProject->masterNotation()->notation();
mu::engraving::MasterScore *score = notationProject->masterNotation()->masterScore();
mu::notation::INotationPartsPtr notationParts = notation->parts();
PartInstrumentList partList;
IDList originalIDs;
size_t idx = 0;
for (const auto *p : notationParts->partList())
{
originalIDs.emplace_back(p->id());
partList.append(PartInstrument{
.partId = p->id(),
.instrumentTemplate = instrumentsRepository()->instrumentTemplate(p->instrumentId().toStdString()),
.isExistingPart = true, // exisiting
.isSoloist = p->soloist(),
});
partList.append(PartInstrument{
.partId = notationParts->partList().size() + (idx++),
.instrumentTemplate = instrumentsRepository()->instrumentTemplate(p->instrumentId().toStdString()),
.isExistingPart = false, // new
.isSoloist = p->soloist(),
});
}
master->parts()->setParts(partList, master->parts()->scoreOrder());
score->doLayout(); While this correctly creates new parts for each existing part, it seems like the
Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
cbjeukendrup
Sep 19, 2023
Replies: 1 comment 6 replies
-
To change instrument, there is MuseScore/src/engraving/dom/part.h Line 143 in eff81f3 |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the repository is indeed still empty, you're most likely running a non-installed build: you're using the executable from the build folder instead of the one from the install folder specified using
CMAKE_INSTALL_PREFIX
.