comparison main/MainWindow.cpp @ 25:e74f508db18c

* Add setRatio method to the time stretcher, and make it possible to change the ratio without having to construct and replace the time stretcher. This means we can do it seamlessly. Add a lot more ratios to the time stretch control in the main window
author Chris Cannam
date Fri, 15 Sep 2006 15:35:06 +0000
parents ae0731ba8e67
children d88d117e0c34
comparison
equal deleted inserted replaced
24:ae0731ba8e67 25:e74f508db18c
153 153
154 m_fader = new Fader(frame, false); 154 m_fader = new Fader(frame, false);
155 155
156 m_playSpeed = new AudioDial(frame); 156 m_playSpeed = new AudioDial(frame);
157 m_playSpeed->setMinimum(0); 157 m_playSpeed->setMinimum(0);
158 m_playSpeed->setMaximum(20); 158 m_playSpeed->setMaximum(199);
159 m_playSpeed->setValue(10); 159 m_playSpeed->setValue(100);
160 m_playSpeed->setFixedWidth(24); 160 m_playSpeed->setFixedWidth(24);
161 m_playSpeed->setFixedHeight(24); 161 m_playSpeed->setFixedHeight(24);
162 m_playSpeed->setNotchesVisible(true); 162 m_playSpeed->setNotchesVisible(true);
163 m_playSpeed->setPageStep(1); 163 m_playSpeed->setPageStep(10);
164 m_playSpeed->setToolTip(tr("Playback speed: Full")); 164 m_playSpeed->setToolTip(tr("Playback speed: +0%"));
165 m_playSpeed->setDefaultValue(10); 165 m_playSpeed->setDefaultValue(100);
166 connect(m_playSpeed, SIGNAL(valueChanged(int)), 166 connect(m_playSpeed, SIGNAL(valueChanged(int)),
167 this, SLOT(playSpeedChanged(int))); 167 this, SLOT(playSpeedChanged(int)));
168 168
169 m_playSharpen = new QCheckBox(frame); 169 m_playSharpen = new QCheckBox(frame);
170 m_playSharpen->setToolTip(tr("Sharpen percussive transients")); 170 m_playSharpen->setToolTip(tr("Sharpen percussive transients"));
2868 } 2868 }
2869 2869
2870 void 2870 void
2871 MainWindow::playSpeedChanged(int speed) 2871 MainWindow::playSpeedChanged(int speed)
2872 { 2872 {
2873 static float factors[] = { 2873 // static float factors[] = {
2874 1.0, 1.1, 1.2, 1.3, 1.5, 1.7, 2.0, 3.0, 4.0, 6.0, 10.0 2874 // 1.0, 1.1, 1.2, 1.3, 1.5, 1.7, 2.0, 3.0, 4.0, 6.0, 10.0
2875 }; 2875 // };
2876 float factor = factors[speed >= 10 ? speed - 10 : 10 - speed]; 2876 // float factor = factors[speed >= 10 ? speed - 10 : 10 - speed];
2877
2878 bool slow = false;
2879 bool something = false;
2880 float factor;
2881
2882 if (speed < 100) {
2883 slow = true;
2884 speed = 100 - speed;
2885 } else {
2886 speed = speed - 100;
2887 }
2888
2889 // speed is 0 -> 100
2890
2891 if (speed == 0) {
2892 factor = 1.0;
2893 } else {
2894 factor = speed;
2895 factor = 1.0 + (factor * factor) / 1000.f;
2896 something = true;
2897 }
2877 2898
2878 int pc = lrintf((factor - 1.0) * 100); 2899 int pc = lrintf((factor - 1.0) * 100);
2879 2900
2880 if (speed > 10) { 2901 if (!slow) factor = 1.0 / factor;
2881 factor = 1.0 / factor; 2902
2882 } 2903 std::cerr << "speed = " << speed << " factor = " << factor << std::endl;
2883
2884 std::cerr << "factor = " << factor << std::endl;
2885 2904
2886 m_playSpeed->setToolTip(tr("Playback speed: %1%2%") 2905 m_playSpeed->setToolTip(tr("Playback speed: %1%2%")
2887 .arg(speed >= 10 ? "+" : "-") 2906 .arg(!slow ? "+" : "-")
2888 .arg(pc)); 2907 .arg(pc));
2889 2908
2890 m_playSharpen->setEnabled(speed != 10); 2909 m_playSharpen->setEnabled(something);
2891 bool sharpen = (speed != 10 && m_playSharpen->isChecked()); 2910 bool sharpen = (something && m_playSharpen->isChecked());
2892 m_playSource->setSlowdownFactor(factor, sharpen); 2911 m_playSource->setSlowdownFactor(factor, sharpen);
2893 } 2912 }
2894 2913
2895 void 2914 void
2896 MainWindow::playSharpenToggled() 2915 MainWindow::playSharpenToggled()