Skip to content

Commit

Permalink
Code review changes
Browse files Browse the repository at this point in the history
Whitespace and formatting.
  • Loading branch information
michaelgregorius committed Apr 4, 2024
1 parent d8b5cf7 commit 5007b8e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 38 deletions.
2 changes: 1 addition & 1 deletion include/EnvelopeGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class EnvelopeGraph : public QWidget, public ModelView
private:
QPixmap m_envGraph = embed::getIconPixmap("envelope_graph");

EnvelopeAndLfoParameters * m_params;
EnvelopeAndLfoParameters* m_params;
};

} // namespace gui
Expand Down
2 changes: 1 addition & 1 deletion include/LfoGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class LfoGraph : public QWidget, public ModelView
private:
QPixmap m_lfoGraph = embed::getIconPixmap("lfo_graph");

EnvelopeAndLfoParameters * m_params;
EnvelopeAndLfoParameters* m_params;

float m_randomGraph {0.};
};
Expand Down
29 changes: 14 additions & 15 deletions src/gui/instrument/EnvelopeAndLfoView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ EnvelopeAndLfoView::EnvelopeAndLfoView(QWidget * parent) :
m_params(nullptr)
{
// Helper lambdas for consistent repeated buiding of certain widgets
auto buildKnob = [&](const QString & label, const QString& hintText)
auto buildKnob = [&](const QString& label, const QString& hintText)
{
auto knob = new Knob(KnobType::Bright26, this);
knob->setLabel(label);
Expand Down Expand Up @@ -138,8 +138,7 @@ EnvelopeAndLfoView::EnvelopeAndLfoView(QWidget * parent) :
auto random_lfo_btn = buildPixmapButton("random_wave_active", "random_wave_inactive");
m_userLfoBtn = buildPixmapButton("usr_wave_active", "usr_wave_inactive");

connect( m_userLfoBtn, SIGNAL(toggled(bool)),
this, SLOT(lfoUserWaveChanged()));
connect(m_userLfoBtn, SIGNAL(toggled(bool)), this, SLOT(lfoUserWaveChanged()));

typesLayout->addWidget(sin_lfo_btn);
typesLayout->addWidget(triangle_lfo_btn);
Expand All @@ -149,12 +148,12 @@ EnvelopeAndLfoView::EnvelopeAndLfoView(QWidget * parent) :
typesLayout->addWidget(m_userLfoBtn);

m_lfoWaveBtnGrp = new automatableButtonGroup(this);
m_lfoWaveBtnGrp->addButton( sin_lfo_btn );
m_lfoWaveBtnGrp->addButton( triangle_lfo_btn );
m_lfoWaveBtnGrp->addButton( saw_lfo_btn );
m_lfoWaveBtnGrp->addButton( sqr_lfo_btn );
m_lfoWaveBtnGrp->addButton( m_userLfoBtn );
m_lfoWaveBtnGrp->addButton( random_lfo_btn );
m_lfoWaveBtnGrp->addButton(sin_lfo_btn);
m_lfoWaveBtnGrp->addButton(triangle_lfo_btn);
m_lfoWaveBtnGrp->addButton(saw_lfo_btn);
m_lfoWaveBtnGrp->addButton(sqr_lfo_btn);
m_lfoWaveBtnGrp->addButton(m_userLfoBtn);
m_lfoWaveBtnGrp->addButton(random_lfo_btn);

QVBoxLayout* knobsAndCheckBoxesLayout = new QVBoxLayout();
lfoLayout->addLayout(knobsAndCheckBoxesLayout);
Expand All @@ -168,9 +167,9 @@ EnvelopeAndLfoView::EnvelopeAndLfoView(QWidget * parent) :
m_lfoAttackKnob = buildKnob(tr("ATT"), tr("Attack:"));
lfoKnobsLayout->addWidget(m_lfoAttackKnob);

m_lfoSpeedKnob = new TempoSyncKnob( KnobType::Bright26, this );
m_lfoSpeedKnob->setLabel( tr("SPD") );
m_lfoSpeedKnob->setHintText( tr("Frequency:"), "");
m_lfoSpeedKnob = new TempoSyncKnob(KnobType::Bright26, this);
m_lfoSpeedKnob->setLabel(tr("SPD"));
m_lfoSpeedKnob->setHintText(tr("Frequency:"), "");
lfoKnobsLayout->addWidget(m_lfoSpeedKnob);

m_lfoAmountKnob = buildKnob(tr("AMT"), tr("Modulation amount:"));
Expand All @@ -179,15 +178,15 @@ EnvelopeAndLfoView::EnvelopeAndLfoView(QWidget * parent) :
QVBoxLayout* checkBoxesLayout = new QVBoxLayout();
knobsAndCheckBoxesLayout->addLayout(checkBoxesLayout);

m_x100Cb = new LedCheckBox( tr("FREQ x 100"), this );
m_x100Cb = new LedCheckBox(tr("FREQ x 100"), this);
m_x100Cb->setToolTip(tr("Multiply LFO frequency by 100"));
checkBoxesLayout->addWidget(m_x100Cb);

m_controlEnvAmountCb = new LedCheckBox(tr("MOD ENV AMOUNT"), this);
m_controlEnvAmountCb->setToolTip( tr("Control envelope amount by this LFO") );
m_controlEnvAmountCb->setToolTip(tr("Control envelope amount by this LFO"));
checkBoxesLayout->addWidget(m_controlEnvAmountCb);

setAcceptDrops( true );
setAcceptDrops(true);
}


Expand Down
2 changes: 1 addition & 1 deletion src/gui/instrument/InstrumentSoundShapingView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ InstrumentSoundShapingView::InstrumentSoundShapingView(QWidget* parent) :
{
m_envLfoViews[i] = new EnvelopeAndLfoView(m_targetsTabWidget);
m_targetsTabWidget->addTab(m_envLfoViews[i],
tr(InstrumentSoundShaping::targetNames[i][0]), nullptr);
tr(InstrumentSoundShaping::targetNames[i][0]), nullptr);
}

mainLayout->addWidget(m_targetsTabWidget, 1);
Expand Down
31 changes: 11 additions & 20 deletions src/gui/instrument/LfoGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,8 @@ void LfoGraph::paintEvent(QPaintEvent*)
// Draw the graph background
p.drawPixmap(rect(), m_lfoGraph);

const auto * params = castModel<EnvelopeAndLfoParameters>();
if (!params)
{
return;
}
const auto* params = castModel<EnvelopeAndLfoParameters>();
if (!params) { return; }

const float amount = params->getLfoAmountModel().value();
const float lfoSpeed = params->getLfoSpeedModel().value();
Expand All @@ -89,19 +86,19 @@ void LfoGraph::paintEvent(QPaintEvent*)
int graph_x_base = 2;
int graph_y_base = 3 + LFO_GRAPH_H / 2;

const float frames_for_graph = SECS_PER_LFO_OSCILLATION *
Engine::audioEngine()->baseSampleRate() / 10;
const float frames_for_graph =
SECS_PER_LFO_OSCILLATION * Engine::audioEngine()->baseSampleRate() / 10;

const float gray = 1.0 - fabsf(amount);
const QColor penColor(static_cast<int>(96 * gray), static_cast<int>(255 - 159 * gray), static_cast<int>(128 - 32 * gray));
const auto red = static_cast<int>(96 * gray);
const auto green = static_cast<int>(255 - 159 * gray);
const auto blue = static_cast<int>(128 - 32 * gray);
const QColor penColor(red, green, blue);
p.setPen(QPen(penColor, 1.5));

float osc_frames = oscillationFrames;

if (x100)
{
osc_frames *= 100.0f;
}
if (x100) { osc_frames *= 100.0f; }

float old_y = 0;
for (int x = 0; x <= LFO_GRAPH_W; ++x)
Expand Down Expand Up @@ -163,14 +160,8 @@ void LfoGraph::toggleAmountModel()
{
auto* params = castModel<EnvelopeAndLfoParameters>();
auto& lfoAmountModel = params->getLfoAmountModel();
if (lfoAmountModel.value() < 1.0)
{
lfoAmountModel.setValue(1.0);
}
else
{
lfoAmountModel.setValue(0.0);
}

lfoAmountModel.setValue(lfoAmountModel.value() < 1.0 ? 1.0 : 0.0);
}

} // namespace gui
Expand Down

0 comments on commit 5007b8e

Please sign in to comment.