Skip to content

Commit

Permalink
* handle port defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
cannam committed Aug 16, 2004
1 parent 20e5392 commit 4f32a1f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 40 deletions.
38 changes: 6 additions & 32 deletions dssi-vst-scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);

Expand All @@ -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<std::string> vstPath = Paths::getPath
("VST_PATH", "/usr/local/lib/vst:/usr/lib/vst", "/vst");

Expand Down Expand Up @@ -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:
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 10 additions & 4 deletions dssi-vst-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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");

Expand Down
21 changes: 18 additions & 3 deletions dssi-vst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion remotevstclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ RemoteVSTClient::queryPlugins(std::vector<PluginRecord> &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));
Expand Down
1 change: 1 addition & 0 deletions remotevstclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class RemoteVSTClient : public RemotePluginClient
int outputs;
int parameters;
std::vector<std::string> parameterNames;
std::vector<float> parameterDefaults;
int programs;
std::vector<std::string> programNames;
};
Expand Down

0 comments on commit 4f32a1f

Please sign in to comment.