1f7750745372 — Chris Cannam 4 years ago
Implement speed changing
2 files changed, 14 insertions(+), 20 deletions(-)

M src/Interface.cpp
M src/Interface.h
M src/Interface.cpp +13 -17
@@ 34,14 34,23 @@ Interface::Interface(Processor *p, QWidg
     auto pause = new QPushButton(tr("||"));
     mainLayout->addWidget(pause, 0, 3);
 
+    auto speed = new QDoubleSpinBox;
+    speed->setMinimum(0.1);
+    speed->setMaximum(100.0);
+    speed->setValue(1.0);
+    speed->setDecimals(2);
+    speed->setSingleStep(0.1);
+    mainLayout->addWidget(speed, 0, 4);
+
     connect(open, SIGNAL(clicked()), this, SLOT(open()));
     connect(rewind, SIGNAL(clicked()), this, SLOT(rewind()));
     connect(play, SIGNAL(clicked()), this, SLOT(play()));
     connect(pause, SIGNAL(clicked()), this, SLOT(pause()));
+    connect(speed, SIGNAL(valueChanged(double)), this, SLOT(speedChanged(double)));
 
     m_filenameLabel = new QLabel;
     m_filenameLabel->setText(tr("<no file loaded>"));
-    mainLayout->addWidget(m_filenameLabel, 1, 0, 1, 4);
+    mainLayout->addWidget(m_filenameLabel, 1, 0, 1, 5);
 
     setCentralWidget(mainFrame);
 }

          
@@ 102,23 111,10 @@ Interface::rewind()
 {
     m_processor->rewind();
 }
-/*
+
 void
-Interface::speedUp()
+Interface::speedChanged(double ratio)
 {
-    int v = m_speed->value();
-    v = (v/2) * 2 + 2; // target is always even
-    m_speed->setValue(v);
-    speedChange(m_speed->value());
+    m_processor->setTimeRatio(ratio);
 }
 
-void
-Interface::slowDown()
-{
-    int v = m_speed->value();
-    v = (v/2) * 2 - 2; // target is always even
-    m_speed->setValue(v);
-    speedChange(m_speed->value());
-}
-*/
-

          
M src/Interface.h +1 -3
@@ 31,12 31,10 @@ protected slots:
     void play();
     void pause();
     void rewind();
-//    void speedUp();
-//    void slowDown();
+    void speedChanged(double);
     
 private:
     Processor *m_processor;
-    QDoubleSpinBox *m_speedSpin;
     QLabel *m_filenameLabel;
 };