summaryrefslogtreecommitdiff
path: root/src/samplesorter.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-09-10 19:14:11 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-09-10 19:14:11 +0200
commita9e821dc6d7201678d8991f67f090235c29d4ad4 (patch)
treec3d64dc8f689af4ea7831e86456556da2c8749bc /src/samplesorter.cc
parent2c2ab60ee896f5d7c5d8d9ed3a0b0287740df6e6 (diff)
Add 'spreader' slider to generate tab.
Diffstat (limited to 'src/samplesorter.cc')
-rw-r--r--src/samplesorter.cc21
1 files changed, 15 insertions, 6 deletions
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++;
}