Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ial issue 16 bypassed automation #52

Merged
merged 6 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,15 @@ void EarVstExportSources::generateAdmAndChna(ReaperAPI const& api)
auto admParameter = (AdmParameter)admParameterIndex;
auto param = pluginSuite->getParameterFor(admParameter);
auto env = getEnvelopeFor(pluginSuite, pluginInst.get(), admParameter, api);

if(param && env) {

if (getEnvelopeBypassed(env, api)) {
// We have an envelope, but it is bypassed
auto val = getValueFor(pluginSuite, pluginInst.get(), admParameter, api);
auto newErrors = cumulatedPointData.useConstantValueForParameter(admParameter, *val);
for (auto& newError : newErrors) {
warningStrings.push_back(newError.what());
}
} else if(param && env) {
// We have an envelope for this ADM parameter
auto newErrors = cumulatedPointData.useEnvelopeDataForParameter(*env, *param, admParameter, api);
for(auto &newError : newErrors) {
Expand Down Expand Up @@ -356,6 +363,27 @@ std::optional<double> EarVstExportSources::getValueFor(std::shared_ptr<admplug::
return std::optional<double>();
}

bool EarVstExportSources::getEnvelopeBypassed(TrackEnvelope* env, ReaperAPI const& api)
{
bool envBypassed = false;
if(env) {
char chunk[1024]; // For a plugin parameter (PARMENV) the ACT flag should always be within the first couple bytes of the state chunk
bool getRes = api.GetEnvelopeStateChunk(env, chunk, 1024, false);
if (getRes) {
std::istringstream chunkSs(chunk);
std::string line;
while (std::getline(chunkSs, line)) {
auto activePos = line.rfind("ACT ", 0);
if ((activePos != std::string::npos) && (line.size() > (activePos + 4))) {
envBypassed = line.at(activePos + 4) == '0';
break;
}
}
}
}
return envBypassed;
}

std::vector<std::shared_ptr<PluginInstance>> EarVstExportSources::getEarInputPluginsWithTrackMapping(int trackMapping, ReaperAPI const& api)
{
std::vector<std::shared_ptr<PluginInstance>> insts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,5 @@ class EarVstExportSources : public IExportSources
std::vector<std::shared_ptr<PluginInstance>> getEarInputPluginsWithTrackMapping(int trackMapping, ReaperAPI const& api);
TrackEnvelope* getEnvelopeFor(std::shared_ptr<admplug::PluginSuite> pluginSuite, PluginInstance * pluginInst, AdmParameter admParameter, ReaperAPI const & api);
std::optional<double> getValueFor(std::shared_ptr<admplug::PluginSuite> pluginSuite, PluginInstance * pluginInst, AdmParameter admParameter, ReaperAPI const & api);

bool getEnvelopeBypassed(TrackEnvelope* env, ReaperAPI const& api);
};