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

Expand the AudioPorts display #40

Merged
merged 1 commit into from
Mar 22, 2024
Merged
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
48 changes: 47 additions & 1 deletion src/clap-info/info-ports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ Json::Value createAudioPortsJson(const clap_plugin *inst)
outPorts = inst_ports->count(inst, false);
audioPorts["output-port-count"] = outPorts;

auto makeFlags = [](const auto &p) {
Json::Value flag;
flag["value"] = p;
Json::Value desc;

#define ADDF(x) \
if (p & x) \
{ \
desc.append(#x); \
}
ADDF(CLAP_AUDIO_PORT_IS_MAIN);
ADDF(CLAP_AUDIO_PORT_SUPPORTS_64BITS);
ADDF(CLAP_AUDIO_PORT_PREFERS_64BITS);
ADDF(CLAP_AUDIO_PORT_REQUIRES_COMMON_SAMPLE_SIZE);
#undef ADDF

if (desc.size() != 0)
{
flag["fields"] = desc;
}
return flag;
};

Json::Value inputPorts;
inputPorts.resize(0);
for (int i = 0; i < inPorts; ++i)
Expand All @@ -42,7 +65,18 @@ Json::Value createAudioPortsJson(const clap_plugin *inst)
inst_ports->get(inst, i, true, &inf);
Json::Value inputPort;
inputPort["name"] = inf.name;
inputPort["id"] = inf.id;
inputPort["channel-count"] = inf.channel_count;
if (inf.port_type)
{
inputPort["port-type"] = inf.port_type;
}
inputPort["flags"] = makeFlags(inf.flags);

if (inf.in_place_pair != CLAP_INVALID_ID)
{
inputPort["in-place-pair"] = inf.in_place_pair;
}
inputPorts.append(inputPort);
}
audioPorts["input-ports"] = inputPorts;
Expand All @@ -55,7 +89,19 @@ Json::Value createAudioPortsJson(const clap_plugin *inst)
inst_ports->get(inst, i, false, &inf);
Json::Value outputPort;
outputPort["name"] = inf.name;
outputPort["id"] = inf.id;
outputPort["channel-count"] = inf.channel_count;
if (inf.port_type)
{
outputPort["port-type"] = inf.port_type;
}

outputPort["flags"] = makeFlags(inf.flags);

if (inf.in_place_pair != CLAP_INVALID_ID)
{
outputPort["in-place-pair"] = inf.in_place_pair;
}
outputPorts.append(outputPort);
}
audioPorts["output-ports"] = outputPorts;
Expand Down Expand Up @@ -131,4 +177,4 @@ Json::Value createNotePortsJson(const clap_plugin *inst)
}
return notePorts;
}
} // namespace clap_info_host
} // namespace clap_info_host
Loading