Skip to content

Commit

Permalink
Merge pull request #2 from consolegrl/slicert-style
Browse files Browse the repository at this point in the history
Minor style + Text margin fix
  • Loading branch information
DanielKauss authored Oct 10, 2023
2 parents 3e0419f + 611884a commit e202dec
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 29 deletions.
2 changes: 1 addition & 1 deletion plugins/SlicerT/SlicerT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ void SlicerT::loadSettings(const QDomElement& element)
m_noteThreshold.loadSettings(element, "threshold");
m_originalBPM.loadSettings(element, "origBPM");

// create dinamic buffer
// create dynamic buffer
float speedRatio = (float)m_originalBPM.value() / Engine::getSong()->getTempo();
m_phaseVocoder.loadSample(
m_originalSample.data(), m_originalSample.frames(), m_originalSample.sampleRate(), speedRatio);
Expand Down
13 changes: 8 additions & 5 deletions plugins/SlicerT/SlicerT.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ class PhaseVocoder
};

// simple helper class that handles the different audio channels
class dinamicPlaybackBuffer
class DynamicPlaybackBuffer
{
public:
dinamicPlaybackBuffer()
DynamicPlaybackBuffer()
: m_leftChannel()
, m_rightChannel()
{
}
{}

void loadSample(const sampleFrame* outData, int frames, int sampleRate, float newRatio)
{
std::vector<float> leftData(frames, 0);
Expand All @@ -119,6 +119,7 @@ class dinamicPlaybackBuffer
m_leftChannel.loadData(leftData, sampleRate, newRatio);
m_rightChannel.loadData(rightData, sampleRate, newRatio);
}

void getFrames(sampleFrame* outData, int startFrame, int frames)
{
std::vector<float> leftOut(frames, 0); // not a huge performance issue
Expand All @@ -133,8 +134,10 @@ class dinamicPlaybackBuffer
outData[i][1] = rightOut[i];
}
}

int frames() { return m_leftChannel.frames(); }
float scaleRatio() { return m_leftChannel.scaleRatio(); }

void setScaleRatio(float newRatio)
{
m_leftChannel.setScaleRatio(newRatio);
Expand Down Expand Up @@ -181,7 +184,7 @@ public slots:

// sample buffers
SampleBuffer m_originalSample;
dinamicPlaybackBuffer m_phaseVocoder;
DynamicPlaybackBuffer m_phaseVocoder;

std::vector<int> m_slicePoints;

Expand Down
42 changes: 23 additions & 19 deletions plugins/SlicerT/SlicerTUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ SlicerTUI::SlicerTUI(SlicerT* instrument, QWidget* parent)

// render background
QPalette pal;
pal.setBrush(backgroundRole(), PLUGIN_NAME::getIconPixmap("bg"));
pal.setBrush(backgroundRole(), PLUGIN_NAME::getIconPixmap("artwork"));
setPalette(pal);

// move editor and seeker
m_wf.move(2, 6);

// snap combo box
m_snapSetting.setGeometry(190, 200, 55, ComboBox::DEFAULT_HEIGHT);
m_snapSetting.setGeometry(185, 200, 55, ComboBox::DEFAULT_HEIGHT);
m_snapSetting.setToolTip(tr("Set slice snapping for detection"));
m_snapSetting.setModel(&m_slicerTParent->m_sliceSnap);

Expand All @@ -76,32 +76,32 @@ SlicerTUI::SlicerTUI(SlicerT* instrument, QWidget* parent)
m_syncToggle.setModel(&m_slicerTParent->m_enableSync);

// bpm spin box
m_bpmBox.move(135, 203);
m_bpmBox.move(130, 203);
m_bpmBox.setToolTip(tr("Original sample BPM"));
m_bpmBox.setLabel(tr("BPM"));
m_bpmBox.setModel(&m_slicerTParent->m_originalBPM);

// threshold knob
m_noteThresholdKnob.move(14, 195);
m_noteThresholdKnob.move(9, 195);
m_noteThresholdKnob.setToolTip(tr("Threshold used for slicing"));
m_noteThresholdKnob.setLabel(tr("Threshold"));
m_noteThresholdKnob.setModel(&m_slicerTParent->m_noteThreshold);

// fadeout knob
m_fadeOutKnob.move(80, 195);
m_fadeOutKnob.setToolTip(tr("FadeOut for notes"));
m_fadeOutKnob.setLabel(tr("FadeOut"));
m_fadeOutKnob.move(75, 195);
m_fadeOutKnob.setToolTip(tr("Fade Out for notes"));
m_fadeOutKnob.setLabel(tr("Fade Out"));
m_fadeOutKnob.setModel(&m_slicerTParent->m_fadeOutFrames);

// midi copy button
m_midiExportButton.move(205, 155);
m_midiExportButton.move(215, 150);
m_midiExportButton.setActiveGraphic(PLUGIN_NAME::getIconPixmap("copyMidi"));
m_midiExportButton.setInactiveGraphic(PLUGIN_NAME::getIconPixmap("copyMidi"));
m_midiExportButton.setToolTip(tr("Copy midi pattern to clipboard"));
connect(&m_midiExportButton, SIGNAL(clicked()), this, SLOT(exportMidi()));

// slcie reset button
m_resetButton.move(25, 155);
// slice reset button
m_resetButton.move(19, 150);
m_resetButton.setActiveGraphic(PLUGIN_NAME::getIconPixmap("resetSlices"));
m_resetButton.setInactiveGraphic(PLUGIN_NAME::getIconPixmap("resetSlices"));
m_resetButton.setToolTip(tr("Reset Slices"));
Expand Down Expand Up @@ -145,8 +145,14 @@ void SlicerTUI::dragEnterEvent(QDragEnterEvent* dee)
{
dee->acceptProposedAction();
}
else if (txt.section(':', 0, 0) == "samplefile") { dee->acceptProposedAction(); }
else { dee->ignore(); }
else if (txt.section(':', 0, 0) == "samplefile")
{
dee->acceptProposedAction();
}
else
{
dee->ignore();
}
}
else { dee->ignore(); }
}
Expand All @@ -157,10 +163,8 @@ void SlicerTUI::dropEvent(QDropEvent* de)
QString value = StringPairDrag::decodeValue(de);
if (type == "samplefile")
{
m_slicerTParent->updateFile(value);
// castModel<AudioFileProcessor>()->setAudioFile( value );
// de->accept();
// set m_wf wave file
m_slicerTParent->updateFile(value);
return;
}
else if (type == QString("clip_%1").arg(static_cast<int>(Track::Type::Sample)))
Expand All @@ -180,10 +184,10 @@ void SlicerTUI::paintEvent(QPaintEvent* pe)
QPainter brush(this);
brush.setPen(QColor(255, 255, 255));
brush.setFont(QFont(brush.font().family(), 7.5f, -1, false));
brush.drawText(205, 170, 20, 20, Qt::AlignCenter, tr("Midi"));
brush.drawText(22, 170, 25, 20, Qt::AlignCenter, tr("Reset"));
brush.drawText(190, 217, 55, 20, Qt::AlignCenter, tr("Snap"));
brush.drawText(212, 165, 25, 20, Qt::AlignCenter, tr("Midi"));
brush.drawText(14, 165, 30, 20, Qt::AlignCenter, tr("Reset"));
brush.drawText(185, 217, 55, 20, Qt::AlignCenter, tr("Snap"));
}

} // namespace gui
} // namespace lmms
} // namespace lmms
6 changes: 3 additions & 3 deletions plugins/SlicerT/SlicerTUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class SlicerTKnob : public Knob
SlicerTKnob(QWidget* _parent)
: Knob(KnobType::Styled, _parent)
{
setFixedSize(46, 40);
setCenterPointX(23.0);
setFixedSize(50, 40);
setCenterPointX(24.0);
setCenterPointY(15.0);
}
};
Expand Down Expand Up @@ -89,4 +89,4 @@ protected slots:
};
} // namespace gui
} // namespace lmms
#endif // SLICERT_UI_H
#endif // SLICERT_UI_H
3 changes: 2 additions & 1 deletion plugins/SlicerT/WaveForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
namespace lmms {

namespace gui {

WaveForm::WaveForm(int w, int h, SlicerT* instrument, QWidget* parent)
: QWidget(parent)
,
Expand Down Expand Up @@ -327,4 +328,4 @@ void WaveForm::paintEvent(QPaintEvent* pe)
p.drawPixmap(0, m_seekerHeight + m_middleMargin, m_sliceEditor);
}
} // namespace gui
} // namespace lmms
} // namespace lmms
Binary file added plugins/SlicerT/artwork.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugins/SlicerT/artwork.xcf
Binary file not shown.
Binary file removed plugins/SlicerT/bg.png
Binary file not shown.

0 comments on commit e202dec

Please sign in to comment.