diff options
-rw-r--r-- | src/Makefile.am | 12 | ||||
-rw-r--r-- | src/audioextractor.cc | 20 | ||||
-rw-r--r-- | src/audioextractor.h | 4 | ||||
-rw-r--r-- | src/canvastoolranges.cc (renamed from src/canvastoolselections.cc) | 130 | ||||
-rw-r--r-- | src/canvastoolranges.h (renamed from src/canvastoolselections.h) | 34 | ||||
-rw-r--r-- | src/dgedit.pro | 12 | ||||
-rw-r--r-- | src/filelist.cc | 4 | ||||
-rw-r--r-- | src/filelist.h | 2 | ||||
-rw-r--r-- | src/instrumentwidget.cc | 114 | ||||
-rw-r--r-- | src/instrumentwidget.h | 12 | ||||
-rw-r--r-- | src/player.cc | 40 | ||||
-rw-r--r-- | src/player.h | 14 | ||||
-rw-r--r-- | src/project.cc | 8 | ||||
-rw-r--r-- | src/project.h | 8 | ||||
-rw-r--r-- | src/projectrenderer.cc | 6 | ||||
-rw-r--r-- | src/projectserialiser.cc | 30 | ||||
-rw-r--r-- | src/range.cc (renamed from src/selection.cc) | 34 | ||||
-rw-r--r-- | src/range.h (renamed from src/selection.h) | 52 | ||||
-rw-r--r-- | src/rangeeditor.cc (renamed from src/selectioneditor.cc) | 30 | ||||
-rw-r--r-- | src/rangeeditor.h (renamed from src/selectioneditor.h) | 12 | ||||
-rw-r--r-- | src/samplesorter.cc | 58 | ||||
-rw-r--r-- | src/samplesorter.h | 16 | ||||
-rw-r--r-- | src/ts/dgedit_da.ts | 14 | ||||
-rw-r--r-- | src/ts/dgedit_fr.ts | 15 |
24 files changed, 340 insertions, 341 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index d9a3a90..6b23d17 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,7 +20,7 @@ dgedit_SOURCES = \ $(top_srcdir)/src/canvas.cc \ $(top_srcdir)/src/canvastool.cc \ $(top_srcdir)/src/canvastoollisten.cc \ - $(top_srcdir)/src/canvastoolselections.cc \ + $(top_srcdir)/src/canvastoolranges.cc \ $(top_srcdir)/src/canvastoolthreshold.cc \ $(top_srcdir)/src/canvaswidget.cc \ $(top_srcdir)/src/channeldialog.cc \ @@ -40,8 +40,8 @@ dgedit_SOURCES = \ $(top_srcdir)/src/projectserialiser.cc \ $(top_srcdir)/src/renderdialog.cc \ $(top_srcdir)/src/samplesorter.cc \ - $(top_srcdir)/src/selection.cc \ - $(top_srcdir)/src/selectioneditor.cc \ + $(top_srcdir)/src/range.cc \ + $(top_srcdir)/src/rangeeditor.cc \ $(top_srcdir)/src/settings.cc \ $(top_srcdir)/src/volumefader.cc \ $(top_srcdir)/src/zoomslider.cc @@ -52,7 +52,7 @@ HDRS = \ $(top_srcdir)/src/canvas.h \ $(top_srcdir)/src/canvastool.h \ $(top_srcdir)/src/canvastoollisten.h \ - $(top_srcdir)/src/canvastoolselections.h \ + $(top_srcdir)/src/canvastoolranges.h \ $(top_srcdir)/src/canvastoolthreshold.h \ $(top_srcdir)/src/canvaswidget.h \ $(top_srcdir)/src/channeldialog.h \ @@ -72,8 +72,8 @@ HDRS = \ $(top_srcdir)/src/projectserialiser.h \ $(top_srcdir)/src/renderdialog.h \ $(top_srcdir)/src/samplesorter.h \ - $(top_srcdir)/src/selection.h \ - $(top_srcdir)/src/selectioneditor.h \ + $(top_srcdir)/src/range.h \ + $(top_srcdir)/src/rangeeditor.h \ $(top_srcdir)/src/sleep.h \ $(top_srcdir)/src/settings.h \ $(top_srcdir)/src/volumefader.h \ diff --git a/src/audioextractor.cc b/src/audioextractor.cc index 95fe6b2..d14370e 100644 --- a/src/audioextractor.cc +++ b/src/audioextractor.cc @@ -50,14 +50,14 @@ AudioExtractor::AudioExtractor(Instrument& instrument, QObject *parent) { } -bool AudioExtractor::exportSelections() +bool AudioExtractor::exportRanges() { - auto selections = instrument.getSelections(); + auto ranges = instrument.getRanges(); auto exportpath = instrument.getProject().getExportPath(); auto prefix = instrument.getPrefix(); int samplerate = -1; - emit setMaximumProgress(selections.ids().size() + 1/* for xml writing*/); + emit setMaximumProgress(ranges.ids().size() + 1/* for xml writing*/); int progress = 0; emit progressUpdate(progress++); qApp->processEvents(); @@ -92,15 +92,15 @@ bool AudioExtractor::exportSelections() } idx = 1; - QVector<sel_id_t> sels = selections.ids(); + QVector<sel_id_t> sels = ranges.ids(); - // Sort selections by velocity + // Sort ranges by velocity for(int v1 = 0; v1 < sels.size(); v1++) { for(int v2 = 0; v2 < sels.size(); v2++) { - Selection sel1 = selections.get(sels[v1]); - Selection sel2 = selections.get(sels[v2]); + Range sel1 = ranges.get(sels[v1]); + Range sel2 = ranges.get(sels[v2]); if(sel1.energy < sel2.energy) { @@ -121,7 +121,7 @@ bool AudioExtractor::exportSelections() QVector<sel_id_t>::iterator si = sels.begin(); while(si != sels.end()) { - Selection sel = selections.get(*si); + Range sel = ranges.get(*si); size_t offset = sel.from; size_t size = sel.to - sel.from; size_t fadein = sel.fadein; @@ -241,7 +241,7 @@ bool AudioExtractor::exportSelections() { index++; - Selection i = selections.get(*si); + Range i = ranges.get(*si); i.name = prefix + "-" + QString::number(index); QDomElement sample = doc.createElement("sample"); @@ -249,7 +249,7 @@ bool AudioExtractor::exportSelections() sample.setAttribute("power", QString::number(i.energy)); samples.appendChild(sample); - selections.update(*si, i); + ranges.update(*si, i); int channelnum = 1; // Filechannel numbers are 1-based. diff --git a/src/audioextractor.h b/src/audioextractor.h index 134c582..aa85d98 100644 --- a/src/audioextractor.h +++ b/src/audioextractor.h @@ -32,7 +32,7 @@ #include <QString> #include <QVector> -#include "selection.h" +#include "range.h" #include "samplesorter.h" class Instrument; @@ -45,7 +45,7 @@ public: AudioExtractor(Instrument& instrument, QObject* parent); public slots: - bool exportSelections(); + bool exportRanges(); signals: void progressUpdate(int value); diff --git a/src/canvastoolselections.cc b/src/canvastoolranges.cc index d3e90f1..bd359a6 100644 --- a/src/canvastoolselections.cc +++ b/src/canvastoolranges.cc @@ -1,6 +1,6 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /*************************************************************************** - * canvastoolselections.cc + * canvastoolranges.cc * * Thu Jul 28 20:16:59 CEST 2011 * Copyright 2011 Bent Bisballe Nyeng @@ -24,7 +24,7 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include "canvastoolselections.h" +#include "canvastoolranges.h" #include <math.h> #include <stdio.h> @@ -34,18 +34,18 @@ #define unmapX(x) canvas->unmapX(x) #define unmapY(x) canvas->unmapY(x) -CanvasToolSelections::CanvasToolSelections(Canvas* c, Selections& s, - Selections& p) - : selections(s) - , selections_preview(p) +CanvasToolRanges::CanvasToolRanges(Canvas* c, Ranges& s, + Ranges& p) + : ranges(s) + , ranges_preview(p) { threshold = 0.5; // Default from CanvasToolThreshold hold = 100; canvas = c; - selection_is_moving_left = false; - selection_is_moving_right = false; + range_is_moving_left = false; + range_is_moving_right = false; colSelBg = QColor(255, 0, 0, 60); colSel = QColor(255, 0, 0, 160); @@ -55,39 +55,39 @@ CanvasToolSelections::CanvasToolSelections(Canvas* c, Selections& s, colPreviewSel = QColor(0, 0, 255, 160); } -bool CanvasToolSelections::mouseMoveEvent(QMouseEvent* event) +bool CanvasToolRanges::mouseMoveEvent(QMouseEvent* event) { - sel_id_t active_selection = selections.active(); - Selection act_sel = selections.get(active_selection); + sel_id_t active_range = ranges.active(); + Range act_sel = ranges.get(active_range); - if(selection_is_moving_left) + if(range_is_moving_left) { float val = unmapX(event->x()); if(val > act_sel.to) val = act_sel.to - 1; act_sel.from = std::max(0.0f, val); - selections.update(active_selection, act_sel); + ranges.update(active_range, act_sel); canvas->update(); return true; } - if(selection_is_moving_right) + if(range_is_moving_right) { float val = unmapX(event->x()); if(val < act_sel.from) val = act_sel.from + 1; act_sel.to = std::min(val, (float)canvas->size); - selections.update(active_selection, act_sel); + ranges.update(active_range, act_sel); canvas->update(); return true; } if(event->button() != Qt::LeftButton) { - // Check if a selection is being dragged. - QVector<sel_id_t> ids = selections.ids(); + // Check if a range is being dragged. + QVector<sel_id_t> ids = ranges.ids(); QVector<sel_id_t>::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections.get(*i); + Range sel = ranges.get(*i); if(abs(event->x() - mapX(sel.from)) < 2 || abs(event->x() - mapX(sel.to)) < 2) { @@ -101,42 +101,42 @@ bool CanvasToolSelections::mouseMoveEvent(QMouseEvent* event) return false; } -bool CanvasToolSelections::mousePressEvent(QMouseEvent* event) +bool CanvasToolRanges::mousePressEvent(QMouseEvent* event) { if(event->button() == Qt::LeftButton) { - // Check if a selection is being dragged. - QVector<sel_id_t> ids = selections.ids(); + // Check if a range is being dragged. + QVector<sel_id_t> ids = ranges.ids(); QVector<sel_id_t>::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections.get(*i); + Range sel = ranges.get(*i); if(abs(event->x() - mapX(sel.from)) < 2) { - selections.setActive(*i); - selection_is_moving_left = true; + ranges.setActive(*i); + range_is_moving_left = true; return true; } if(abs(event->x() - mapX(sel.to)) < 2) { - selections.setActive(*i); - selection_is_moving_right = true; + ranges.setActive(*i); + range_is_moving_right = true; return true; } i++; } - // Check if a selection is being selected. + // Check if a range is being selected. i = ids.begin(); while(i != ids.end()) { - Selection sel = selections.get(*i); + Range sel = ranges.get(*i); if(event->x() > mapX(sel.from) && event->x() < mapX(sel.to)) { - selections.setActive(*i); + ranges.setActive(*i); canvas->update(); return true; } @@ -144,12 +144,12 @@ bool CanvasToolSelections::mousePressEvent(QMouseEvent* event) i++; } - // Make new selection + // Make new range int from = unmapX(event->x()); - Selection new_selection(from, from); - sel_id_t id = selections.add(new_selection); - selections.setActive(id); - selection_is_moving_right = true; + Range new_range(from, from); + sel_id_t id = ranges.add(new_range); + ranges.setActive(id); + range_is_moving_right = true; canvas->update(); return true; } @@ -157,14 +157,14 @@ bool CanvasToolSelections::mousePressEvent(QMouseEvent* event) return false; } -bool CanvasToolSelections::mouseReleaseEvent(QMouseEvent* event) +bool CanvasToolRanges::mouseReleaseEvent(QMouseEvent* event) { if(event->button() == Qt::LeftButton) { - if(selection_is_moving_left || selection_is_moving_right) + if(range_is_moving_left || range_is_moving_right) { - selection_is_moving_left = false; - selection_is_moving_right = false; + range_is_moving_left = false; + range_is_moving_right = false; canvas->setCursor(Qt::ArrowCursor); canvas->update(); return true; @@ -174,24 +174,24 @@ bool CanvasToolSelections::mouseReleaseEvent(QMouseEvent* event) return false; } -void CanvasToolSelections::paintEvent(QPaintEvent* event, QPainter& painter) +void CanvasToolRanges::paintEvent(QPaintEvent* event, QPainter& painter) { int pos = unmapX(event->rect().x()); int width = unmapX(event->rect().width()); { - QVector<sel_id_t> ids = selections.ids(); + QVector<sel_id_t> ids = ranges.ids(); QVector<sel_id_t>::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections.get(*i); + Range sel = ranges.get(*i); int from = sel.from; int to = sel.to; int fadein = sel.fadein; int fadeout = sel.fadeout; if(from > pos + width || to + width < pos) { i++; continue; } - if(selections.active() ==* i) + if(ranges.active() ==* i) { painter.setBrush(colActiveSelBg); painter.setPen(colActiveSel); @@ -213,11 +213,11 @@ void CanvasToolSelections::paintEvent(QPaintEvent* event, QPainter& painter) if(show_preview) { - QVector<sel_id_t> ids = selections_preview.ids(); + QVector<sel_id_t> ids = ranges_preview.ids(); QVector<sel_id_t>::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections_preview.get(*i); + Range sel = ranges_preview.get(*i); int from = sel.from; int to = sel.to; int fadein = sel.fadein; @@ -238,52 +238,52 @@ void CanvasToolSelections::paintEvent(QPaintEvent* event, QPainter& painter) } } -void CanvasToolSelections::keyReleaseEvent(QKeyEvent* event) +void CanvasToolRanges::keyReleaseEvent(QKeyEvent* event) { - if(selections.active() != SEL_NONE && event->key() == Qt::Key_Delete) + if(ranges.active() != SEL_NONE && event->key() == Qt::Key_Delete) { - selections.remove(selections.active()); + ranges.remove(ranges.active()); canvas->update(); } } -void CanvasToolSelections::thresholdChanged(double t) +void CanvasToolRanges::thresholdChanged(double t) { threshold = t; } -void CanvasToolSelections::holdChanged(int h) +void CanvasToolRanges::holdChanged(int h) { hold = h; } -void CanvasToolSelections::noiseFloorChanged(int t) +void CanvasToolRanges::noiseFloorChanged(int t) { double div = 666.0 / 0.00003; noise_floor = (double)t/div; } -void CanvasToolSelections::fadeoutChanged(int t) +void CanvasToolRanges::fadeoutChanged(int t) { fadeout = (double)t/1000.0; } -void CanvasToolSelections::autoCreateSelections() +void CanvasToolRanges::autoCreateRanges() { - doAutoCreateSelections(false); + doAutoCreateRanges(false); } -void CanvasToolSelections::autoCreateSelectionsPreview() +void CanvasToolRanges::autoCreateRangesPreview() { - doAutoCreateSelections(true); + doAutoCreateRanges(true); } -void CanvasToolSelections::doAutoCreateSelections(bool preview) +void CanvasToolRanges::doAutoCreateRanges(bool preview) { float* data = canvas->data; size_t size = canvas->size; - if(preview) selections_preview.clear(); + if(preview) ranges_preview.clear(); for(size_t i = 0; i < size; i++) { @@ -320,14 +320,14 @@ void CanvasToolSelections::doAutoCreateSelections(bool preview) to++; } - Selection s(from, to, 2, ((to - from) / 3) * fadeout); + Range s(from, to, 2, ((to - from) / 3) * fadeout); if(preview) { - selections_preview.add(s); + ranges_preview.add(s); } else { - selections.add(s); + ranges.add(s); } i = to+1; @@ -336,16 +336,16 @@ void CanvasToolSelections::doAutoCreateSelections(bool preview) canvas->update(); } -void CanvasToolSelections::clearSelections() +void CanvasToolRanges::clearRanges() { - selections.clear(); - selection_is_moving_left = false; - selection_is_moving_right = false; + ranges.clear(); + range_is_moving_left = false; + range_is_moving_right = false; canvas->setCursor(Qt::ArrowCursor); canvas->update(); } -void CanvasToolSelections::setShowPreview(bool s) +void CanvasToolRanges::setShowPreview(bool s) { show_preview = s; canvas->update(); diff --git a/src/canvastoolselections.h b/src/canvastoolranges.h index 21f00c6..122c21c 100644 --- a/src/canvastoolselections.h +++ b/src/canvastoolranges.h @@ -1,6 +1,6 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /*************************************************************************** - * canvastoolselections.h + * canvastoolranges.h * * Thu Jul 28 20:16:59 CEST 2011 * Copyright 2011 Bent Bisballe Nyeng @@ -32,33 +32,33 @@ #include "canvas.h" -#include "selection.h" +#include "range.h" -class CanvasToolSelections +class CanvasToolRanges : public CanvasTool { Q_OBJECT public: - CanvasToolSelections(Canvas* canvas, Selections& selections, - Selections& selections_preview); + CanvasToolRanges(Canvas* canvas, Ranges& ranges, + Ranges& ranges_preview); - QString name() { return tr("Selections"); } + QString name() { return tr("Ranges"); } bool mouseMoveEvent(QMouseEvent* event); bool mousePressEvent(QMouseEvent* event); bool mouseReleaseEvent(QMouseEvent* event); void paintEvent(QPaintEvent* event, QPainter& painter); void keyReleaseEvent(QKeyEvent* event); - //Selections selections(); + //Ranges ranges(); signals: - //void selectionsChanged(Selections selections); - //void activeSelectionChanged(sel_id_t id); + //void rangesChanged(Ranges ranges); + //void activeRangeChanged(sel_id_t id); public slots: - void autoCreateSelections(); - void autoCreateSelectionsPreview(); - void clearSelections(); + void autoCreateRanges(); + void autoCreateRangesPreview(); + void clearRanges(); void thresholdChanged(double threshold); void noiseFloorChanged(int t); void holdChanged(int h); @@ -66,10 +66,10 @@ public slots: void setShowPreview(bool show_preview); private: - void doAutoCreateSelections(bool preview); + void doAutoCreateRanges(bool preview); - bool selection_is_moving_left; - bool selection_is_moving_right; + bool range_is_moving_left; + bool range_is_moving_right; Canvas* canvas; @@ -85,8 +85,8 @@ private: QColor colPreviewSelBg; QColor colPreviewSel; - Selections& selections; - Selections& selections_preview; + Ranges& ranges; + Ranges& ranges_preview; bool show_preview; }; diff --git a/src/dgedit.pro b/src/dgedit.pro index 517be08..7c5034d 100644 --- a/src/dgedit.pro +++ b/src/dgedit.pro @@ -13,7 +13,7 @@ HEADERS += audioextractor.h \ canvas.h \ canvastool.h \ canvastoollisten.h \ - canvastoolselections.h \ + canvastoolranges.h \ canvastoolthreshold.h \ canvaswidget.h \ filelist.h \ @@ -22,8 +22,8 @@ HEADERS += audioextractor.h \ mipmap.h \ player.h \ samplesorter.h \ - selection.h \ - selectioneditor.h \ + range.h \ + rangeeditor.h \ sleep.h \ volumefader.h \ zoomslider.h @@ -31,7 +31,7 @@ SOURCES += audioextractor.cc \ canvas.cc \ canvastool.cc \ canvastoollisten.cc \ - canvastoolselections.cc \ + canvastoolranges.cc \ canvastoolthreshold.cc \ canvaswidget.cc \ dgedit.cc \ @@ -41,8 +41,8 @@ SOURCES += audioextractor.cc \ mipmap.cc \ player.cc \ samplesorter.cc \ - selection.cc \ - selectioneditor.cc \ + range.cc \ + rangeeditor.cc \ volumefader.cc \ zoomslider.cc RESOURCES += dgedit.qrc diff --git a/src/filelist.cc b/src/filelist.cc index e1467e3..dab2095 100644 --- a/src/filelist.cc +++ b/src/filelist.cc @@ -433,7 +433,7 @@ FileList::FileList(Instrument& instrument) header()->resizeSection(2, 24); connect(this, SIGNAL(doubleClicked(const QModelIndex&)), - this, SLOT(selectionChanged(const QModelIndex&))); + this, SLOT(rangeChanged(const QModelIndex&))); createMenus(); } @@ -510,7 +510,7 @@ void FileList::addFiles() model->refresh(); } -void FileList::selectionChanged(const QModelIndex &index) +void FileList::rangeChanged(const QModelIndex &index) { auto audiofile_ids = instrument.getAudioFileList(); auto audiofile_id = audiofile_ids.begin() + index.row(); diff --git a/src/filelist.h b/src/filelist.h index 165af83..120fc77 100644 --- a/src/filelist.h +++ b/src/filelist.h @@ -53,7 +53,7 @@ public slots: void addFiles(); private slots: - void selectionChanged(const QModelIndex &index); + void rangeChanged(const QModelIndex &index); void onCustomContextMenu(const QPoint &point); void setMaster(); void removeFile(); 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) diff --git a/src/instrumentwidget.h b/src/instrumentwidget.h index 721b829..d2a4b9d 100644 --- a/src/instrumentwidget.h +++ b/src/instrumentwidget.h @@ -38,10 +38,10 @@ #include "audioextractor.h" #include "samplesorter.h" #include "filelist.h" -#include "canvastoolselections.h" +#include "canvastoolranges.h" #include "canvastoolthreshold.h" #include "canvastoollisten.h" -#include "selection.h" +#include "range.h" #include "player.h" #include "zoomslider.h" #include "canvaswidget.h" @@ -74,7 +74,7 @@ public slots: void browse(); void tabChanged(int tabid); void generateSlidersChanged(); - void selectionChanged(); + void rangeChanged(); void prefixChanged(); void exportPathChanged(); @@ -87,7 +87,7 @@ private: int generateTabId; SampleSorter* sorter; - CanvasToolSelections* tool_selections; + CanvasToolRanges* tool_ranges; CanvasToolThreshold* threshold; CanvasToolListen* listen; AudioExtractor* extractor; @@ -108,8 +108,8 @@ private: QTabWidget* tabs; // Session state information: - Selections selections; - Selections selections_preview; + Ranges ranges; + Ranges ranges_preview; Player player; Settings& settings; diff --git a/src/player.cc b/src/player.cc index d598d9f..a3eeaa2 100644 --- a/src/player.cc +++ b/src/player.cc @@ -38,7 +38,7 @@ Player::Player() pcm_data = NULL; pcm_size = 0; end = 0; - new_selection = false; + new_range = false; connect(&report_timer, SIGNAL(timeout()), this, SLOT(reportTimeout())); report_timer.start(50); // Update 25 times per second @@ -55,7 +55,7 @@ Player::~Player() #define _MIN(a, b) (a<b?a:b) void Player::run() { - Selection sel; + Range sel; static int init = 0; if(init == 0) @@ -79,14 +79,14 @@ void Player::run() while(running) { { - // Check for new Selection. + // Check for new Range. QMutexLocker lock(&mutex); - if(new_selection) + if(new_range) { - sel = selection; + sel = range; pos = sel.from; end = sel_end; - new_selection = false; + new_range = false; } } @@ -134,18 +134,18 @@ void Player::run() } } -bool Player::playSelectionDone() +bool Player::playRangeDone() { - return pos >= sel_end || pos >= selection.to; + return pos >= sel_end || pos >= range.to; } -void Player::playSelection(Selection s, int len) +void Player::playRange(Range s, int len) { { - // Enqueue new Selection for player consumation + // Enqueue new Range for player consumation QMutexLocker lock(&mutex); - selection = s; + range = s; if(len > 0) { @@ -153,16 +153,16 @@ void Player::playSelection(Selection s, int len) } else { - sel_end = selection.to - selection.from; + sel_end = range.to - range.from; } - sel_end += selection.from; + sel_end += range.from; - new_selection = true; + new_range = true; } - // Wait until player actually consumed the new Selection. - while(new_selection) + // Wait until player actually consumed the new Range. + while(new_range) { msleep(1); } @@ -197,20 +197,20 @@ void Player::setPcmData(float* data, size_t size, double samplerate) void Player::setPosition(size_t position) { - Selection s; + Range s; s.from = position; s.to = pcm_size; s.fadein = 0; s.fadeout = 0; - playSelection(s); + playRange(s); } void Player::stop() { - Selection s; + Range s; s.from = 0; s.to = 0; s.fadein = 0; s.fadeout = 0; - playSelection(s, pos); + playRange(s, pos); } diff --git a/src/player.h b/src/player.h index 0f5b780..9bc03b7 100644 --- a/src/player.h +++ b/src/player.h @@ -32,7 +32,7 @@ #include <ao/ao.h> -#include "selection.h" +#include "range.h" class Player : public QThread @@ -67,12 +67,12 @@ public slots: //! Set player position as sample offset. void setPosition(size_t position); - //! Play range based on selection including fade-in/out. + //! Play range based on range including fade-in/out. //! \param length Stop playing after length samples. -1 means play all. - void playSelection(Selection selection, int length = -1); + void playRange(Range range, int length = -1); - //! Return true if last selection is done playing. - bool playSelectionDone(); + //! Return true if last range is done playing. + bool playRangeDone(); //! Stop playing void stop(); @@ -105,7 +105,7 @@ private: bool running; QMutex mutex; - volatile bool new_selection; + volatile bool new_range; size_t sel_end; - Selection selection; + Range range; }; diff --git a/src/project.cc b/src/project.cc index 9cac537..b3b88a3 100644 --- a/src/project.cc +++ b/src/project.cc @@ -335,16 +335,16 @@ void Instrument::setThreshold(float threshold) } } -Selections Instrument::getSelections() const +Ranges Instrument::getRanges() const { - return selections; + return ranges; } -void Instrument::setSelections(const Selections& selections) +void Instrument::setRanges(const Ranges& ranges) { { Project::RAIIBulkUpdate bulkUpdate(project); - this->selections = selections; + this->ranges = ranges; } } diff --git a/src/project.h b/src/project.h index 3e2b886..b21f089 100644 --- a/src/project.h +++ b/src/project.h @@ -32,7 +32,7 @@ #include <QString> #include "audioextractor.h" -#include "selection.h" +#include "range.h" class Project; class Instrument; @@ -105,8 +105,8 @@ public: float getThreshold() const; void setThreshold(float threshold); - Selections getSelections() const; - void setSelections(const Selections& selectios); + Ranges getRanges() const; + void setRanges(const Ranges& selectios); QString getPrefix() const; void setPrefix(const QString& prefix); @@ -134,7 +134,7 @@ private: float threshold{0.5f}; // Edit tab - Selections selections; + Ranges ranges; // Export tab QString prefix; diff --git a/src/projectrenderer.cc b/src/projectrenderer.cc index 62d646e..a8e805b 100644 --- a/src/projectrenderer.cc +++ b/src/projectrenderer.cc @@ -85,8 +85,8 @@ void ProjectRenderer::render() instrument.getInstrumentName()); { - auto selections = instrument.getSelections().ids(); - emit progressRenderStart(selections.count()); + auto ranges = instrument.getRanges().ids(); + emit progressRenderStart(ranges.count()); qApp->processEvents(); } @@ -94,7 +94,7 @@ void ProjectRenderer::render() connect(&extractor, SIGNAL(progressUpdate(int)), this, SIGNAL(progressRenderTask(int))); - if(!extractor.exportSelections()) + if(!extractor.exportRanges()) { emit progressFinished(1); qApp->processEvents(); diff --git a/src/projectserialiser.cc b/src/projectserialiser.cc index 6a204eb..59cb97d 100644 --- a/src/projectserialiser.cc +++ b/src/projectserialiser.cc @@ -192,11 +192,11 @@ QString ProjectSerialiser::serialise(const Project& project) } auto regions = doc.createElement("regions"); - regions.setAttribute("nextid", i.selections.nextid); - regions.setAttribute("act", i.selections.act); + regions.setAttribute("nextid", i.ranges.nextid); + regions.setAttribute("act", i.ranges.act); instrument.appendChild(regions); - for(auto r = i.selections.sels.begin(); r != i.selections.sels.end(); ++r) + for(auto r = i.ranges.sels.begin(); r != i.ranges.sels.end(); ++r) { auto region = doc.createElement("region"); region.setAttribute("id", (int)r.key()); @@ -292,20 +292,20 @@ bool ProjectSerialiser::deserialise(const QString& data, Project& project) instr.prefix = instrument("prefix").text(); - auto selections = instrument("regions"); - instr.selections.nextid = selections["nextid"].toInt(); - instr.selections.act = selections["act"].toInt(); + auto ranges = instrument("regions"); + instr.ranges.nextid = ranges["nextid"].toInt(); + instr.ranges.act = ranges["act"].toInt(); - for(auto& selection : selections.children()) + for(auto& range : ranges.children()) { - Selection s; - s.from = selection["from"].toInt(); - s.to = selection["to"].toInt(); - s.fadein = selection["fadein"].toInt(); - s.fadeout = selection["fadeout"].toInt(); - s.energy = selection["energy"].toFloat(); - s.name = selection["name"]; - instr.selections.sels[selection["id"].toInt()] = s; + Range s; + s.from = range["from"].toInt(); + s.to = range["to"].toInt(); + s.fadein = range["fadein"].toInt(); + s.fadeout = range["fadeout"].toInt(); + s.energy = range["energy"].toFloat(); + s.name = range["name"]; + instr.ranges.sels[range["id"].toInt()] = s; } } diff --git a/src/selection.cc b/src/range.cc index e18e485..28bf48e 100644 --- a/src/selection.cc +++ b/src/range.cc @@ -1,6 +1,6 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /*************************************************************************** - * selection.cc + * range.cc * * Mon Apr 14 10:13:21 CEST 2014 * Copyright 2014 Bent Bisballe Nyeng @@ -24,50 +24,50 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include "selection.h" +#include "range.h" -Selections::Selections() +Ranges::Ranges() : QObject(NULL) { nextid = 0; act = SEL_NONE; } -Selections::Selections(const Selections& other) +Ranges::Ranges(const Ranges& other) { *this = other; } -void Selections::operator=(const Selections& other) +void Ranges::operator=(const Ranges& other) { sels = other.sels; nextid = other.nextid; act = other.act; } -sel_id_t Selections::add(Selection selection) +sel_id_t Ranges::add(Range range) { sel_id_t id = nextid++; - sels[id] = selection; + sels[id] = range; added(id); return id; } -Selection Selections::get(sel_id_t id) +Range Ranges::get(sel_id_t id) { if(sels.find(id) == sels.end()) { - Selection s(0,0,0,0); + Range s(0,0,0,0); return s; } return sels[id]; } -QVector<sel_id_t> Selections::ids() +QVector<sel_id_t> Ranges::ids() { QVector<sel_id_t> v; - QMap<sel_id_t, Selection>::iterator i = sels.begin(); + QMap<sel_id_t, Range>::iterator i = sels.begin(); while(i != sels.end()) { v.push_back(i.key()); @@ -77,16 +77,16 @@ QVector<sel_id_t> Selections::ids() return v; } -void Selections::update(sel_id_t id, Selection selection) +void Ranges::update(sel_id_t id, Range range) { if(sels.find(id) != sels.end()) { - sels[id] = selection; + sels[id] = range; emit updated(id); } } -void Selections::remove(sel_id_t id) +void Ranges::remove(sel_id_t id) { if(sels.find(id) != sels.end()) { @@ -99,7 +99,7 @@ void Selections::remove(sel_id_t id) } } -void Selections::clear() +void Ranges::clear() { QVector<sel_id_t> _ids = ids(); QVector<sel_id_t>::iterator i = _ids.begin(); @@ -110,7 +110,7 @@ void Selections::clear() } } -void Selections::setActive(sel_id_t id) +void Ranges::setActive(sel_id_t id) { if(sels.find(id) != sels.end()) { @@ -123,7 +123,7 @@ void Selections::setActive(sel_id_t id) emit activeChanged(act); } -sel_id_t Selections::active() +sel_id_t Ranges::active() { return act; } diff --git a/src/selection.h b/src/range.h index 338b381..c887a66 100644 --- a/src/selection.h +++ b/src/range.h @@ -1,6 +1,6 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /*************************************************************************** - * selection.h + * range.h * * Sat Nov 21 13:20:46 CET 2009 * Copyright 2009 Bent Bisballe Nyeng @@ -31,10 +31,10 @@ #include <QMap> #include <QVector> -class Selection +class Range { public: - Selection(int from = 0, int to = 0, int fadein = 0, int fadeout = 0) + Range(int from = 0, int to = 0, int fadein = 0, int fadeout = 0) { this->from = from; this->to = to; @@ -54,62 +54,62 @@ public: typedef int sel_id_t; #define SEL_NONE -1 -class Selections +class Ranges : public QObject { Q_OBJECT public: - Selections(); - Selections(const Selections&); + Ranges(); + Ranges(const Ranges&); - void operator=(const Selections& other); + void operator=(const Ranges& other); - //! Add a new selection object. The new id is returned. - //! Adding a new selections will emit an added signal with the new id. - sel_id_t add(Selection selection); + //! Add a new range object. The new id is returned. + //! Adding a new ranges will emit an added signal with the new id. + sel_id_t add(Range range); - //! Get a stack copy of a specific selection object, by id. - //! NOTE: If id does not exist an empty selection (from = to = 0) is + //! Get a stack copy of a specific range object, by id. + //! NOTE: If id does not exist an empty range (from = to = 0) is //! returned. - Selection get(sel_id_t id); + Range get(sel_id_t id); //! Return vector (unsorted) of all ids in the object. QVector<sel_id_t> ids(); - //! Set active selection (to be rendered yellow) + //! Set active range (to be rendered yellow) void setActive(sel_id_t id); - //! Get active selection id. + //! Get active range id. sel_id_t active(); public slots: - //! Update a selection by id. - //! Updating a selection will emit a updated signal. - void update(sel_id_t id, Selection selection); + //! Update a range by id. + //! Updating a range will emit a updated signal. + void update(sel_id_t id, Range range); - //! Delete a selection by id. - //! Deleting a selection will emit a deleted signal. + //! Delete a range by id. + //! Deleting a range will emit a deleted signal. void remove(sel_id_t id); - //! Delete all selections + //! Delete all ranges void clear(); signals: - //! This signal is emitted when a new selection has been added. + //! This signal is emitted when a new range has been added. void added(sel_id_t id); - //! This signal is emitted when an existing selection has been updated. + //! This signal is emitted when an existing range has been updated. void updated(sel_id_t id); - //! This signal is emitted when a selection has been removed. + //! This signal is emitted when a range has been removed. void removed(sel_id_t id); - //! The active selection changed. + //! The active range changed. void activeChanged(sel_id_t id); private: friend class ProjectSerialiser; - QMap<sel_id_t, Selection> sels; + QMap<sel_id_t, Range> sels; sel_id_t nextid; sel_id_t act; }; diff --git a/src/selectioneditor.cc b/src/rangeeditor.cc index 417059d..868f434 100644 --- a/src/selectioneditor.cc +++ b/src/rangeeditor.cc @@ -1,6 +1,6 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /*************************************************************************** - * selectioneditor.cc + * rangeeditor.cc * * Thu Apr 17 17:25:18 CEST 2014 * Copyright 2014 Bent Bisballe Nyeng @@ -24,7 +24,7 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include "selectioneditor.h" +#include "rangeeditor.h" #include "project.h" @@ -40,7 +40,7 @@ static QLineEdit *createWidget(QString name, QWidget* parent) QLineEdit* edt = new QLineEdit(); QObject::connect(edt, SIGNAL(editingFinished()), - parent, SLOT(updateSelection())); + parent, SLOT(updateRange())); l->addWidget(edt); @@ -49,8 +49,8 @@ static QLineEdit *createWidget(QString name, QWidget* parent) return edt; } -SelectionEditor::SelectionEditor(Selections &s, Instrument& instrument) - : selections(s) +RangeEditor::RangeEditor(Ranges &s, Instrument& instrument) + : ranges(s) , instrument(instrument) { cur = SEL_NONE; @@ -67,9 +67,9 @@ SelectionEditor::SelectionEditor(Selections &s, Instrument& instrument) ((QHBoxLayout*)layout())->addStretch(); } -void SelectionEditor::updateSelection() +void RangeEditor::updateRange() { - Selection sel; + Range sel; sel.from = from->text().toInt(); sel.to = to->text().toInt(); @@ -78,14 +78,14 @@ void SelectionEditor::updateSelection() sel.energy = energy->text().toDouble(); sel.name = name->text(); - selections.update(cur, sel); + ranges.update(cur, sel); - instrument.setSelections(selections); + instrument.setRanges(ranges); } -void SelectionEditor::update() +void RangeEditor::update() { - Selection sel = selections.get(cur); + Range sel = ranges.get(cur); from->setText(QString::number(sel.from)); to->setText(QString::number(sel.to)); fadein->setText(QString::number(sel.fadein)); @@ -94,12 +94,12 @@ void SelectionEditor::update() name->setText(sel.name); } -void SelectionEditor::added(sel_id_t id) +void RangeEditor::added(sel_id_t id) { // Nothing to do here... } -void SelectionEditor::updated(sel_id_t id) +void RangeEditor::updated(sel_id_t id) { if(cur == id) { @@ -107,7 +107,7 @@ void SelectionEditor::updated(sel_id_t id) } } -void SelectionEditor::removed(sel_id_t id) +void RangeEditor::removed(sel_id_t id) { if(cur == id) { @@ -116,7 +116,7 @@ void SelectionEditor::removed(sel_id_t id) } } -void SelectionEditor::activeChanged(sel_id_t id) +void RangeEditor::activeChanged(sel_id_t id) { cur = id; update(); diff --git a/src/selectioneditor.h b/src/rangeeditor.h index cdbf2de..b3ecd9b 100644 --- a/src/selectioneditor.h +++ b/src/rangeeditor.h @@ -1,6 +1,6 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /*************************************************************************** - * selectioneditor.h + * rangeeditor.h * * Thu Apr 17 17:25:17 CEST 2014 * Copyright 2014 Bent Bisballe Nyeng @@ -29,16 +29,16 @@ #include <QWidget> #include <QLineEdit> -#include "selection.h" +#include "range.h" class Instrument; -class SelectionEditor +class RangeEditor : public QWidget { Q_OBJECT public: - SelectionEditor(Selections& selections, Instrument& instrument); + RangeEditor(Ranges& ranges, Instrument& instrument); public slots: void added(sel_id_t id); @@ -48,10 +48,10 @@ public slots: private slots: void update(); - void updateSelection(); + void updateRange(); private: - Selections& selections; + Ranges& ranges; sel_id_t cur; diff --git a/src/samplesorter.cc b/src/samplesorter.cc index 29c24e6..15d6c3f 100644 --- a/src/samplesorter.cc +++ b/src/samplesorter.cc @@ -37,9 +37,9 @@ #define MAXFLOAT (3.40282347e+38F) #endif -SampleSorter::SampleSorter(Selections& s, Selections& p, Instrument& instrument) - : selections(s) - , selections_preview(p) +SampleSorter::SampleSorter(Ranges& s, Ranges& p, Instrument& instrument) + : ranges(s) + , ranges_preview(p) , instrument(instrument) { setMouseTracking(true); @@ -84,9 +84,9 @@ void SampleSorter::setAttackLength(int len) relayout(); } -void SampleSorter::addSelection(sel_id_t id) +void SampleSorter::addRange(sel_id_t id) { - Selection s = selections.get(id); + Range s = ranges.get(id); double energy = 0.0; for(size_t idx = s.from; @@ -98,14 +98,14 @@ void SampleSorter::addSelection(sel_id_t id) } s.energy = pow(energy, spread); - selections.update(id, s); + ranges.update(id, s); relayout(); } -void SampleSorter::addSelectionPreview(sel_id_t id) +void SampleSorter::addRangePreview(sel_id_t id) { - Selection s = selections_preview.get(id); + Range s = ranges_preview.get(id); double energy = 0.0; for(size_t idx = s.from; @@ -117,7 +117,7 @@ void SampleSorter::addSelectionPreview(sel_id_t id) } s.energy = pow(energy, spread); - selections_preview.update(id, s); + ranges_preview.update(id, s); relayout(); } @@ -128,11 +128,11 @@ void SampleSorter::relayout() max = 0.0; { - QVector<sel_id_t> ids = selections.ids(); + QVector<sel_id_t> ids = ranges.ids(); QVector<sel_id_t>::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections.get(*i); + Range sel = ranges.get(*i); if(sel.energy < min) { @@ -149,11 +149,11 @@ void SampleSorter::relayout() if(show_preview) { - QVector<sel_id_t> ids = selections_preview.ids(); + QVector<sel_id_t> ids = ranges_preview.ids(); QVector<sel_id_t>::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections_preview.get(*i); + Range sel = ranges_preview.get(*i); if(sel.energy < min) { @@ -203,12 +203,12 @@ void SampleSorter::paintEvent(QPaintEvent* event) { - QVector<sel_id_t> ids = selections.ids(); + QVector<sel_id_t> ids = ranges.ids(); QVector<sel_id_t>::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections.get(*i); - if(*i == selections.active()) + Range sel = ranges.get(*i); + if(*i == ranges.active()) { painter.setPen(colPtSel); } @@ -226,11 +226,11 @@ void SampleSorter::paintEvent(QPaintEvent* event) if(show_preview) { - QVector<sel_id_t> ids = selections_preview.ids(); + QVector<sel_id_t> ids = ranges_preview.ids(); QVector<sel_id_t>::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections_preview.get(*i); + Range sel = ranges_preview.get(*i); painter.setPen(colPtPreview); float x = (sel.energy / max); x = sqrt(x); @@ -243,16 +243,16 @@ void SampleSorter::paintEvent(QPaintEvent* event) } -sel_id_t SampleSorter::getSelectionByCoordinate(int px, int py) +sel_id_t SampleSorter::getRangeByCoordinate(int px, int py) { // Hit radius is slithly larger than the circles themselves. int hit_r = C_RADIUS + 1; - QVector<sel_id_t> ids = selections.ids(); + QVector<sel_id_t> ids = ranges.ids(); QVector<sel_id_t>::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections.get(*i); + Range sel = ranges.get(*i); float x = (sel.energy/max); x = sqrt(x); x *= (float)width() * 0.9; @@ -273,14 +273,14 @@ void SampleSorter::mouseMoveEvent(QMouseEvent* event) { if(sel_moving != SEL_NONE) { - Selection sel = selections.get(sel_moving); + Range sel = ranges.get(sel_moving); if(sel_moving != SEL_NONE) { double power = unmapX(event->x()); power *= power; power *= max; sel.energy = power; - selections.update(sel_moving, sel); + ranges.update(sel_moving, sel); } update(); @@ -288,7 +288,7 @@ void SampleSorter::mouseMoveEvent(QMouseEvent* event) } else { - sel_id_t psel = getSelectionByCoordinate(event->x(), event->y()); + sel_id_t psel = getRangeByCoordinate(event->x(), event->y()); if(psel != SEL_NONE) { setCursor(Qt::OpenHandCursor); @@ -304,9 +304,9 @@ void SampleSorter::mousePressEvent(QMouseEvent* event) { if(event->button() == Qt::LeftButton) { - sel_id_t psel = getSelectionByCoordinate(event->x(), event->y()); + sel_id_t psel = getRangeByCoordinate(event->x(), event->y()); sel_moving = psel; - selections.setActive(psel); + ranges.setActive(psel); if(psel != SEL_NONE) { setCursor(Qt::ClosedHandCursor); @@ -319,7 +319,7 @@ void SampleSorter::mouseReleaseEvent(QMouseEvent* event) if(event->button() == Qt::LeftButton) { sel_moving = SEL_NONE; - sel_id_t psel = getSelectionByCoordinate(event->x(), event->y()); + sel_id_t psel = getRangeByCoordinate(event->x(), event->y()); if(psel != SEL_NONE) { setCursor(Qt::OpenHandCursor); @@ -333,8 +333,8 @@ void SampleSorter::mouseReleaseEvent(QMouseEvent* event) void SampleSorter::keyReleaseEvent(QKeyEvent* event) { - if(selections.active() != SEL_NONE && event->key() == Qt::Key_Delete) + if(ranges.active() != SEL_NONE && event->key() == Qt::Key_Delete) { - selections.remove(selections.active()); + ranges.remove(ranges.active()); } } diff --git a/src/samplesorter.h b/src/samplesorter.h index 056161d..f1774e3 100644 --- a/src/samplesorter.h +++ b/src/samplesorter.h @@ -28,7 +28,7 @@ #include <QWidget> #include <QVector> -#include "selection.h" +#include "range.h" class Instrument; @@ -37,7 +37,7 @@ class SampleSorter { Q_OBJECT public: - SampleSorter(Selections& selections, Selections& selections_preview, + SampleSorter(Ranges& ranges, Ranges& ranges_preview, Instrument& instrument); public slots: @@ -45,8 +45,8 @@ public slots: void setAttackLength(int len); int attackLength(); - void addSelection(sel_id_t id); - void addSelectionPreview(sel_id_t id); + void addRange(sel_id_t id); + void addRangePreview(sel_id_t id); void relayout(); @@ -62,10 +62,10 @@ protected: void keyReleaseEvent(QKeyEvent* event) override; private: - sel_id_t getSelectionByCoordinate(int x, int y); + sel_id_t getRangeByCoordinate(int x, int y); - Selections& selections; - Selections& selections_preview; + Ranges& ranges; + Ranges& ranges_preview; bool show_preview; @@ -77,7 +77,7 @@ private: const float* data; size_t size; - Selection sel; + Range sel; sel_id_t sel_moving; diff --git a/src/ts/dgedit_da.ts b/src/ts/dgedit_da.ts index bda3ba5..7fc26cc 100644 --- a/src/ts/dgedit_da.ts +++ b/src/ts/dgedit_da.ts @@ -25,7 +25,7 @@ <context> <name>CanvasToolSelections</name> <message> - <location filename="../canvastoolselections.h" line="45"/> + <location filename="../canvastoolranges.h" line="45"/> <source>Selections</source> <translation>Markeringer</translation> </message> @@ -537,32 +537,32 @@ <context> <name>SelectionEditor</name> <message> - <location filename="../selectioneditor.cc" line="60"/> + <location filename="../rangeeditor.cc" line="60"/> <source>From:</source> <translation>Fra:</translation> </message> <message> - <location filename="../selectioneditor.cc" line="61"/> + <location filename="../rangeeditor.cc" line="61"/> <source>To:</source> <translation>Til:</translation> </message> <message> - <location filename="../selectioneditor.cc" line="62"/> + <location filename="../rangeeditor.cc" line="62"/> <source>FadeIn:</source> <translation>FadeIn:</translation> </message> <message> - <location filename="../selectioneditor.cc" line="63"/> + <location filename="../rangeeditor.cc" line="63"/> <source>FadeOut:</source> <translation>FadeOut:</translation> </message> <message> - <location filename="../selectioneditor.cc" line="64"/> + <location filename="../rangeeditor.cc" line="64"/> <source>Energy:</source> <translation>Energi:</translation> </message> <message> - <location filename="../selectioneditor.cc" line="65"/> + <location filename="../rangeeditor.cc" line="65"/> <source>Name:</source> <translation>Navn:</translation> </message> diff --git a/src/ts/dgedit_fr.ts b/src/ts/dgedit_fr.ts index deb07bd..b37cad8 100644 --- a/src/ts/dgedit_fr.ts +++ b/src/ts/dgedit_fr.ts @@ -25,7 +25,7 @@ <context> <name>CanvasToolSelections</name> <message> - <location filename="../canvastoolselections.h" line="45"/> + <location filename="../canvastoolranges.h" line="45"/> <source>Selections</source> <translation>Sélections</translation> </message> @@ -537,32 +537,32 @@ <context> <name>SelectionEditor</name> <message> - <location filename="../selectioneditor.cc" line="60"/> + <location filename="../rangeeditor.cc" line="60"/> <source>From:</source> <translation>Depuis :</translation> </message> <message> - <location filename="../selectioneditor.cc" line="61"/> + <location filename="../rangeeditor.cc" line="61"/> <source>To:</source> <translation>Jusqu'à :</translation> </message> <message> - <location filename="../selectioneditor.cc" line="62"/> + <location filename="../rangeeditor.cc" line="62"/> <source>FadeIn:</source> <translation>Fondu ouverture :</translation> </message> <message> - <location filename="../selectioneditor.cc" line="63"/> + <location filename="../rangeeditor.cc" line="63"/> <source>FadeOut:</source> <translation>Fondu fermeture :</translation> </message> <message> - <location filename="../selectioneditor.cc" line="64"/> + <location filename="../rangeeditor.cc" line="64"/> <source>Energy:</source> <translation>Énergie :</translation> </message> <message> - <location filename="../selectioneditor.cc" line="65"/> + <location filename="../rangeeditor.cc" line="65"/> <source>Name:</source> <translation>Nom :</translation> </message> @@ -581,4 +581,3 @@ </message> </context> </TS> - |