Skip to content

Commit

Permalink
Show voice count on screen
Browse files Browse the repository at this point in the history
Rearrange the main area a bit too while at it
  • Loading branch information
baconpaul committed Dec 24, 2024
1 parent c55cb19 commit 626b929
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 13 deletions.
7 changes: 3 additions & 4 deletions doc/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ SOURCE:
- 90%-100% of internal nyquist mute fades

MAIN:
- Rotate VU meter to use space
- Put voice count below vU meter along with voice limit editor
- Voice limit in Main Area hooked up
- Voice limit font and split font with menu button from top

MIXER:
- LFO on Mixer Node to level or pan
Expand All @@ -27,12 +27,11 @@ PRESETS:
- preset scan user directory to make tree

PLAY MODE:
- Voice limit count and Voice Count display
- Pitch Bend support
- Portamento maybe
- An envelope retrigger legato more where envelopes are opt-in to retrigger even on gated voices

GENERAL AND CLEANUPS
- Temposync the LFO
- AM is somehow not quiet right. Signal to zero seems 'no modulation' not 'no output'
- Don't send VU etc when editor not attached
- Edit area says "click a knbo to edit on startup"
Expand Down
6 changes: 6 additions & 0 deletions src/synth/synth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ void Synth::process(const clap_output_events_t *outq)
{
AudioToUIMsg msg{AudioToUIMsg::UPDATE_VU, 0, vuPeak.vu_peak[0], vuPeak.vu_peak[1]};
audioToUi.push(msg);

AudioToUIMsg msg2{AudioToUIMsg::UPDATE_VOICE_COUNT, (uint32_t)voiceCount};
audioToUi.push(msg2);
lastVuUpdate = 0;
}
else
Expand All @@ -117,6 +120,7 @@ void Synth::addToVoiceList(Voice *v)
v->next->prior = v;
}
head = v;
voiceCount++;
}

Voice *Synth::removeFromVoiceList(Voice *cvoice)
Expand All @@ -138,6 +142,8 @@ Voice *Synth::removeFromVoiceList(Voice *cvoice)
cvoice->fadeBlocks = -1;
cvoice->next = nullptr;
cvoice->prior = nullptr;

voiceCount--;
return nv;
}

Expand Down
2 changes: 2 additions & 0 deletions src/synth/synth.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct Synth
void addToVoiceList(Voice *);
Voice *removeFromVoiceList(Voice *); // returns next
void dumpVoiceList();
int voiceCount{0};

struct VMResponder
{
Expand Down Expand Up @@ -179,6 +180,7 @@ struct Synth
{
UPDATE_PARAM,
UPDATE_VU,
UPDATE_VOICE_COUNT
} action;
uint32_t paramId{0};
float value{0}, value2{0};
Expand Down
42 changes: 33 additions & 9 deletions src/ui/main-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,33 @@ MainPanel::MainPanel(SixSinesEditor &e) : jcmp::NamedPanel("Main"), HasEditor(e)
lev->setDrawLabel(false);
addAndMakeVisible(*lev);
levLabel = std::make_unique<jcmp::Label>();
levLabel->setText("Main Level");
levLabel->setText("Level");
addAndMakeVisible(*levLabel);

vuMeter = std::make_unique<jcmp::VUMeter>(jcmp::VUMeter::VERTICAL);
vuMeter = std::make_unique<jcmp::VUMeter>(jcmp::VUMeter::HORIZONTAL);
addAndMakeVisible(*vuMeter);

voiceCount = std::make_unique<jcmp::Label>();
voiceCount->setJustification(juce::Justification::centredLeft);
addAndMakeVisible(*voiceCount);
setVoiceCount(0);

vcOf = std::make_unique<jcmp::Label>();
vcOf->setText("/");
vcOf->setJustification(juce::Justification::centredRight);
addAndMakeVisible(*vcOf);

voiceLimit = std::make_unique<jcmp::MenuButton>();
voiceLimit->setLabel("64");
voiceLimit->setOnCallback(
[this]()
{
auto p = juce::PopupMenu();
p.addSectionHeader("Coming Soon");
p.showMenuAsync(juce::PopupMenu::Options().withParentComponent(&editor));
});
addAndMakeVisible(*voiceLimit);

highlight = std::make_unique<KnobHighlight>();
addChildComponent(*highlight);
}
Expand All @@ -41,12 +62,15 @@ void MainPanel::resized()
{
auto b = getContentArea().reduced(uicMargin, 0);

b = juce::Rectangle<int>(b.getX(), b.getY(), uicKnobSize + uicPowerButtonSize + uicMargin,
uicKnobSize);
lev->setBounds(b.withTrimmedLeft(uicPowerButtonSize + uicMargin));
vuMeter->setBounds(
b.withWidth(uicPowerButtonSize).withTrimmedRight(2).withTrimmedTop(2).withTrimmedLeft(2));
levLabel->setBounds(b.translated(0, uicKnobSize + uicLabelGap).withHeight(uicLabelHeight));
positionKnobAndLabel(b.getX(), b.getY(), lev, levLabel);

auto vum = b.withTrimmedLeft(uicKnobSize + 2 * uicMargin).withHeight(b.getHeight() / 3);
vuMeter->setBounds(vum);

auto lp = vum.translated(0, vum.getHeight() + uicMargin);
voiceCount->setBounds(lp);
vcOf->setBounds(lp.withTrimmedRight(vum.getWidth() * 0.6));
voiceLimit->setBounds(lp.withTrimmedLeft(vum.getWidth() * 0.4 + uicMargin));
}

void MainPanel::beginEdit()
Expand All @@ -58,7 +82,7 @@ void MainPanel::beginEdit()

highlight->setVisible(true);
auto b = getContentArea().reduced(uicMargin, 0);
highlight->setBounds(b.getX(), b.getY(), uicPowerKnobWidth + 2, uicLabeledKnobHeight);
highlight->setBounds(b.getX(), b.getY(), uicKnobSize + uicMargin, uicLabeledKnobHeight);
highlight->toBack();
}

Expand Down
4 changes: 4 additions & 0 deletions src/ui/main-panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ struct MainPanel : jcmp::NamedPanel, HasEditor
std::unique_ptr<jcmp::Knob> lev;
std::unique_ptr<jcmp::Label> levLabel;
std::unique_ptr<jcmp::VUMeter> vuMeter;

void setVoiceCount(int vc) { voiceCount->setText("v: " + std::to_string(vc)); }
std::unique_ptr<jcmp::Label> voiceCount, vcOf;
std::unique_ptr<jcmp::MenuButton> voiceLimit;
};
} // namespace baconpaul::six_sines::ui
#endif // MAIN_PANEL_H
5 changes: 5 additions & 0 deletions src/ui/six-sines-editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ void SixSinesEditor::idle()
{
mainPanel->vuMeter->setLevels(aum->value, aum->value2);
}
else if (aum->action == Synth::AudioToUIMsg::UPDATE_VOICE_COUNT)
{
mainPanel->setVoiceCount(aum->paramId);
mainPanel->repaint();
}
aum = audioToUI.pop();
}
}
Expand Down

0 comments on commit 626b929

Please sign in to comment.