MCPcopy Create free account
hub / github.com/csound/csound / getInstrument

Method getInstrument

interfaces/CsoundFile.cpp:845–879  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

843}
844
845bool CsoundFile::getInstrument(int number, std::string &definition_) const
846{
847 int beginDefinition = 0;
848 int endDefinition = 0;
849 for(int index = 0; true; index++)
850 {
851 beginDefinition = findToken(orchestra, "instr", beginDefinition);
852 if(beginDefinition == -1)
853 {
854 return false;
855 }
856 endDefinition = findToken(orchestra, "endin", beginDefinition);
857 if(endDefinition == -1)
858 {
859 return false;
860 }
861 endDefinition += 6;
862 std::string definition = orchestra.substr(beginDefinition,
863 endDefinition - beginDefinition);
864 std::string pre;
865 std::string id;
866 std::string name;
867 std::string post;
868 if(parseInstrument(definition, pre, id, name, post))
869 {
870 if(number == atof(id.c_str()))
871 {
872 definition_ = definition;
873 return true;
874 }
875 }
876 beginDefinition++;
877 }
878 return false;
879}
880
881std::string CsoundFile::getInstrument(std::string name) const
882{

Callers

nothing calls this directly

Calls 4

findTokenFunction · 0.85
parseInstrumentFunction · 0.85
trimFunction · 0.85
compareMethod · 0.80

Tested by

no test coverage detected