27 PulseWidth(l10n::String name, l10n::String title_format_str, int32_t newP, uint8_t source_id)
28 : PatchedParam(name, newP, source_id), FormattedTitle(title_format_str, source_id + 1) {}
30 [[nodiscard]] std::string_view
getTitle()
const override {
return FormattedTitle::title(); }
32 int32_t getFinalValue()
override {
return computeFinalValueForHalfPrecisionMenuItem(this->getValue()); }
35 this->setValue(computeCurrentValueForHalfPrecisionMenuItem(
36 soundEditor.currentParamManager->getPatchedParamSet()->getValue(getP())));
40 const auto sound =
static_cast<Sound*
>(modControllable);
41 if (sound->getSynthMode() == SynthMode::FM) {
45 const OscType oscType = sound->sources[source_id_].oscType;
46 if (oscType == OscType::WAVETABLE) {
47 auto& source = sound->sources[source_id_];
48 return source.hasAtLeastOneAudioFileLoaded();
51 return oscType != OscType::SAMPLE && oscType != OscType::INPUT_L && oscType != OscType::INPUT_R
52 && oscType != OscType::INPUT_STEREO;
55 void renderInHorizontalMenu(int32_t startX, int32_t width, int32_t startY, int32_t height)
override {
58 const float valueNormalized = getValue() / 50.0f;
60 constexpr int32_t xPadding = 4;
61 width -= xPadding * 2 + 1;
63 int32_t xStart = startX + xPadding;
64 int32_t xEnd = xStart + width;
65 int32_t yStart = startY + 3;
66 int32_t yEnd = startY + height - 5;
68 int32_t pwMinX = xStart + 2;
69 int32_t pwMaxX = xStart + width / 2;
70 int32_t pwWidth = pwMaxX - pwMinX;
71 int32_t pwX = pwMaxX - pwWidth * valueNormalized;
73 image.drawVerticalLine(xStart, yStart, yEnd);
74 image.drawHorizontalLine(yStart, xStart, pwX);
75 image.drawVerticalLine(pwX, yStart, yEnd);
76 image.drawHorizontalLine(yEnd, pwX, xEnd);