summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cc7
-rw-r--r--src/mainwindow.h1
-rw-r--r--src/samplesorter.cc21
-rw-r--r--src/samplesorter.h4
-rw-r--r--src/selectioneditor.cc2
5 files changed, 29 insertions, 6 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 05562b6..59fc26a 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -343,6 +343,13 @@ QWidget *MainWindow::createGenerateTab()
tool_selections, SLOT(autoCreateSelectionsPreview()));
slider_attacklength->setValue(300);
+ slider_spread = createAttribute(w, "Power spread:", 1, 2000);
+ connect(slider_spread, SIGNAL(valueChanged(int)),
+ sorter, SLOT(setSpreadFactor(int)));
+ connect(slider_spread, SIGNAL(valueChanged(int)),
+ tool_selections, SLOT(autoCreateSelectionsPreview()));
+ slider_spread->setValue(1000);
+
slider_hold = createAttribute(w, "Minimum size (samples):", 0, 200000);
connect(slider_hold, SIGNAL(valueChanged(int)),
tool_selections, SLOT(holdChanged(int)));
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 69a4c5e..b512f50 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -107,6 +107,7 @@ private:
QScrollBar *sb_playsamples;
QComboBox *presets;
QSlider *slider_attacklength;
+ QSlider *slider_spread;
QSlider *slider_hold;
QSlider *slider_falloff;
QSlider *slider_fadelength;
diff --git a/src/samplesorter.cc b/src/samplesorter.cc
index 00139e2..c32030a 100644
--- a/src/samplesorter.cc
+++ b/src/samplesorter.cc
@@ -46,6 +46,8 @@ SampleSorter::SampleSorter(Selections &s, Selections &p)
attlen = 666; // Magical constants needs biblical proportions...
sel_moving = SEL_NONE;
+
+ setSpreadFactor(1000);
}
void SampleSorter::setShowPreview(bool s)
@@ -66,6 +68,13 @@ int SampleSorter::attackLength()
return attlen;
}
+void SampleSorter::setSpreadFactor(int s)
+{
+ spread = (double)s / 1000.0;
+ spread *= spread;
+ relayout();
+}
+
void SampleSorter::setAttackLength(int len)
{
attlen = len;
@@ -84,7 +93,7 @@ void SampleSorter::addSelection(sel_id_t id)
energy += data[idx] * data[idx];
}
- s.energy = energy;
+ s.energy = pow(energy, spread);
selections.update(id, s);
relayout();
@@ -102,7 +111,7 @@ void SampleSorter::addSelectionPreview(sel_id_t id)
energy += data[idx] * data[idx];
}
- s.energy = energy;
+ s.energy = pow(energy, spread);
selections_preview.update(id, s);
relayout();
@@ -179,9 +188,9 @@ void SampleSorter::paintEvent(QPaintEvent *event)
Selection sel = selections.get(*i);
if(*i == selections.active()) painter.setPen(colPtSel);
else painter.setPen(colPt);
- float x = sel.energy / max;
+ float x = (sel.energy / max);
x = sqrt(x);
- x *= (float)width();
+ x *= (float)width() * 0.9;
drawCircle(painter, x, MAP(x));
i++;
}
@@ -193,9 +202,9 @@ void SampleSorter::paintEvent(QPaintEvent *event)
while(i != ids.end()) {
Selection sel = selections_preview.get(*i);
painter.setPen(colPtPreview);
- float x = sel.energy / max;
+ float x = (sel.energy / max);
x = sqrt(x);
- x *= (float)width();
+ x *= (float)width() * 0.9;
drawCircle(painter, x, MAP(x));
i++;
}
diff --git a/src/samplesorter.h b/src/samplesorter.h
index ada7fd8..ed86b9d 100644
--- a/src/samplesorter.h
+++ b/src/samplesorter.h
@@ -48,6 +48,8 @@ public slots:
void setShowPreview(bool show_preview);
+ void setSpreadFactor(int spread);
+
protected:
void paintEvent(QPaintEvent *event);
void mouseMoveEvent(QMouseEvent *event);
@@ -73,6 +75,8 @@ private:
Selection sel;
sel_id_t sel_moving;
+
+ double spread;
};
#endif/*__DRUMGIZMO_SAMPLESORTER_H__*/
diff --git a/src/selectioneditor.cc b/src/selectioneditor.cc
index e8db104..5f3057b 100644
--- a/src/selectioneditor.cc
+++ b/src/selectioneditor.cc
@@ -60,6 +60,8 @@ SelectionEditor::SelectionEditor(Selections &s)
fadeout = createWidget("FadeOut:", this);
energy = createWidget("Energy:", this);
name = createWidget("Name:", this);
+
+ ((QHBoxLayout *)layout())->addStretch();
}
void SelectionEditor::updateSelection()