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

[Enhance] ChoicesParam for LoudnessClient and PitchClient #141

Merged
merged 5 commits into from
May 13, 2022
Merged
Changes from 1 commit
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
25 changes: 19 additions & 6 deletions include/clients/rt/LoudnessClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace client {
namespace loudness {

enum LoudnessParamIndex {
kSelect,
kKWeighting,
kTruePeak,
kWindowSize,
Expand All @@ -33,6 +34,7 @@ enum LoudnessParamIndex {
};

constexpr auto LoudnessParams = defineParameters(
ChoicesParam("select","Selection of Outputs","loudness","truepeak"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't always true peak, so should probably just say peak

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed - will change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in 3baac1d

EnumParam("kWeighting", "Apply K-Weighting", 1, "Off", "On"),
EnumParam("truePeak", "Compute True Peak", 1, "Off", "On"),
LongParam("windowSize", "Window Size", 1024, UpperLimit<kMaxWindowSize>()),
Expand Down Expand Up @@ -61,13 +63,13 @@ class LoudnessClient : public FluidBaseClient, public AudioIn, public ControlOut
static constexpr auto& getParameterDescriptors() { return LoudnessParams; }

LoudnessClient(ParamSetViewType& p)
: mParams(p), mAlgorithm{get<kMaxWindowSize>()}
: mParams(p), mAlgorithm{get<kMaxWindowSize>()},
mMaxOutputSize{asSigned(get<kSelect>().count())}
{
audioChannelsIn(1);
controlChannelsOut({1,2});
controlChannelsOut({1,mMaxOutputSize});
setInputLabels({"audio input"});
setOutputLabels({"loudness and peak amplitude"});

mDescriptors = FluidTensor<double, 1>(2);
}

Expand Down Expand Up @@ -98,9 +100,18 @@ class LoudnessClient : public FluidBaseClient, public AudioIn, public ControlOut
get<kKWeighting>() == 1,
get<kTruePeak>() == 1);
});
// output[0](0) = static_cast<T>(mDescriptors(0));
// output[1](0) = static_cast<T>(mDescriptors(1));
output[0] <<= mDescriptors;

auto selection = get<kSelect>();
index numSelected = asSigned(selection.count());
index numOuts = std::min<index>(mMaxOutputSize,numSelected);

for(index i = 0, j = 0 ; i < 2 && j < numOuts; ++i)
{
if(selection[asUnsigned(i)]) output[0](j++) = static_cast<T>(mDescriptors(i));
}
if(mMaxOutputSize > numSelected)
for(index i = (mMaxOutputSize - numSelected); i < mMaxOutputSize; ++i)
output[0](i) = 0;
}

index latency() { return get<kWindowSize>(); }
Expand All @@ -122,6 +133,8 @@ class LoudnessClient : public FluidBaseClient, public AudioIn, public ControlOut
algorithm::Loudness mAlgorithm;
BufferedProcess mBufferedProcess;
FluidTensor<double, 1> mDescriptors;

index mMaxOutputSize;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is always 2, so no need for a variable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay cool! Less code is good :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in b75b213

};
} // namespace loudness

Expand Down