-
Notifications
You must be signed in to change notification settings - Fork 16
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
Changes from 1 commit
401ce80
3baac1d
b75b213
13210b1
821f018
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ namespace client { | |
namespace loudness { | ||
|
||
enum LoudnessParamIndex { | ||
kSelect, | ||
kKWeighting, | ||
kTruePeak, | ||
kWindowSize, | ||
|
@@ -33,6 +34,7 @@ enum LoudnessParamIndex { | |
}; | ||
|
||
constexpr auto LoudnessParams = defineParameters( | ||
ChoicesParam("select","Selection of Outputs","loudness","truepeak"), | ||
EnumParam("kWeighting", "Apply K-Weighting", 1, "Off", "On"), | ||
EnumParam("truePeak", "Compute True Peak", 1, "Off", "On"), | ||
LongParam("windowSize", "Window Size", 1024, UpperLimit<kMaxWindowSize>()), | ||
|
@@ -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); | ||
} | ||
|
||
|
@@ -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>(); } | ||
|
@@ -122,6 +133,8 @@ class LoudnessClient : public FluidBaseClient, public AudioIn, public ControlOut | |
algorithm::Loudness mAlgorithm; | ||
BufferedProcess mBufferedProcess; | ||
FluidTensor<double, 1> mDescriptors; | ||
|
||
index mMaxOutputSize; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is always 2, so no need for a variable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay cool! Less code is good :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in b75b213 |
||
}; | ||
} // namespace loudness | ||
|
||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed - will change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 3baac1d