--- linuxsampler/trunk/src/linuxsampler.cpp 2007/01/07 15:52:36 1012 +++ linuxsampler/trunk/src/linuxsampler.cpp 2007/05/26 22:20:46 1208 @@ -112,9 +112,9 @@ if (profile) { dmsg(1,("Calibrating profiler...")); - gig::Profiler::Calibrate(); - gig::Profiler::Reset(); - gig::Profiler::enable(); + LinuxSampler::gig::Profiler::Calibrate(); + LinuxSampler::gig::Profiler::Reset(); + LinuxSampler::gig::Profiler::enable(); dmsg(1,("OK\n")); } @@ -144,7 +144,7 @@ if (profile) { unsigned int samplingFreq = 48000; //FIXME: hardcoded for now - unsigned int bv = gig::Profiler::GetBogoVoices(samplingFreq); + unsigned int bv = LinuxSampler::gig::Profiler::GetBogoVoices(samplingFreq); if (bv != 0) { printf(" BogoVoices: %i \r", bv); @@ -163,10 +163,10 @@ if (!pEngineChannel) continue; Engine* pEngine = pEngineChannel->GetEngine(); if (!pEngine) continue; - LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_voice_count, iter->first, pEngine->VoiceCount())); - LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_stream_count, iter->first, pEngine->DiskStreamCount())); - LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_buffer_fill, iter->first, pEngine->DiskStreamBufferFillPercentage())); - LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_total_voice_count, pSampler->GetVoiceCount())); + pSampler->fireVoiceCountChanged(iter->first, pEngine->VoiceCount()); + pSampler->fireStreamCountChanged(iter->first, pEngine->DiskStreamCount()); + pSampler->fireBufferFillChanged(iter->first, pEngine->DiskStreamBufferFillPercentage()); + pSampler->fireTotalVoiceCountChanged(pSampler->GetVoiceCount()); } LSCPServer::UnlockRTNotify(); } @@ -185,6 +185,9 @@ delete pLSCPServer; } if (pSampler) delete pSampler; +#if HAVE_SQLITE3 + InstrumentsDb::Destroy(); +#endif printf("LinuxSampler stopped due to SIGINT.\n"); exit(EXIT_SUCCESS); } @@ -235,6 +238,8 @@ {"profile",0,0,0}, {"no-tune",0,0,0}, {"statistics",0,0,0}, + {"instruments-db-location",1,0,0}, + {"create-instruments-db",1,0,0}, {"lscp-addr",1,0,0}, {"lscp-port",1,0,0}, {0,0,0,0} @@ -251,13 +256,15 @@ switch(option_index) { case 0: // --help printf("usage: linuxsampler [OPTIONS]\n\n"); - printf("--help prints this message\n"); - printf("--version prints version information\n"); - printf("--profile profile synthesis algorithms\n"); - printf("--no-tune disable assembly optimization\n"); - printf("--statistics periodically prints statistics\n"); - printf("--lscp-addr set LSCP address (default: any)\n"); - printf("--lscp-port set LSCP port (default: 8888)\n"); + printf("--help prints this message\n"); + printf("--version prints version information\n"); + printf("--profile profile synthesis algorithms\n"); + printf("--no-tune disable assembly optimization\n"); + printf("--statistics periodically prints statistics\n"); + printf("--lscp-addr set LSCP address (default: any)\n"); + printf("--lscp-port set LSCP port (default: 8888)\n"); + printf("--create-instruments-db creates an instruments DB\n"); + printf("--instruments-db-location specifies the instruments DB file\n"); exit(EXIT_SUCCESS); break; case 1: // --version @@ -273,19 +280,74 @@ case 4: // --statistics bPrintStatistics = true; break; - case 5: // --lscp-addr - struct in_addr addr; - if (inet_aton(optarg, &addr) == 0) - printf("WARNING: Failed to parse lscp-addr argument, ignoring!\n"); - else - lscp_addr = addr.s_addr; - break; - case 6: // --lscp-port - long unsigned int port = 0; - if ((sscanf(optarg, "%u", &port) != 1) || (port == 0) || (port > 65535)) - printf("WARNING: Failed to parse lscp-port argument, ignoring!\n"); - else - lscp_port = htons(port); + case 5: // --instruments-db-location +#if HAVE_SQLITE3 + try { + if (optarg) { + struct stat statBuf; + int res = stat(optarg, &statBuf); + + if (res) { + std::stringstream ss; + ss << "Fail to stat `" << optarg << "`: " << strerror(errno); + throw Exception(ss.str()); + } + + if (!S_ISREG(statBuf.st_mode)) { + std::stringstream ss; + ss << "`" << optarg << "` is not a regular file"; + throw Exception(ss.str()); + } + + InstrumentsDb::GetInstrumentsDb()->SetDbFile(String(optarg)); + } + } catch(Exception e) { + std::cerr << e.Message() << std::endl << std::endl; + return; + } + + return; +#else + std::cerr << "LinuxSampler was not build with "; + std::cerr << "instruments database support." < 65535)) + printf("WARNING: Failed to parse lscp-port argument, ignoring!\n"); + else + lscp_port = htons(port); break; } }