diff --git a/dssi-vst-scanner.cpp b/dssi-vst-scanner.cpp index 03d8376..c61d821 100644 --- a/dssi-vst-scanner.cpp +++ b/dssi-vst-scanner.cpp @@ -44,7 +44,7 @@ hostCallback(AEffect *plugin, long opcode, long index, return 2300; case audioMasterGetVendorString: - strcpy((char *)ptr, "Chris Cannam"); + strcpy((char *)ptr, "Fervent Software"); break; case audioMasterGetProductString: @@ -119,7 +119,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow) char *destFile = 0; cout << "DSSI VST plugin scanner v0.2" << endl; - cout << "Copyright (c) 2004 Chris Cannam" << endl; + cout << "Copyright (c) 2004 Chris Cannam - Fervent Software" << endl; if (cmdline && cmdline[0]) destFile = strdup(cmdline); @@ -133,22 +133,8 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow) } } - //!!! could do with an option for vst/vsti path, for the moment - // we'll deal only with effects - -// char libPath[1024]; HINSTANCE libHandle = 0; - -#ifdef NOT_DEFINED -//!!! - char *vstDir = getenv("VST_DIR"); - if (!vstDir) { - cerr << "dssi-vst-scanner: $VST_DIR not set" << endl; - exit(1); - } -#endif - std::vector vstPath = Paths::getPath ("VST_PATH", "/usr/local/lib/vst:/usr/lib/vst", "/vst"); @@ -199,6 +185,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow) // parameter count (int) // then for each parameter: // name (64 chars) + // default value (float) // // program count (int) // then for each program: @@ -213,22 +200,6 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow) continue; } -#ifdef NOT_DEFINED -//!!! - if (vstDir[strlen(vstDir) - 1] == '/') { - snprintf(libPath, 1024, "%s%s", vstDir, libname.c_str()); - } else { - snprintf(libPath, 1024, "%s/%s", vstDir, libname.c_str()); - } - - std::string libpathstr(libPath); - - if (home && home[0] != '\0') { - if (libpathstr.substr(0, strlen(home)) == std::string(home)) { - libpathstr = libpathstr.substr(strlen(home) + 1); - } - } -#endif int fd = targetfd; bool haveCache = false; bool writingCache = false; @@ -355,6 +326,9 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow) memset(buffer, 0, 65); plugin->dispatcher(plugin, effGetParamName, i, 0, buffer, 0); write(fd, buffer, 64); + //!!! do I need mains changed before this?: + float f = plugin->getParameter(plugin, i); + write(fd, &f, sizeof(float)); } programs = plugin->numPrograms; diff --git a/dssi-vst-server.cpp b/dssi-vst-server.cpp index 3e796d1..f73a549 100644 --- a/dssi-vst-server.cpp +++ b/dssi-vst-server.cpp @@ -90,6 +90,7 @@ class RemoteVSTServer : public RemotePluginServer AEffect *m_plugin; std::string m_name; std::string m_maker; + float *m_defaults; bool m_hasMIDI; }; @@ -151,11 +152,17 @@ RemoteVSTServer::RemoteVSTServer(std::string fileIdentifiers, if (buffer[0]) m_maker = buffer; m_plugin->dispatcher(m_plugin, effMainsChanged, 0, 1, NULL, 0); + + m_defaults = new float[m_plugin->numParams]; + for (int i = 0; i < m_plugin->numParams; ++i) { + m_defaults[i] = m_plugin->getParameter(m_plugin, i); + } } RemoteVSTServer::~RemoteVSTServer() { m_plugin->dispatcher(m_plugin, effClose, 0, 0, NULL, 0); + delete[] m_defaults; } void @@ -222,8 +229,7 @@ RemoteVSTServer::getParameter(int p) float RemoteVSTServer::getParameterDefault(int p) { - //!!! fix - return m_plugin->getParameter(m_plugin, p); + return m_defaults[p]; } std::string @@ -329,7 +335,7 @@ hostCallback(AEffect *plugin, long opcode, long index, case audioMasterGetVendorString: if (debugLevel > 1) cerr << "dssi-vst-server[2]: audioMasterGetVendorString requested" << endl; - strcpy((char *)ptr, "Chris Cannam"); + strcpy((char *)ptr, "Fervent Software"); break; case audioMasterGetProductString: @@ -490,7 +496,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow) char *fileInfo = 0; cout << "DSSI VST plugin server v" << RemotePluginVersion << endl; - cout << "Copyright (c) 2004 Chris Cannam" << endl; + cout << "Copyright (c) 2004 Chris Cannam - Fervent Software" << endl; char *home = getenv("HOME"); diff --git a/dssi-vst.cpp b/dssi-vst.cpp index c4ea15f..714d951 100644 --- a/dssi-vst.cpp +++ b/dssi-vst.cpp @@ -324,7 +324,7 @@ DSSIVSTPluginInstance::run(unsigned long sampleCount) void DSSIVSTPluginInstance::runSynth(unsigned long sampleCount, - snd_seq_event_t *events, unsigned long eventCount) + snd_seq_event_t *events, unsigned long eventCount) { try { if (m_alsaDecoder) { @@ -431,8 +431,23 @@ DSSIVSTPlugin::DSSIVSTPlugin() for (int i = 0; i < parameters; ++i) { ports[i] = LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL; names[i] = strdup(rec.parameterNames[i].c_str()); - hints[i].HintDescriptor = 0; //!!! need this - std::cerr << "Port " << i << ": name " << names[i] << std::endl; + hints[i].LowerBound = 0.0; + hints[i].LowerBound = 1.0; + hints[i].HintDescriptor = + LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE; + float deflt = rec.parameterDefaults[i]; + if (deflt < 0.0001) { + hints[i].HintDescriptor |= LADSPA_HINT_DEFAULT_MINIMUM; + } else if (deflt > 0.999) { + hints[i].HintDescriptor |= LADSPA_HINT_DEFAULT_MAXIMUM; + } else if (deflt < 0.35) { + hints[i].HintDescriptor |= LADSPA_HINT_DEFAULT_LOW; + } else if (deflt > 0.65) { + hints[i].HintDescriptor |= LADSPA_HINT_DEFAULT_HIGH; + } else { + hints[i].HintDescriptor |= LADSPA_HINT_DEFAULT_MIDDLE; + } + std::cerr << "Port " << i << ": name " << names[i] << ", hint " << hints[i].HintDescriptor << std::endl; } for (int i = 0; i < inputs; ++i) { diff --git a/remotevstclient.cpp b/remotevstclient.cpp index 06a181c..b374d8f 100644 --- a/remotevstclient.cpp +++ b/remotevstclient.cpp @@ -243,7 +243,10 @@ RemoteVSTClient::queryPlugins(std::vector &plugins) for (int i = 0; i < rec.parameters; ++i) { tryRead(fd, buffer, 64); rec.parameterNames.push_back(std::string(buffer)); - std::cerr << "Parameter " << i << ": name " << buffer << std::endl; + float f; + tryRead(fd, &f, sizeof(float)); + rec.parameterDefaults.push_back(f); + std::cerr << "Parameter " << i << ": name " << buffer << ", default " << f << std::endl; } tryRead(fd, &rec.programs, sizeof(int)); diff --git a/remotevstclient.h b/remotevstclient.h index 144b7a4..d78e347 100644 --- a/remotevstclient.h +++ b/remotevstclient.h @@ -31,6 +31,7 @@ class RemoteVSTClient : public RemotePluginClient int outputs; int parameters; std::vector parameterNames; + std::vector parameterDefaults; int programs; std::vector programNames; };