Merge lp:~mixxxdevelopers/mixxx/features_xwax2_albert into lp:~ywwg/mixxx/features_xwax2
- features_xwax2_albert
- Merge into features_xwax2
Proposed by
Albert Santoni
Status: | Merged |
---|---|
Merged at revision: | 2571 |
Proposed branch: | lp:~mixxxdevelopers/mixxx/features_xwax2_albert |
Merge into: | lp:~ywwg/mixxx/features_xwax2 |
Diff against target: |
724 lines (+172/-246) 12 files modified
mixxx/src/dlgprefvinyl.cpp (+13/-81) mixxx/src/dlgprefvinyl.h (+0/-7) mixxx/src/soundmanager.cpp (+7/-6) mixxx/src/soundmanager.h (+1/-0) mixxx/src/vinylcontrol.cpp (+20/-12) mixxx/src/vinylcontrol.h (+6/-4) mixxx/src/vinylcontrolproxy.cpp (+27/-0) mixxx/src/vinylcontrolproxy.h (+3/-0) mixxx/src/vinylcontrolscratchlib.cpp (+2/-2) mixxx/src/vinylcontrolsignalwidget.cpp (+81/-118) mixxx/src/vinylcontrolsignalwidget.h (+7/-10) mixxx/src/vinylcontrolxwax.cpp (+5/-6) |
To merge this branch: | bzr merge lp:~mixxxdevelopers/mixxx/features_xwax2_albert |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Owen Williams | Pending | ||
Review via email: mp+49926@code.launchpad.net |
Commit message
Description of the change
Here's the vinyl control signal quality widget changes and cleanup we discussed last night.
Thanks!
Albert
To post a comment you must log in.
Revision history for this message
Albert Santoni (gamegod) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'mixxx/src/dlgprefvinyl.cpp' |
2 | --- mixxx/src/dlgprefvinyl.cpp 2010-11-14 16:18:42 +0000 |
3 | +++ mixxx/src/dlgprefvinyl.cpp 2011-02-16 07:37:07 +0000 |
4 | @@ -43,17 +43,6 @@ |
5 | vinylControlMode.addButton(AbsoluteMode); |
6 | vinylControlMode.addButton(RelativeMode); |
7 | |
8 | - //Get access to the timecode strength ControlObjects |
9 | - m_timecodeQuality1 = new ControlObjectThreadMain(ControlObject::getControl(ConfigKey("[Channel1]", "VinylControlQuality"))); |
10 | - m_timecodeQuality2 = new ControlObjectThreadMain(ControlObject::getControl(ConfigKey("[Channel2]", "VinylControlQuality"))); |
11 | - |
12 | - m_vinylControlInput1L = new ControlObjectThreadMain(ControlObject::getControl(ConfigKey("[Channel1]", "VinylControlInputL"))); |
13 | - m_vinylControlInput1R = new ControlObjectThreadMain(ControlObject::getControl(ConfigKey("[Channel1]", "VinylControlInputR"))); |
14 | - m_vinylControlInput2L = new ControlObjectThreadMain(ControlObject::getControl(ConfigKey("[Channel2]", "VinylControlInputL"))); |
15 | - m_vinylControlInput2R = new ControlObjectThreadMain(ControlObject::getControl(ConfigKey("[Channel2]", "VinylControlInputR"))); |
16 | - |
17 | - |
18 | - |
19 | m_signalWidget1.setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
20 | m_signalWidget2.setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
21 | const unsigned signalWidgetWidth = 75; |
22 | @@ -62,8 +51,6 @@ |
23 | m_signalWidget2.setMinimumSize(signalWidgetWidth, signalWidgetHeight); |
24 | m_signalWidget1.setMaximumSize(signalWidgetWidth, signalWidgetHeight); |
25 | m_signalWidget2.setMaximumSize(signalWidgetWidth, signalWidgetHeight); |
26 | - m_signalWidget1.setupWidget(); |
27 | - m_signalWidget2.setupWidget(); |
28 | |
29 | delete groupBoxSignalQuality->layout(); |
30 | QHBoxLayout *layout = new QHBoxLayout; |
31 | @@ -98,14 +85,11 @@ |
32 | /** @brief Performs any necessary actions that need to happen when the prefs dialog is opened */ |
33 | void DlgPrefVinyl::slotShow() |
34 | { |
35 | - //Connect the signal quality ControlObjects to this dialog, so they start updating |
36 | - connect(m_timecodeQuality1, SIGNAL(valueChanged(double)), this, SLOT(updateSignalQuality1(double))); |
37 | - connect(m_timecodeQuality2, SIGNAL(valueChanged(double)), this, SLOT(updateSignalQuality2(double))); |
38 | - |
39 | - connect(m_vinylControlInput1L, SIGNAL(valueChanged(double)), this, SLOT(updateInputLevelLeft1(double))); |
40 | - connect(m_vinylControlInput1R, SIGNAL(valueChanged(double)), this, SLOT(updateInputLevelRight1(double))); |
41 | - connect(m_vinylControlInput2L, SIGNAL(valueChanged(double)), this, SLOT(updateInputLevelLeft2(double))); |
42 | - connect(m_vinylControlInput2R, SIGNAL(valueChanged(double)), this, SLOT(updateInputLevelRight2(double))); |
43 | + QList<VinylControlProxy*> VCProxiesList = m_pSoundManager->getVinylControlProxies(); |
44 | + if (VCProxiesList.value(0) != NULL) |
45 | + m_signalWidget1.setVinylControlProxy(VCProxiesList.value(0)); |
46 | + if (VCProxiesList.value(1) != NULL) |
47 | + m_signalWidget2.setVinylControlProxy(VCProxiesList.value(1)); |
48 | |
49 | //(Re)Initialize the signal quality indicators |
50 | m_signalWidget1.resetWidget(); |
51 | @@ -121,12 +105,6 @@ |
52 | //Stop updating the vinyl control signal indicators when the prefs dialog is closed. |
53 | m_signalWidget1.stopDrawing(); |
54 | m_signalWidget2.stopDrawing(); |
55 | - m_timecodeQuality1->disconnect(this); |
56 | - m_timecodeQuality2->disconnect(this); |
57 | - m_vinylControlInput1L->disconnect(this); |
58 | - m_vinylControlInput1R->disconnect(this); |
59 | - m_vinylControlInput2L->disconnect(this); |
60 | - m_vinylControlInput2R->disconnect(this); |
61 | } |
62 | |
63 | void DlgPrefVinyl::slotUpdate() |
64 | @@ -174,7 +152,6 @@ |
65 | //Apply updates for everything else... |
66 | VinylTypeSlotApply(); |
67 | VinylGainSlotApply(); |
68 | - AutoCalibrationSlotApply(); |
69 | |
70 | int iMode = 0; |
71 | if (AbsoluteMode->isChecked()) |
72 | @@ -201,11 +178,6 @@ |
73 | config->set(ConfigKey("[VinylControl]","strVinylType"), ConfigValue(ComboBoxVinylType->currentText())); |
74 | } |
75 | |
76 | -void DlgPrefVinyl::AutoCalibrationSlotApply() |
77 | -{ |
78 | - // Do the scratchlib calibration steps. |
79 | -} |
80 | - |
81 | void DlgPrefVinyl::VinylGainSlotApply() |
82 | { |
83 | qDebug() << "in VinylGainSlotApply()" << "with gain:" << VinylGain->value(); |
84 | @@ -220,56 +192,16 @@ |
85 | //gain->setText(config->getValueString(ConfigKey("[VinylControl]","VinylControlGain"))); //this is probably ineffecient... |
86 | } |
87 | |
88 | -/** @brief Wraps updateSignalQuality to work nicely with slots |
89 | - * @param value The new signal quality level for channel 1 (0.0f-1.0f) |
90 | - */ |
91 | -void DlgPrefVinyl::updateSignalQuality1(double value) |
92 | -{ |
93 | - m_signalWidget1.updateSignalQuality(VINYLCONTROL_SIGQUALITY, value); |
94 | -} |
95 | - |
96 | -/** @brief Wraps updateSignalQuality to work nicely with slots |
97 | - * @param value The new signal quality level for channel 2 (0.0f-1.0f) |
98 | - */ |
99 | -void DlgPrefVinyl::updateSignalQuality2(double value) |
100 | -{ |
101 | - m_signalWidget2.updateSignalQuality(VINYLCONTROL_SIGQUALITY, value); |
102 | -} |
103 | - |
104 | -/** @brief Wraps updateSignalQuality to work nicely with slots |
105 | - * @param value The new input level for the left channel of the first deck (0.0f-1.0f) |
106 | - */ |
107 | -void DlgPrefVinyl::updateInputLevelLeft1(double value) |
108 | -{ |
109 | - m_signalWidget1.updateSignalQuality(VINYLCONTROL_SIGLEFTCHANNEL, value); |
110 | -} |
111 | - |
112 | -/** @brief Wraps updateSignalQuality to work nicely with slots |
113 | - * @param value The new input level for the right channel of the first deck (0.0f-1.0f) |
114 | - */ |
115 | -void DlgPrefVinyl::updateInputLevelRight1(double value) |
116 | -{ |
117 | - m_signalWidget1.updateSignalQuality(VINYLCONTROL_SIGRIGHTCHANNEL, value); |
118 | -} |
119 | - |
120 | -/** @brief Wraps updateSignalQuality to work nicely with slots |
121 | - * @param value The new input level for the left channel of the second deck (0.0f-1.0f) |
122 | - */ |
123 | -void DlgPrefVinyl::updateInputLevelLeft2(double value) |
124 | -{ |
125 | - m_signalWidget2.updateSignalQuality(VINYLCONTROL_SIGLEFTCHANNEL, value); |
126 | -} |
127 | - |
128 | -/** @brief Wraps updateSignalQuality to work nicely with slots |
129 | - * @param value The new input level for the right channel of the second deck (0.0f-1.0f) |
130 | - */ |
131 | -void DlgPrefVinyl::updateInputLevelRight2(double value) |
132 | -{ |
133 | - m_signalWidget2.updateSignalQuality(VINYLCONTROL_SIGRIGHTCHANNEL, value); |
134 | -} |
135 | - |
136 | void DlgPrefVinyl::settingsChanged() { |
137 | if (!m_dontForce) { |
138 | emit(refreshVCProxies()); |
139 | } |
140 | + |
141 | + QList<VinylControlProxy*> VCProxiesList = m_pSoundManager->getVinylControlProxies(); |
142 | + if (VCProxiesList.value(0) != NULL) { |
143 | + m_signalWidget1.setVinylControlProxy(VCProxiesList.value(0)); |
144 | + } |
145 | + if (VCProxiesList.value(1) != NULL) { |
146 | + m_signalWidget2.setVinylControlProxy(VCProxiesList.value(1)); |
147 | + } |
148 | } |
149 | |
150 | === modified file 'mixxx/src/dlgprefvinyl.h' |
151 | --- mixxx/src/dlgprefvinyl.h 2010-11-01 01:23:18 +0000 |
152 | +++ mixxx/src/dlgprefvinyl.h 2011-02-16 07:37:07 +0000 |
153 | @@ -45,14 +45,7 @@ |
154 | void slotApply(); |
155 | void EnableRelativeModeSlotApply(); |
156 | void VinylTypeSlotApply(); |
157 | - void AutoCalibrationSlotApply(); |
158 | void VinylGainSlotApply(); |
159 | - void updateSignalQuality1(double value); |
160 | - void updateSignalQuality2(double value); |
161 | - void updateInputLevelLeft1(double value); |
162 | - void updateInputLevelRight1(double value); |
163 | - void updateInputLevelLeft2(double value); |
164 | - void updateInputLevelRight2(double value); |
165 | void slotClose(); |
166 | void slotShow(); |
167 | |
168 | |
169 | === modified file 'mixxx/src/soundmanager.cpp' |
170 | --- mixxx/src/soundmanager.cpp 2011-02-09 17:17:20 +0000 |
171 | +++ mixxx/src/soundmanager.cpp 2011-02-16 07:37:07 +0000 |
172 | @@ -55,12 +55,6 @@ |
173 | ControlObjectThreadMain* pControlObjectVinylControlMode1 = new ControlObjectThreadMain(ControlObject::getControl(ConfigKey("[Channel1]", "VinylMode"))); |
174 | ControlObjectThreadMain* pControlObjectVinylControlMode2 = new ControlObjectThreadMain(ControlObject::getControl(ConfigKey("[Channel2]", "VinylMode"))); |
175 | ControlObjectThreadMain* pControlObjectVinylControlGain = new ControlObjectThreadMain(new ControlObject(ConfigKey("[VinylControl]", "VinylControlGain"))); |
176 | - ControlObjectThreadMain* pControlObjectVinylControlSignalQuality1 = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Channel1]", "VinylControlQuality"))); |
177 | - ControlObjectThreadMain* pControlObjectVinylControlSignalQuality2 = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Channel2]", "VinylControlQuality"))); |
178 | - ControlObjectThreadMain* pControlObjectVinylControlInputStrengthL1 = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Channel1]", "VinylControlInputL"))); |
179 | - ControlObjectThreadMain* pControlObjectVinylControlInputStrengthR1 = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Channel1]", "VinylControlInputR"))); |
180 | - ControlObjectThreadMain* pControlObjectVinylControlInputStrengthL2 = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Channel2]", "VinylControlInputL"))); |
181 | - ControlObjectThreadMain* pControlObjectVinylControlInputStrengthR2 = new ControlObjectThreadMain(new ControlObject(ConfigKey("[Channel2]", "VinylControlInputR"))); |
182 | |
183 | //Hack because PortAudio samplerate enumeration is slow as hell on Linux (ALSA dmix sucks, so we can't blame PortAudio) |
184 | m_samplerates.push_back(44100); |
185 | @@ -371,6 +365,8 @@ |
186 | QHash<QString, VinylControlProxy*> vinyl_inputs; |
187 | m_VinylControl.append(new VinylControlProxy(m_pConfig, "[Channel1]")); |
188 | m_VinylControl.append(new VinylControlProxy(m_pConfig, "[Channel2]")); |
189 | + qDebug() << "Created VinylControlProxies" << |
190 | + m_VinylControl[0] << m_VinylControl[1]; |
191 | m_VinylMapping.clear(); |
192 | #endif |
193 | foreach (SoundDevice *device, m_devices) { |
194 | @@ -501,6 +497,11 @@ |
195 | return m_VinylControl[deck] && |
196 | m_inputBuffers.contains(m_VinylMapping[vinyl_control]); |
197 | } |
198 | + |
199 | +QList<VinylControlProxy*> SoundManager::getVinylControlProxies() |
200 | +{ |
201 | + return m_VinylControl; |
202 | +} |
203 | #endif |
204 | |
205 | int SoundManager::setConfig(SoundManagerConfig config) { |
206 | |
207 | === modified file 'mixxx/src/soundmanager.h' |
208 | --- mixxx/src/soundmanager.h 2010-11-27 17:09:04 +0000 |
209 | +++ mixxx/src/soundmanager.h 2011-02-16 07:37:07 +0000 |
210 | @@ -59,6 +59,7 @@ |
211 | SoundManagerConfig getConfig() const; |
212 | #ifdef __VINYLCONTROL__ |
213 | bool hasVinylInput(int deck); |
214 | + QList<VinylControlProxy*> getVinylControlProxies(); |
215 | #endif |
216 | int setConfig(SoundManagerConfig config); |
217 | void checkConfig(); |
218 | |
219 | === modified file 'mixxx/src/vinylcontrol.cpp' |
220 | --- mixxx/src/vinylcontrol.cpp 2011-01-17 15:42:43 +0000 |
221 | +++ mixxx/src/vinylcontrol.cpp 2011-02-16 07:37:07 +0000 |
222 | @@ -19,9 +19,6 @@ |
223 | mode = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "VinylMode"))); |
224 | enabled = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "vinylcontrol"))); |
225 | rateRange = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "rateRange"))); |
226 | - timecodeQuality = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "VinylControlQuality"))); |
227 | - timecodeInputL = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "VinylControlInputL"))); |
228 | - timecodeInputR = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "VinylControlInputR"))); |
229 | //vinylStatus = new ControlObject(ConfigKey(group,"VinylStatus")); |
230 | vinylStatus = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "VinylStatus"))); |
231 | rateDir = new ControlObjectThread(ControlObject::getControl(ConfigKey(group, "rate_dir"))); |
232 | @@ -32,6 +29,9 @@ |
233 | dVinylScratch = 0.0f; |
234 | dDriftControl = 0.0f; |
235 | fRateRange = 0.0f; |
236 | + m_fSignalLeft = 0.0f; |
237 | + m_fSignalRight = 0.0f; |
238 | + m_fTimecodeQuality = 0.0f; |
239 | |
240 | //Get the vinyl type |
241 | strVinylType = m_pConfig->getValueString(ConfigKey("[VinylControl]","strVinylType")); |
242 | @@ -76,12 +76,20 @@ |
243 | { |
244 | return dVinylScratch; |
245 | } |
246 | - |
247 | -//Returns some sort of indication of the vinyl's signal strength. |
248 | -//Range of fTimecodeStrength should be 0.0 to 1.0 |
249 | -/* |
250 | -float VinylControl::getTimecodeStrength() |
251 | -{ |
252 | - return fTimecodeStrength; |
253 | -} |
254 | -*/ |
255 | +float VinylControl::getSignalLeft() |
256 | +{ |
257 | + return m_fSignalLeft; |
258 | +} |
259 | + |
260 | +float VinylControl::getSignalRight() |
261 | +{ |
262 | + return m_fSignalRight; |
263 | +} |
264 | + |
265 | +/** Returns some sort of indication of the vinyl's signal quality. |
266 | + Range of m_fTimecodeQuality should be 0.0 to 1.0 */ |
267 | +float VinylControl::getTimecodeQuality() |
268 | +{ |
269 | + return m_fTimecodeQuality; |
270 | +} |
271 | + |
272 | |
273 | === modified file 'mixxx/src/vinylcontrol.h' |
274 | --- mixxx/src/vinylcontrol.h 2011-01-17 15:42:43 +0000 |
275 | +++ mixxx/src/vinylcontrol.h 2011-02-16 07:37:07 +0000 |
276 | @@ -38,7 +38,9 @@ |
277 | virtual void syncPosition() = 0; */ |
278 | virtual void AnalyseSamples(short* samples, size_t size) = 0; |
279 | virtual float getSpeed(); |
280 | - //virtual float getTimecodeStrength(); |
281 | + virtual float getSignalLeft(); |
282 | + virtual float getSignalRight(); |
283 | + virtual float getTimecodeQuality(); |
284 | protected: |
285 | virtual void run() = 0; // main thread loop |
286 | |
287 | @@ -54,9 +56,6 @@ |
288 | ControlObjectThread *mode; //The ControlObject used to get the vinyl control mode (absolute/relative/scratch) |
289 | ControlObjectThread *enabled; //The ControlObject used to get if the vinyl control is enabled or disabled. |
290 | ControlObjectThread *rateRange; //The ControlObject used to the get the pitch range from the prefs. |
291 | - ControlObjectThread *timecodeQuality; //The ControlObject used to notify the GUI about the quality of the timecode signal. |
292 | - ControlObjectThread *timecodeInputL; //The ControlObject used to notify the GUI about vinyl control left channel's volume. |
293 | - ControlObjectThread *timecodeInputR; //The ControlObject used to notify the GUI about vinyl control right channel's volume. |
294 | ControlObjectThread *vinylStatus; |
295 | ControlObjectThread *rateDir; //direction of rate |
296 | ControlObjectThread *loopEnabled; //looping enabled? |
297 | @@ -70,6 +69,9 @@ |
298 | //... these two values naturally drift apart, so we need to keep making adjustments to the pitch |
299 | //to stop it from getting bad. |
300 | float fRateRange; //The pitch range setting from Mixxx's preferences |
301 | + float m_fTimecodeQuality; //Used as a measure of the quality of the timecode signal. |
302 | + float m_fSignalLeft; //Measures the left channel's volume. |
303 | + float m_fSignalRight; //Measures the right channel's volume. |
304 | |
305 | unsigned long iSampleRate; |
306 | bool bIsEnabled; |
307 | |
308 | === modified file 'mixxx/src/vinylcontrolproxy.cpp' |
309 | --- mixxx/src/vinylcontrolproxy.cpp 2009-02-06 04:50:55 +0000 |
310 | +++ mixxx/src/vinylcontrolproxy.cpp 2011-02-16 07:37:07 +0000 |
311 | @@ -96,3 +96,30 @@ |
312 | else |
313 | return 0.0f; |
314 | } |
315 | + |
316 | +float VinylControlProxy::getSignalLeft() |
317 | +{ |
318 | + if (m_pVinylControl) |
319 | + return m_pVinylControl->getSignalLeft(); |
320 | + else |
321 | + return 0.0f; |
322 | +} |
323 | + |
324 | +float VinylControlProxy::getSignalRight() |
325 | +{ |
326 | + if (m_pVinylControl) |
327 | + return m_pVinylControl->getSignalRight(); |
328 | + else |
329 | + return 0.0f; |
330 | +} |
331 | + |
332 | +/** Returns some sort of indication of the vinyl's signal quality. |
333 | + Range of m_fTimecodeQuality should be 0.0 to 1.0 */ |
334 | +float VinylControlProxy::getTimecodeQuality() |
335 | +{ |
336 | + if (m_pVinylControl) |
337 | + return m_pVinylControl->getTimecodeQuality(); |
338 | + else |
339 | + return 0.0f; |
340 | +} |
341 | + |
342 | |
343 | === modified file 'mixxx/src/vinylcontrolproxy.h' |
344 | --- mixxx/src/vinylcontrolproxy.h 2007-08-22 04:26:44 +0000 |
345 | +++ mixxx/src/vinylcontrolproxy.h 2011-02-16 07:37:07 +0000 |
346 | @@ -15,6 +15,9 @@ |
347 | void ToggleVinylControl(bool enable); |
348 | void run(); |
349 | float getSpeed(); |
350 | + float getSignalLeft(); |
351 | + float getSignalRight(); |
352 | + float getTimecodeQuality(); |
353 | protected: |
354 | VinylControl* m_pVinylControl; //Pointer to active VinylControl object |
355 | }; |
356 | |
357 | === modified file 'mixxx/src/vinylcontrolscratchlib.cpp' |
358 | --- mixxx/src/vinylcontrolscratchlib.cpp 2009-07-12 08:02:43 +0000 |
359 | +++ mixxx/src/vinylcontrolscratchlib.cpp 2011-02-16 07:37:07 +0000 |
360 | @@ -100,9 +100,9 @@ |
361 | } |
362 | |
363 | if (strVinylType == MIXXX_VINYL_FINALSCRATCH) |
364 | - timecodeQuality->slotSet(analyzer->GetTimecodesPerSecond() / 32); |
365 | + m_fTimecodeQuality = analyzer->GetTimecodesPerSecond() / 32; |
366 | else if (strVinylType == MIXXX_VINYL_MIXVIBESDVSCD) |
367 | - timecodeQuality->slotSet(analyzer->GetTimecodesPerSecond() / 32); |
368 | + m_fTimecodeQuality = analyzer->GetTimecodesPerSecond() / 32; |
369 | |
370 | waitForNextInput.wakeAll(); |
371 | lockSamples.unlock(); |
372 | |
373 | === modified file 'mixxx/src/vinylcontrolsignalwidget.cpp' |
374 | --- mixxx/src/vinylcontrolsignalwidget.cpp 2009-07-24 06:39:43 +0000 |
375 | +++ mixxx/src/vinylcontrolsignalwidget.cpp 2011-02-16 07:37:07 +0000 |
376 | @@ -15,30 +15,51 @@ |
377 | * * |
378 | ***************************************************************************/ |
379 | |
380 | +/** |
381 | + TODO(XXX): Feb 2011 - asantoni |
382 | + * This class probably doesn't need the locking anymore. |
383 | |
384 | +*/ |
385 | |
386 | #include <QtCore> |
387 | #include <QtGui> |
388 | +#include <math.h> |
389 | #include "vinylcontrolsignalwidget.h" |
390 | -#include <math.h> |
391 | -#include <stdlib.h> |
392 | +#include "vinylcontrolproxy.h" |
393 | |
394 | VinylControlSignalWidget::VinylControlSignalWidget() |
395 | - : QGraphicsView(), |
396 | - m_iTimerId(0) { |
397 | + : QWidget(), |
398 | + m_iTimerId(0), |
399 | + m_pVinylControl(NULL) { |
400 | for (int type = 0; type < (int) VINYLCONTROL_SIGTYPE_NUM; type++) { |
401 | - m_signalRectItem[type] = NULL; |
402 | } |
403 | - setupWidget(); |
404 | + |
405 | } |
406 | |
407 | VinylControlSignalWidget::~VinylControlSignalWidget() |
408 | { |
409 | } |
410 | |
411 | +/** This gets called before the VinylControlProxy objects get destroyed, in |
412 | + order to prevent us from having bad pointers dangling. */ |
413 | +void VinylControlSignalWidget::invalidateVinylControl() |
414 | +{ |
415 | + m_pVinylControl = NULL; |
416 | +} |
417 | + |
418 | +void VinylControlSignalWidget::setVinylControlProxy(VinylControlProxy* vc) |
419 | +{ |
420 | + |
421 | + m_pVinylControl = vc; |
422 | + //Catch when the VinylControl objects get deleted (like when |
423 | + //you change your vinyl type) |
424 | + connect(m_pVinylControl, SIGNAL(destroyed()), |
425 | + this, SLOT(invalidateVinylControl())); |
426 | +} |
427 | + |
428 | void VinylControlSignalWidget::startDrawing() { |
429 | if (m_iTimerId == 0) { |
430 | - m_iTimerId = startTimer(50); |
431 | + m_iTimerId = startTimer(60); |
432 | } |
433 | } |
434 | |
435 | @@ -50,134 +71,76 @@ |
436 | } |
437 | |
438 | void VinylControlSignalWidget::timerEvent(QTimerEvent *event) { |
439 | - updateScene(); |
440 | + if (m_pVinylControl) { |
441 | + updateSignalQuality(VINYLCONTROL_SIGQUALITY, |
442 | + m_pVinylControl->getTimecodeQuality()); |
443 | + updateSignalQuality(VINYLCONTROL_SIGLEFTCHANNEL, |
444 | + m_pVinylControl->getSignalLeft()); |
445 | + updateSignalQuality(VINYLCONTROL_SIGRIGHTCHANNEL, |
446 | + m_pVinylControl->getSignalRight()); |
447 | + } |
448 | + else { |
449 | + updateSignalQuality(VINYLCONTROL_SIGQUALITY, |
450 | + 0.0f); |
451 | + updateSignalQuality(VINYLCONTROL_SIGLEFTCHANNEL, |
452 | + 0.0f); |
453 | + updateSignalQuality(VINYLCONTROL_SIGRIGHTCHANNEL, |
454 | + 0.0f); |
455 | + } |
456 | + update(); |
457 | } |
458 | |
459 | -void VinylControlSignalWidget::updateScene() { |
460 | +void VinylControlSignalWidget::resetWidget() |
461 | +{ |
462 | m_controlLock.lock(); |
463 | + for (int type = 0; type < (int)VINYLCONTROL_SIGTYPE_NUM; type++) |
464 | + { |
465 | + m_fRMSvolumeSum[type] = 0.0f; |
466 | + m_fRMSvolume[type] = 0.0f; |
467 | + m_samplesCalculated[type] = 0; |
468 | + } |
469 | + m_controlLock.unlock(); |
470 | +} |
471 | + |
472 | +void VinylControlSignalWidget::paintEvent(QPaintEvent* event) |
473 | +{ |
474 | + int sizeX = this->width(); |
475 | + int sizeY = this->height(); |
476 | + |
477 | + QPainter painter(this); |
478 | + //painter.fillRect(this->rect(), QBrush(Qt::black)); |
479 | + |
480 | + //Paint the background as a measure of whether or not the timecode is |
481 | + //being successfully decoded. |
482 | + painter.fillRect(this->rect(), QBrush(QColor(0, m_fRMSvolume[0]*255, 0))); |
483 | + |
484 | for (int type = 0; type < (int)VINYLCONTROL_SIGTYPE_NUM; type++) { |
485 | |
486 | if (m_samplesCalculated[type] == 0) |
487 | continue; |
488 | - |
489 | QBrush brush; |
490 | if (type == VINYLCONTROL_SIGQUALITY) { |
491 | - if (m_fRMSvolume[type] >= 0.990f) { |
492 | - m_textItem->setPlainText(tr("OK")); |
493 | - brush = QBrush(m_signalGradGood); |
494 | - } |
495 | - else { |
496 | - m_textItem->setPlainText(tr("")); |
497 | - brush = QBrush(m_signalGradBad); |
498 | - } |
499 | + //Hmmm. |
500 | } |
501 | else { //For the left/right channel signals. |
502 | - if (m_fRMSvolume[type] < 0.90f && m_fRMSvolume[type] > 0.10f) { //This is totally empirical. |
503 | - brush = QBrush(m_signalGradGood); |
504 | - } else { |
505 | - brush = QBrush(m_signalGradBad); |
506 | - } |
507 | + |
508 | + painter.setPen(QPen(Qt::white)); |
509 | + int width = m_fRMSvolume[1]*sizeX; |
510 | + int height = m_fRMSvolume[2]*sizeY; |
511 | + int centerX = (sizeX-width) / 2; |
512 | + int centerY = (sizeY-height) / 2; |
513 | + painter.drawEllipse(centerX, |
514 | + centerY, |
515 | + width, |
516 | + height); |
517 | } |
518 | - |
519 | - //The QGraphicsView coord system is upside down... |
520 | - int sizeY = this->height(); |
521 | - m_signalRect[type].setHeight(-m_fRMSvolume[type] * sizeY); |
522 | - m_signalRectItem[type]->setBrush(brush); |
523 | - m_signalRectItem[type]->setRect(m_signalRect[type]); |
524 | |
525 | // Reset calculation: |
526 | m_fRMSvolumeSum[type] = 0; |
527 | m_samplesCalculated[type] = 0; |
528 | } |
529 | - m_controlLock.unlock(); |
530 | -} |
531 | - |
532 | -void VinylControlSignalWidget::resetWidget() |
533 | -{ |
534 | - m_controlLock.lock(); |
535 | - for (int type = 0; type < (int)VINYLCONTROL_SIGTYPE_NUM; type++) |
536 | - { |
537 | - m_fRMSvolumeSum[type] = 0.0f; |
538 | - m_fRMSvolume[type] = 0.0f; |
539 | - m_samplesCalculated[type] = 0; |
540 | - } |
541 | - m_controlLock.unlock(); |
542 | -} |
543 | - |
544 | - |
545 | -void VinylControlSignalWidget::setupWidget() |
546 | -{ |
547 | - int sizeX = this->width(); |
548 | - int sizeY = this->height(); |
549 | - |
550 | - m_signalScene.setSceneRect(0,0,sizeX, sizeY); |
551 | - m_signalScene.setBackgroundBrush(Qt::black); |
552 | - |
553 | - this->setInteractive(false); |
554 | - |
555 | - //Disable any scrollbars on the QGraphicsView |
556 | - this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
557 | - this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
558 | - |
559 | - //Initialize QPens |
560 | - QPen gridPen(Qt::green); |
561 | - QPen graphLinePen(Qt::white); |
562 | - QPen signalPen(Qt::black); |
563 | - |
564 | - m_signalGradGood = QLinearGradient(0, 0, 0, rect().height()); |
565 | - m_signalGradBad = QLinearGradient(0, 0, 0, rect().height()); |
566 | - m_signalGradGood.setColorAt(0, Qt::green); |
567 | - m_signalGradGood.setColorAt(1, Qt::darkGreen); |
568 | - m_signalGradBad.setColorAt(0, Qt::red); |
569 | - m_signalGradBad.setColorAt(1, Qt::darkRed); |
570 | - |
571 | - |
572 | - //QBrush signalBrush[VINYLCONTROL_SIGTYPE_NUM]; |
573 | - //QPixmap bg1(this->width() / 3, this->height()); |
574 | - /* |
575 | - QPainter painter(m_bg[type]); |
576 | - painter.fillRect(m_bg1->rect(), QBrush(QColor(0, 0, 255))); |
577 | - painter.setPen(Qt::red); |
578 | - painter.setFont(QFont("Tahoma", 8)); |
579 | - painter.drawText(rect(), tr("OK")); //Draw the OK text |
580 | - painter.end(); |
581 | - */ |
582 | - |
583 | - //draw grid |
584 | -#define GRID_X_LINES 3 |
585 | -#define GRID_Y_LINES 3 |
586 | - for(int i=1; i < GRID_X_LINES; i++) |
587 | - { |
588 | - QGraphicsItem* line = m_signalScene.addLine(QLineF(0, i *(sizeY/GRID_X_LINES), |
589 | - sizeX,i *(sizeY/GRID_X_LINES)), gridPen); |
590 | - line->setZValue(0); |
591 | - } |
592 | - for(int i=1; i < GRID_Y_LINES; i++) |
593 | - { |
594 | - QGraphicsItem* line = m_signalScene.addLine(QLineF( i * (sizeX/GRID_Y_LINES), 0, |
595 | - i * (sizeX/GRID_Y_LINES), sizeY), gridPen); |
596 | - line->setZValue(0); |
597 | - } |
598 | - |
599 | - for (int type = 0; type < (int)VINYLCONTROL_SIGTYPE_NUM; type++) |
600 | - { |
601 | - m_signalRect[type].setX(type * (sizeX / 3)); |
602 | - m_signalRect[type].setY(sizeY); |
603 | - m_signalRect[type].setWidth(sizeX / 3); |
604 | - m_signalRect[type].setHeight(1); |
605 | - m_signalRectItem[type] = m_signalScene.addRect(m_signalRect[type], |
606 | - signalPen, |
607 | - QBrush(m_signalGradGood)); |
608 | - m_signalRectItem[type]->setZValue(1); |
609 | - } |
610 | - |
611 | - m_textItem = m_signalScene.addText("", QFont("Tahoma", 8)); |
612 | - m_textItem->setPos(QPointF(1, 1)); |
613 | - m_textItem->setDefaultTextColor(QColor(0,0,0)); |
614 | - m_textItem->setZValue(2); |
615 | - |
616 | - this->setScene(&m_signalScene); |
617 | -} |
618 | +} |
619 | + |
620 | |
621 | /** @brief Wraps Updates the signal quality indicators with a given signal strength |
622 | * @param indicator_index Identifies the corresponding channel and indicator to be updated. |
623 | |
624 | === modified file 'mixxx/src/vinylcontrolsignalwidget.h' |
625 | --- mixxx/src/vinylcontrolsignalwidget.h 2009-07-24 06:39:43 +0000 |
626 | +++ mixxx/src/vinylcontrolsignalwidget.h 2011-02-16 07:37:07 +0000 |
627 | @@ -8,11 +8,12 @@ |
628 | #ifndef VINYLCONTROLSIGNALWIDGET_H_ |
629 | #define VINYLCONTROLSIGNALWIDGET_H_ |
630 | |
631 | - |
632 | #include <QtGui> |
633 | #include <QPainter> |
634 | #include <QTimerEvent> |
635 | |
636 | +class VinylControlProxy; |
637 | + |
638 | enum VinylControlSignalType { |
639 | VINYLCONTROL_SIGQUALITY = 0, |
640 | VINYLCONTROL_SIGLEFTCHANNEL, |
641 | @@ -20,35 +21,31 @@ |
642 | VINYLCONTROL_SIGTYPE_NUM |
643 | }; |
644 | |
645 | -class VinylControlSignalWidget : public QGraphicsView |
646 | +class VinylControlSignalWidget : public QWidget |
647 | { |
648 | Q_OBJECT |
649 | public: |
650 | VinylControlSignalWidget(); |
651 | ~VinylControlSignalWidget(); |
652 | + void setVinylControlProxy(VinylControlProxy* vc); |
653 | + void paintEvent(QPaintEvent* event); |
654 | |
655 | void resetWidget(); |
656 | void startDrawing(); |
657 | void stopDrawing(); |
658 | - void updateScene(); |
659 | - void setupWidget(); |
660 | |
661 | public slots: |
662 | void updateSignalQuality(VinylControlSignalType type, double value); |
663 | + void invalidateVinylControl(); |
664 | |
665 | protected: |
666 | void timerEvent (QTimerEvent* event); |
667 | |
668 | private: |
669 | QMutex m_controlLock; |
670 | - QGraphicsScene m_signalScene; |
671 | - QGraphicsRectItem* m_signalRectItem[VINYLCONTROL_SIGTYPE_NUM]; |
672 | - QGraphicsTextItem* m_textItem; |
673 | + VinylControlProxy* m_pVinylControl; |
674 | QRectF m_signalRect[VINYLCONTROL_SIGTYPE_NUM]; |
675 | |
676 | - QLinearGradient m_signalGradGood; |
677 | - QLinearGradient m_signalGradBad; |
678 | - |
679 | float m_fRMSvolumeSum[VINYLCONTROL_SIGTYPE_NUM]; |
680 | float m_fRMSvolume[VINYLCONTROL_SIGTYPE_NUM]; |
681 | long m_samplesCalculated[VINYLCONTROL_SIGTYPE_NUM]; |
682 | |
683 | === modified file 'mixxx/src/vinylcontrolxwax.cpp' |
684 | --- mixxx/src/vinylcontrolxwax.cpp 2011-01-30 15:37:55 +0000 |
685 | +++ mixxx/src/vinylcontrolxwax.cpp 2011-02-16 07:37:07 +0000 |
686 | @@ -131,9 +131,8 @@ |
687 | timecoder_submit(&timecoder, samples, size); |
688 | |
689 | //Update the input signal strength |
690 | - //qDebug() << group << (float)fabs((float)samples[0]); |
691 | - timecodeInputL->slotSet((float)fabs((float)samples[0]) / SHRT_MAX * 2.0f); |
692 | - timecodeInputR->slotSet((float)fabs((float)samples[1]) / SHRT_MAX * 2.0f); |
693 | + m_fSignalLeft = ((float)fabs((float)samples[0])) / SHRT_MAX * 2.0f; |
694 | + m_fSignalRight = ((float)fabs((float)samples[1])) / SHRT_MAX * 2.0f; |
695 | |
696 | bHaveSignal = fabs((float)samples[0]) + fabs((float)samples[1]) > MIN_SIGNAL; |
697 | //qDebug() << "signal?" << bHaveSignal; |
698 | @@ -325,7 +324,7 @@ |
699 | { |
700 | //POSITION: MAYBE PITCH: YES |
701 | //Notify the UI that the timecode quality is good |
702 | - timecodeQuality->slotSet(1.0f); |
703 | + m_fTimecodeQuality = 1.0f; |
704 | |
705 | //dVinylPitch = (dOldPitch * (XWAX_SMOOTHING - 1) + dVinylPitch) / XWAX_SMOOTHING; |
706 | |
707 | @@ -453,7 +452,7 @@ |
708 | |
709 | dOldPos = filePosition + dDriftAmt; |
710 | if (uiUpdateTime(filePosition)) |
711 | - timecodeQuality->slotSet(0.75f); |
712 | + m_fTimecodeQuality = 0.75f; |
713 | |
714 | if (dVinylPitch > 0.2) |
715 | { |
716 | @@ -522,7 +521,7 @@ |
717 | controlScratch->slotSet(0.0f); |
718 | //resetSteadyPitch(dVinylPitch, filePosition); |
719 | //Notify the UI that the timecode quality is garbage/missing. |
720 | - timecodeQuality->slotSet(0.0f); |
721 | + m_fTimecodeQuality = 0.0f; |
722 | ringPos = 0; |
723 | ringFilled = 0; |
724 | vinylStatus->slotSet(VINYL_STATUS_OK); |
P.S. Here's a video: http:// dl.dropbox. com/u/215333/ mixxx_vinylsig. ogg