gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

config.cpp (1404B)


      1 #include "config.h"
      2 
      3 #include "server.h"
      4 
      5 #include "baseLib/commandline.h"
      6 #include "baseLib/configFile.h"
      7 #include "baseLib/filesystem.h"
      8 
      9 namespace bridgeServer
     10 {
     11 	Config::Config(int _argc, char** _argv)
     12 		: portTcp(bridgeLib::g_tcpServerPort)
     13 		, portUdp(bridgeLib::g_udpServerPort)
     14 		, deviceStateRefreshMinutes(3)
     15 		, pluginsPath(getDefaultDataPath() + "plugins/")
     16 		, romsPath(getDefaultDataPath() + "roms/")
     17 	{
     18 		const baseLib::CommandLine commandLine(_argc, _argv);
     19 
     20 		auto configFilename = commandLine.get("config");
     21 
     22 		if (configFilename.empty())
     23 			configFilename = getDefaultDataPath() + "config/dspBridgeServer.cfg";
     24 
     25 		baseLib::ConfigFile config(configFilename);
     26 
     27 		config.add(commandLine, true);
     28 
     29 		portTcp = config.getInt("tcpPort", static_cast<int>(portTcp));
     30 		portUdp = config.getInt("tcpPort", static_cast<int>(portUdp));
     31 		deviceStateRefreshMinutes = config.getInt("deviceStateRefreshMinutes", static_cast<int>(deviceStateRefreshMinutes));
     32 		pluginsPath = config.get("pluginsPath", pluginsPath);
     33 		romsPath = config.get("romsPath", romsPath);
     34 
     35 		baseLib::filesystem::createDirectory(pluginsPath);
     36 		baseLib::filesystem::createDirectory(romsPath);
     37 	}
     38 
     39 	std::string Config::getDefaultDataPath()
     40 	{
     41 		return baseLib::filesystem::validatePath(baseLib::filesystem::getSpecialFolderPath(baseLib::filesystem::SpecialFolderType::UserDocuments)) + "The Usual Suspects/dspBridgeServer/";
     42 	}
     43 }