summaryrefslogtreecommitdiff
path: root/src/instrumentwidget.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/instrumentwidget.cc')
-rw-r--r--src/instrumentwidget.cc114
1 files changed, 57 insertions, 57 deletions
diff --git a/src/instrumentwidget.cc b/src/instrumentwidget.cc
index 6a2e17e..9aeb7ee 100644
--- a/src/instrumentwidget.cc
+++ b/src/instrumentwidget.cc
@@ -51,7 +51,7 @@
#include "canvastool.h"
#include "canvastoolthreshold.h"
#include "volumefader.h"
-#include "selectioneditor.h"
+#include "rangeeditor.h"
#include "zoomslider.h"
#include "settings.h"
#include "project.h"
@@ -76,8 +76,8 @@ InstrumentWidget::InstrumentWidget(Settings& settings, Instrument& instrument)
{
int start = 44100 * 60;
- Selection p(start, start + 44100 * 60, 0, 0); // one minute selection
- selections_preview.add(p);
+ Range p(start, start + 44100 * 60, 0, 0); // one minute range
+ ranges_preview.add(p);
}
QWidget* central = new QWidget();
@@ -94,30 +94,30 @@ InstrumentWidget::InstrumentWidget(Settings& settings, Instrument& instrument)
addTool(toolbar, canvaswidget->canvas, listen);
threshold = new CanvasToolThreshold(canvaswidget->canvas, instrument);
canvaswidget->canvas->tools.push_back(threshold);
- tool_selections = new CanvasToolSelections(canvaswidget->canvas, selections,
- selections_preview);
+ tool_ranges = new CanvasToolRanges(canvaswidget->canvas, ranges,
+ ranges_preview);
connect(threshold, SIGNAL(thresholdChanged(double)),
- tool_selections, SLOT(thresholdChanged(double)));
+ tool_ranges, SLOT(thresholdChanged(double)));
connect(threshold, SIGNAL(thresholdChanging(double)),
- tool_selections, SLOT(thresholdChanged(double)));
- connect(&selections, SIGNAL(activeChanged(sel_id_t)),
+ tool_ranges, SLOT(thresholdChanged(double)));
+ connect(&ranges, SIGNAL(activeChanged(sel_id_t)),
canvaswidget->canvas, SLOT(update()));
- connect(&selections, SIGNAL(updated(sel_id_t)),
+ connect(&ranges, SIGNAL(updated(sel_id_t)),
canvaswidget->canvas, SLOT(update()));
- addTool(toolbar, canvaswidget->canvas, tool_selections);
-
- sorter = new SampleSorter(selections, selections_preview, instrument);
- connect(&selections, SIGNAL(added(sel_id_t)),
- sorter, SLOT(addSelection(sel_id_t)));
- connect(&selections_preview, SIGNAL(added(sel_id_t)),
- sorter, SLOT(addSelectionPreview(sel_id_t)));
- connect(&selections, SIGNAL(updated(sel_id_t)), sorter, SLOT(relayout()));
- connect(&selections_preview, SIGNAL(updated(sel_id_t)),
+ addTool(toolbar, canvaswidget->canvas, tool_ranges);
+
+ sorter = new SampleSorter(ranges, ranges_preview, instrument);
+ connect(&ranges, SIGNAL(added(sel_id_t)),
+ sorter, SLOT(addRange(sel_id_t)));
+ connect(&ranges_preview, SIGNAL(added(sel_id_t)),
+ sorter, SLOT(addRangePreview(sel_id_t)));
+ connect(&ranges, SIGNAL(updated(sel_id_t)), sorter, SLOT(relayout()));
+ connect(&ranges_preview, SIGNAL(updated(sel_id_t)),
sorter, SLOT(relayout()));
- connect(&selections, SIGNAL(removed(sel_id_t)), sorter, SLOT(relayout()));
- connect(&selections_preview, SIGNAL(removed(sel_id_t)),
+ connect(&ranges, SIGNAL(removed(sel_id_t)), sorter, SLOT(relayout()));
+ connect(&ranges_preview, SIGNAL(removed(sel_id_t)),
sorter, SLOT(relayout()));
- connect(&selections, SIGNAL(activeChanged(sel_id_t)),
+ connect(&ranges, SIGNAL(activeChanged(sel_id_t)),
sorter, SLOT(relayout()));
QPushButton* btn_playsamples = new QPushButton(tr("Play samples"));
@@ -168,8 +168,8 @@ InstrumentWidget::InstrumentWidget(Settings& settings, Instrument& instrument)
canvaswidget->xscale->setValue(0);
canvaswidget->xoffset->setValue(0);
- // Update selections according to threshold
- tool_selections->thresholdChanged(instrument.getThreshold());
+ // Update ranges according to threshold
+ tool_ranges->thresholdChanged(instrument.getThreshold());
}
InstrumentWidget::~InstrumentWidget()
@@ -178,9 +178,9 @@ InstrumentWidget::~InstrumentWidget()
void InstrumentWidget::tabChanged(int tabid)
{
- tool_selections->setShowPreview(tabid == generateTabId);
+ tool_ranges->setShowPreview(tabid == generateTabId);
sorter->setShowPreview(tabid == generateTabId);
- tool_selections->autoCreateSelectionsPreview();
+ tool_ranges->autoCreateRangesPreview();
threshold->setActive(tabid == generateTabId);
}
@@ -211,26 +211,26 @@ QWidget* InstrumentWidget::createFilesTab()
QWidget* InstrumentWidget::createEditTab()
{
- selections = instrument.getSelections();
- SelectionEditor* se = new SelectionEditor(selections, instrument);
+ ranges = instrument.getRanges();
+ RangeEditor* se = new RangeEditor(ranges, instrument);
- connect(&selections, SIGNAL(added(sel_id_t)), se, SLOT(added(sel_id_t)));
- connect(&selections, SIGNAL(updated(sel_id_t)), se, SLOT(updated(sel_id_t)));
- connect(&selections, SIGNAL(removed(sel_id_t)), se, SLOT(removed(sel_id_t)));
- connect(&selections, SIGNAL(activeChanged(sel_id_t)),
+ connect(&ranges, SIGNAL(added(sel_id_t)), se, SLOT(added(sel_id_t)));
+ connect(&ranges, SIGNAL(updated(sel_id_t)), se, SLOT(updated(sel_id_t)));
+ connect(&ranges, SIGNAL(removed(sel_id_t)), se, SLOT(removed(sel_id_t)));
+ connect(&ranges, SIGNAL(activeChanged(sel_id_t)),
se, SLOT(activeChanged(sel_id_t)));
- connect(&selections, SIGNAL(added(sel_id_t)), this, SLOT(selectionChanged()));
- connect(&selections, SIGNAL(updated(sel_id_t)), this, SLOT(selectionChanged()));
- connect(&selections, SIGNAL(removed(sel_id_t)), this, SLOT(selectionChanged()));
- connect(&selections, SIGNAL(activeChanged(sel_id_t)), this, SLOT(selectionChanged()));
+ connect(&ranges, SIGNAL(added(sel_id_t)), this, SLOT(rangeChanged()));
+ connect(&ranges, SIGNAL(updated(sel_id_t)), this, SLOT(rangeChanged()));
+ connect(&ranges, SIGNAL(removed(sel_id_t)), this, SLOT(rangeChanged()));
+ connect(&ranges, SIGNAL(activeChanged(sel_id_t)), this, SLOT(rangeChanged()));
return se;
}
-void InstrumentWidget::selectionChanged()
+void InstrumentWidget::rangeChanged()
{
- instrument.setSelections(selections);
+ instrument.setRanges(ranges);
}
static QSlider* createAttribute(QWidget* parent, QString name,
@@ -271,19 +271,19 @@ QWidget* InstrumentWidget::createGenerateTab()
QPushButton* autosel = new QPushButton();
autosel->setText(tr("Generate"));
connect(autosel, SIGNAL(clicked()),
- tool_selections, SLOT(clearSelections()));
+ tool_ranges, SLOT(clearRanges()));
connect(autosel, SIGNAL(clicked()),
- tool_selections, SLOT(autoCreateSelections()));
+ tool_ranges, SLOT(autoCreateRanges()));
connect(threshold, SIGNAL(thresholdChanged(double)),
- tool_selections, SLOT(autoCreateSelectionsPreview()));
+ tool_ranges, SLOT(autoCreateRangesPreview()));
connect(threshold, SIGNAL(thresholdChanging(double)),
- tool_selections, SLOT(autoCreateSelectionsPreview()));
+ tool_ranges, SLOT(autoCreateRangesPreview()));
QPushButton* clearsel = new QPushButton();
clearsel->setText(tr("Clear"));
connect(clearsel, SIGNAL(clicked()),
- tool_selections, SLOT(clearSelections()));
+ tool_ranges, SLOT(clearRanges()));
btns->addWidget(autosel);
btns->addWidget(clearsel);
@@ -294,7 +294,7 @@ QWidget* InstrumentWidget::createGenerateTab()
connect(slider_attacklength, SIGNAL(valueChanged(int)),
sorter, SLOT(setAttackLength(int)));
connect(slider_attacklength, SIGNAL(valueChanged(int)),
- tool_selections, SLOT(autoCreateSelectionsPreview()));
+ tool_ranges, SLOT(autoCreateRangesPreview()));
slider_attacklength->setValue(instrument.getAttackLength());
connect(slider_attacklength, SIGNAL(valueChanged(int)),
this, SLOT(generateSlidersChanged()));
@@ -303,34 +303,34 @@ QWidget* InstrumentWidget::createGenerateTab()
connect(slider_spread, SIGNAL(valueChanged(int)),
sorter, SLOT(setSpreadFactor(int)));
connect(slider_spread, SIGNAL(valueChanged(int)),
- tool_selections, SLOT(autoCreateSelectionsPreview()));
+ tool_ranges, SLOT(autoCreateRangesPreview()));
slider_spread->setValue(instrument.getPowerSpread());
connect(slider_spread, SIGNAL(valueChanged(int)),
this, SLOT(generateSlidersChanged()));
slider_hold = createAttribute(w, tr("Minimum size (samples):"), 0, 200000);
connect(slider_hold, SIGNAL(valueChanged(int)),
- tool_selections, SLOT(holdChanged(int)));
+ tool_ranges, SLOT(holdChanged(int)));
connect(slider_hold, SIGNAL(valueChanged(int)),
- tool_selections, SLOT(autoCreateSelectionsPreview()));
+ tool_ranges, SLOT(autoCreateRangesPreview()));
slider_hold->setValue(instrument.getMinimumSize());
connect(slider_hold, SIGNAL(valueChanged(int)),
this, SLOT(generateSlidersChanged()));
slider_falloff = createAttribute(w, tr("Falloff:"), 10, 5000);
connect(slider_falloff, SIGNAL(valueChanged(int)),
- tool_selections, SLOT(noiseFloorChanged(int)));
+ tool_ranges, SLOT(noiseFloorChanged(int)));
connect(slider_falloff, SIGNAL(valueChanged(int)),
- tool_selections, SLOT(autoCreateSelectionsPreview()));
+ tool_ranges, SLOT(autoCreateRangesPreview()));
slider_falloff->setValue(instrument.getFalloff());
connect(slider_falloff, SIGNAL(valueChanged(int)),
this, SLOT(generateSlidersChanged()));
slider_fadelength = createAttribute(w, tr("Fadelength:"), 0, 2000);
connect(slider_fadelength, SIGNAL(valueChanged(int)),
- tool_selections, SLOT(fadeoutChanged(int)));
+ tool_ranges, SLOT(fadeoutChanged(int)));
connect(slider_fadelength, SIGNAL(valueChanged(int)),
- tool_selections, SLOT(autoCreateSelectionsPreview()));
+ tool_ranges, SLOT(autoCreateRangesPreview()));
slider_fadelength->setValue(instrument.getFadeLength());
connect(slider_fadelength, SIGNAL(valueChanged(int)),
this, SLOT(generateSlidersChanged()));
@@ -404,10 +404,10 @@ void InstrumentWidget::exportPathChanged()
void InstrumentWidget::playSamples()
{
- Selections* sels = &selections;
+ Ranges* sels = &ranges;
if(tabs->currentIndex() == generateTabId)
{
- sels = &selections_preview;
+ sels = &ranges_preview;
}
QVector<sel_id_t> ids = sels->ids();
@@ -415,8 +415,8 @@ void InstrumentWidget::playSamples()
{
for(int v2 = 0; v2 < ids.size(); v2++)
{
- Selection sel1 = sels->get(ids[v1]);
- Selection sel2 = sels->get(ids[v2]);
+ Range sel1 = sels->get(ids[v1]);
+ Range sel2 = sels->get(ids[v2]);
if(sel1.energy < sel2.energy)
{
@@ -430,7 +430,7 @@ void InstrumentWidget::playSamples()
QVector<sel_id_t>::iterator i = ids.begin();
while(i != ids.end())
{
- Selection sel = sels->get(*i);
+ Range sel = sels->get(*i);
unsigned int length = sb_playsamples->value() * 44100 / 1000;
@@ -448,7 +448,7 @@ void InstrumentWidget::playSamples()
connect(&player, SIGNAL(positionUpdate(size_t)),
listen, SLOT(update(size_t)));
- player.playSelection(sel, to - sel.from);
+ player.playRange(sel, to - sel.from);
QTime t;
t.start();
while(t.elapsed() < sb_playsamples->value())
@@ -466,7 +466,7 @@ void InstrumentWidget::playSamples()
void InstrumentWidget::doExport()
{
- extractor->exportSelections();
+ extractor->exportRanges();
}
void InstrumentWidget::loadFile(QString filename)