Skip to content

Commit 0c25424

Browse files
committed
Merge remote-tracking branch 'upstream' into fix-resampling
2 parents 0b24801 + 7e02795 commit 0c25424

File tree

12 files changed

+55
-123
lines changed

12 files changed

+55
-123
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ jobs:
339339
CCACHE_MAXSIZE: 500M
340340
msvc:
341341
name: msvc-x64
342-
runs-on: windows-2019
342+
runs-on: windows-2022
343343
env:
344344
CCACHE_MAXSIZE: 0
345345
CCACHE_NOCOMPRESS: 1

include/InlineAutomation.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
#include "AutomationNode.h"
2929
#include "AutomationClip.h"
30-
#include "shared_object.h"
3130

3231
namespace lmms
3332
{

include/Note.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,15 @@ class LMMS_EXPORT Note : public SerializingObject
104104
int key = DefaultKey,
105105
volume_t volume = DefaultVolume,
106106
panning_t panning = DefaultPanning,
107-
DetuningHelper * detuning = nullptr );
107+
std::shared_ptr<DetuningHelper> detuning = nullptr);
108108
Note( const Note & note );
109109
~Note() override;
110110

111111
Note& operator=(const Note& note);
112112

113+
//! Performs a deep copy and returns an owning raw pointer
114+
Note* clone() const;
115+
113116
// Note types
114117
enum class Type
115118
{
@@ -237,10 +240,8 @@ class LMMS_EXPORT Note : public SerializingObject
237240

238241
static TimePos quantized( const TimePos & m, const int qGrid );
239242

240-
DetuningHelper * detuning() const
241-
{
242-
return m_detuning.get();
243-
}
243+
const std::shared_ptr<DetuningHelper>& detuning() const { return m_detuning; }
244+
244245
bool hasDetuningInfo() const;
245246
bool withinRange(int tickStart, int tickEnd) const;
246247

@@ -265,7 +266,7 @@ class LMMS_EXPORT Note : public SerializingObject
265266
panning_t m_panning;
266267
TimePos m_length;
267268
TimePos m_pos;
268-
std::unique_ptr<DetuningHelper> m_detuning;
269+
std::shared_ptr<DetuningHelper> m_detuning;
269270

270271
Type m_type = Type::Regular;
271272
};

include/shared_object.h

Lines changed: 0 additions & 89 deletions
This file was deleted.

plugins/SlicerT/SlicerTView.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ SlicerTView::SlicerTView(SlicerT* instrument, QWidget* parent)
7171
m_syncToggle->setToolTip(tr("Enable BPM sync"));
7272
m_syncToggle->setModel(&m_slicerTParent->m_enableSync);
7373

74+
m_clearButton = new PixmapButton(this, tr("Clear all slices"));
75+
m_clearButton->setActiveGraphic(PLUGIN_NAME::getIconPixmap("clear_slices_active"));
76+
m_clearButton->setInactiveGraphic(PLUGIN_NAME::getIconPixmap("clear_slices_inactive"));
77+
m_clearButton->setToolTip(tr("Clear all slices"));
78+
connect(m_clearButton, &PixmapButton::clicked, this, &SlicerTView::clearSlices);
79+
7480
m_bpmBox = new LcdSpinBox(3, "19purple", this);
7581
m_bpmBox->setToolTip(tr("Original sample BPM"));
7682
m_bpmBox->setModel(&m_slicerTParent->m_originalBPM);
@@ -111,6 +117,19 @@ Knob* SlicerTView::createStyledKnob()
111117
return newKnob;
112118
}
113119

120+
// Clear all notes
121+
void SlicerTView::clearSlices()
122+
{
123+
m_slicerTParent->m_slicePoints.clear();
124+
125+
// Points are added to the start (0) and end (1) of the sample,
126+
// so the whole sample can still be copied using MIDI.
127+
m_slicerTParent->m_slicePoints.emplace_back(0);
128+
m_slicerTParent->m_slicePoints.emplace_back(1);
129+
130+
emit m_slicerTParent->dataChanged();
131+
}
132+
114133
// copied from piano roll
115134
void SlicerTView::exportMidi()
116135
{
@@ -261,7 +280,7 @@ void SlicerTView::resizeEvent(QResizeEvent* re)
261280
{
262281
m_y1 = height() - s_bottomBoxOffset;
263282

264-
// left box
283+
// Left box
265284
m_noteThresholdKnob->move(s_x1 - 25, m_y1);
266285
m_fadeOutKnob->move(s_x2 - 25, m_y1);
267286

@@ -271,8 +290,10 @@ void SlicerTView::resizeEvent(QResizeEvent* re)
271290
m_bpmBox->move(s_x5 - 13, m_y1 + 4);
272291
m_snapSetting->move(s_x6 - 8, m_y1 + 3);
273292

274-
// right box
275-
m_syncToggle->move((width() - 100), m_y1 + 5);
293+
// Right box
294+
// For explanation on the choice of constants, look at #7850
295+
m_syncToggle->move((width() - 100), m_y1 - 7);
296+
m_clearButton->move((width() - 100), m_y1 + 17);
276297

277298
m_folderButton->move(width() - 20, height() - s_bottomBoxHeight - s_sampleBoxHeight + 1);
278299

plugins/SlicerT/SlicerTView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class SlicerTView : public InstrumentView
4949
public slots:
5050
void exportMidi();
5151
void openFiles();
52+
void clearSlices();
5253

5354
public:
5455
SlicerTView(SlicerT* instrument, QWidget* parent);
@@ -87,6 +88,7 @@ public slots:
8788
LcdSpinBox* m_bpmBox;
8889
ComboBox* m_snapSetting;
8990
PixmapButton* m_syncToggle;
91+
PixmapButton* m_clearButton;
9092
PixmapButton* m_folderButton;
9193

9294
QPushButton* m_resetButton;
1.13 KB
Loading
1.15 KB
Loading

src/core/Note.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace lmms
3636

3737
Note::Note( const TimePos & length, const TimePos & pos,
3838
int key, volume_t volume, panning_t panning,
39-
DetuningHelper * detuning ) :
39+
std::shared_ptr<DetuningHelper> detuning ) :
4040
m_selected( false ),
4141
m_oldKey(std::clamp(key, 0, NumKeys)),
4242
m_oldPos( pos ),
@@ -46,13 +46,10 @@ Note::Note( const TimePos & length, const TimePos & pos,
4646
m_volume(std::clamp(volume, MinVolume, MaxVolume)),
4747
m_panning(std::clamp(panning, PanningLeft, PanningRight)),
4848
m_length( length ),
49-
m_pos( pos )
49+
m_pos(pos),
50+
m_detuning(std::move(detuning))
5051
{
51-
if (detuning)
52-
{
53-
m_detuning = std::make_unique<DetuningHelper>(*detuning);
54-
}
55-
else
52+
if (!detuning)
5653
{
5754
createDetuning();
5855
}
@@ -73,12 +70,9 @@ Note::Note( const Note & note ) :
7370
m_panning( note.m_panning ),
7471
m_length( note.m_length ),
7572
m_pos( note.m_pos ),
73+
m_detuning(note.m_detuning),
7674
m_type(note.m_type)
7775
{
78-
if (note.m_detuning)
79-
{
80-
m_detuning = std::make_unique<DetuningHelper>(*note.m_detuning);
81-
}
8276
}
8377

8478
Note& Note::operator=(const Note& note)
@@ -94,16 +88,19 @@ Note& Note::operator=(const Note& note)
9488
m_length = note.m_length;
9589
m_pos = note.m_pos;
9690
m_type = note.m_type;
97-
98-
if (note.m_detuning)
99-
{
100-
m_detuning = std::make_unique<DetuningHelper>(*note.m_detuning);
101-
}
91+
m_detuning = note.m_detuning;
10292

10393
return *this;
10494
}
10595

10696

97+
Note* Note::clone() const
98+
{
99+
Note* newNote = new Note(*this);
100+
newNote->m_detuning = std::make_shared<DetuningHelper>(*newNote->m_detuning);
101+
return newNote;
102+
}
103+
107104

108105

109106
Note::~Note()
@@ -234,7 +231,7 @@ void Note::createDetuning()
234231
{
235232
if( m_detuning == nullptr )
236233
{
237-
m_detuning = std::make_unique<DetuningHelper>();
234+
m_detuning = std::make_shared<DetuningHelper>();
238235
(void) m_detuning->automationClip();
239236
m_detuning->setRange( -MaxDetuning, MaxDetuning, 0.5f );
240237
m_detuning->automationClip()->setProgressionType( AutomationClip::ProgressionType::Linear );

src/core/NotePlayHandle.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack,
5454
int midiEventChannel,
5555
Origin origin ) :
5656
PlayHandle( PlayHandle::Type::NotePlayHandle, _offset ),
57-
Note( n.length(), n.pos(), n.key(), n.getVolume(), n.getPanning(), n.detuning() ),
57+
Note(n),
5858
m_pluginData( nullptr ),
5959
m_instrumentTrack( instrumentTrack ),
6060
m_frames( 0 ),
@@ -84,7 +84,7 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack,
8484
lock();
8585
if( hasParent() == false )
8686
{
87-
m_baseDetuning = new BaseDetuning( detuning() );
87+
m_baseDetuning = new BaseDetuning(detuning().get());
8888
m_instrumentTrack->m_processHandles.push_back( this );
8989
}
9090
else

0 commit comments

Comments
 (0)