summaryrefslogtreecommitdiff
path: root/dgedit/mainwindow.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-04-18 13:16:03 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-04-18 13:16:03 +0200
commit68e4647e565519c57d76b95806dd9431a4ecfbb1 (patch)
treee7868dfa39dc886d21967dd6766072067d37636c /dgedit/mainwindow.cc
parent11b8e6db937f4c77942febb69f7b41e87ae0b6e0 (diff)
New player model (again).
Diffstat (limited to 'dgedit/mainwindow.cc')
-rw-r--r--dgedit/mainwindow.cc28
1 files changed, 17 insertions, 11 deletions
diff --git a/dgedit/mainwindow.cc b/dgedit/mainwindow.cc
index d573ff4..9f877bf 100644
--- a/dgedit/mainwindow.cc
+++ b/dgedit/mainwindow.cc
@@ -42,12 +42,12 @@
#include <QIntValidator>
#include <QTabWidget>
#include <QProgressBar>
+#include <QTime>
-#include <unistd.h>
+//#include <unistd.h>
#include "canvastool.h"
#include "canvastoolthreshold.h"
-#include "canvastoollisten.h"
#include "volumefader.h"
#include "selectioneditor.h"
@@ -65,7 +65,6 @@ static void addTool(QToolBar *toolbar, Canvas *canvas, CanvasTool *tool)
canvas->tools.push_back(tool);
}
-static CanvasToolListen *g_listen;
MainWindow::MainWindow()
{
{
@@ -84,8 +83,7 @@ MainWindow::MainWindow()
canvas = new Canvas(this);
QToolBar *toolbar = addToolBar("Tools");
- g_listen = new CanvasToolListen(canvas, player);
- CanvasTool *listen = g_listen;
+ listen = new CanvasToolListen(canvas, player);
addTool(toolbar, canvas, listen);
threshold = new CanvasToolThreshold(canvas);
canvas->tools.push_back(threshold);//addTool(toolbar, canvas, threshold);
@@ -426,8 +424,6 @@ void MainWindow::setVolumeLineEd(int value)
void MainWindow::playSamples()
{
- //unsigned int length = 44100 / 4; // 0.25 seconds in 44k1Hz
-
QVector<sel_id_t> ids = selections.ids();
for(int v1 = 0; v1 < ids.size(); v1++) {
for(int v2 = 0; v2 < ids.size(); v2++) {
@@ -452,15 +448,25 @@ void MainWindow::playSamples()
unsigned int sample_length = sel.to - sel.from;
unsigned int to = sel.to;
- unsigned int sleep = 0;
if(sample_length > length) to = sel.from + length;
- else sleep = length - sample_length;
selections.setActive(*i);
- g_listen->playRange(sel.from, to);
- usleep(1000000 * sleep / 44100);
+ connect(&player, SIGNAL(positionUpdate(size_t)),
+ listen, SLOT(update(size_t)));
+
+ player.playSelection(sel, to - sel.from);
+ QTime t;
+ t.start();
+ while(t.elapsed() < sb_playsamples->value()) {
+ qApp->processEvents();
+ usleep(25 * 1000);
+ }
+ player.stop();
+
+ disconnect(&player, SIGNAL(positionUpdate(size_t)),
+ listen, SLOT(update(size_t)));
i++;
}
}