int CModuleConfig::translate(int mid, std::string & mip, int sid, std::string & sip, std::map<int8_t, std::vector<std::string> >& outputData, std::string function) { if(function=="master") { return translateMaster(mid,mip,sid,sip,outputData); } else if(function=="slave") { return translateSlave(mid,mip,sid,sip,outputData); } else if(function=="master&slave") { return translateMasterSlave(mid,mip,sid,sip,outputData); } return 0; }
int MusicModel::processArgs(const std::vector<std::string> &args) { System::inform("BEGAN MusicModel::processArgv()...\n"); std::map<std::string, std::string> argsmap; std::string key; for (size_t i = 0, n = args.size(); i < n; ++i) { const std::string token = args[i]; std::string value = ""; if (token.find("--") == 0) { key = token; System::inform("argument[%2d]: %s\n", i, key.c_str()); } else { value = token; System::inform("argument[%2d]: %s = %s\n", i, key.c_str(), value.c_str()); } argsmap[key] = value; } char command[0x200]; int errorStatus = 0; bool postPossible = false; std::string playSoundfileName = getOutputSoundfileName(); if ((argsmap.find("--dir") != argsmap.end()) && !errorStatus) { setOutputDirectory(argsmap["--dir"]); } if ((argsmap.find("--midi") != argsmap.end()) && !errorStatus) { errorStatus = generate(); if (errorStatus) { return errorStatus; } getScore().save(getMidiFilename().c_str()); } if ((argsmap.find("--notation") != argsmap.end()) && !errorStatus) { translateToNotation(); } if ((argsmap.find("--audio") != argsmap.end()) && !errorStatus) { postPossible = false; const char *audiosystem = argsmap["--audio"].c_str(); const char *devicename = argsmap["--device"].c_str(); std::sprintf(command, "csound --midi-key=4 --midi-velocity=5 -m195 -+rtaudio=%s -o %s", audiosystem, devicename); System::inform("Csound command: %s\n", command); setCsoundCommand(command); errorStatus = render(); } if ((argsmap.find("--csound") != argsmap.end()) && !errorStatus) { postPossible = true; errorStatus = render(); } if ((argsmap.find("--pianoteq") != argsmap.end()) && !errorStatus) { std::sprintf(command, "Pianoteq --midi=%s\n", getMidiFilename().c_str()); System::inform("Executing command: %s\n", command); errorStatus = std::system(command); } if ((argsmap.find("--pianoteq-wav") != argsmap.end()) && !errorStatus) { postPossible = true; std::sprintf(command, "Pianoteq --headless --midi %s --rate 48000 --wav %s\n", getMidiFilename().c_str(), getOutputSoundfileName().c_str()); System::inform("Executing command: %s\n", command); errorStatus = std::system(command); } if ((argsmap.find("--playmidi") != argsmap.end()) && !errorStatus) { std::sprintf(command, "%s %s\n", argsmap["--playmidi"].c_str(), getMidiFilename().c_str()); System::inform("Executing command: %s\n", command); errorStatus = std::system(command); } if ((argsmap.find("--post") != argsmap.end()) && !errorStatus && postPossible) { errorStatus = translateMaster(); playSoundfileName = getNormalizedSoundfileName(); } if ((argsmap.find("--playwav") != argsmap.end()) && !errorStatus) { std::sprintf(command, "%s %s\n", argsmap["--playwav"].c_str(), playSoundfileName.c_str()); System::inform("Csound command: %s\n", command); errorStatus = std::system(command); } System::inform("ENDED MusicModel::processArgv().\n"); return errorStatus; }