comparison main/MainWindow.cpp @ 12:ee967635c728

* Some work on making the time stretcher squash as well as stretch
author Chris Cannam
date Tue, 12 Sep 2006 16:43:00 +0000
parents 0dbd08e365ce
children 085f34c73939
comparison
equal deleted inserted replaced
11:0dbd08e365ce 12:ee967635c728
151 this, SLOT(sampleRateMismatch(size_t, size_t, bool))); 151 this, SLOT(sampleRateMismatch(size_t, size_t, bool)));
152 152
153 m_fader = new Fader(frame, false); 153 m_fader = new Fader(frame, false);
154 154
155 m_playSpeed = new AudioDial(frame); 155 m_playSpeed = new AudioDial(frame);
156 m_playSpeed->setMinimum(1); 156 m_playSpeed->setMinimum(0);
157 m_playSpeed->setMaximum(10); 157 m_playSpeed->setMaximum(20);
158 m_playSpeed->setValue(10); 158 m_playSpeed->setValue(10);
159 m_playSpeed->setFixedWidth(24); 159 m_playSpeed->setFixedWidth(24);
160 m_playSpeed->setFixedHeight(24); 160 m_playSpeed->setFixedHeight(24);
161 m_playSpeed->setNotchesVisible(true); 161 m_playSpeed->setNotchesVisible(true);
162 m_playSpeed->setPageStep(1); 162 m_playSpeed->setPageStep(1);
2851 } 2851 }
2852 2852
2853 void 2853 void
2854 MainWindow::playSpeedChanged(int speed) 2854 MainWindow::playSpeedChanged(int speed)
2855 { 2855 {
2856 int factor = 11 - speed; 2856 static float factors[] = {
2857 1.0, 1.1, 1.2, 1.3, 1.5, 1.7, 2.0, 3.0, 4.0, 6.0, 10.0
2858 };
2859 float factor = factors[speed >= 10 ? speed - 10 : 10 - speed];
2860 // int factor = 11 - speed;
2861 if (speed > 10) factor = 1.0 / factor;
2862 std::cerr << "factor = " << factor << std::endl;
2863
2864 int iinc = 128;
2865 int oinc = lrintf(iinc * factor);
2866 factor = (float(oinc) + 0.01) / iinc;
2867 std::cerr << "corrected factor = " << factor << std::endl;
2868
2857 m_playSpeed->setToolTip(tr("Playback speed: %1") 2869 m_playSpeed->setToolTip(tr("Playback speed: %1")
2858 .arg(factor > 1 ? 2870 .arg(factor != 1 ?
2859 QString("1/%1").arg(factor) : 2871 QString("1/%1").arg(factor) :
2860 tr("Full"))); 2872 tr("Full")));
2861 m_playSource->setSlowdownFactor(factor); 2873 m_playSource->setSlowdownFactor(factor);
2862 } 2874 }
2863 2875