=== modified file 'mixxx/src/controlvaluedelegate.cpp' --- mixxx/src/controlvaluedelegate.cpp 2011-04-26 18:12:18.000000000 +0530 +++ mixxx/src/controlvaluedelegate.cpp 2011-04-26 23:46:47.000000000 +0530 @@ -25,6 +25,7 @@ { if (m_channelControlValues.isEmpty()) //List is static/shared across all objects, so only fill once. { + m_channelControlValues.append("zoom_waveform"); m_channelControlValues.append("beatsync"); m_channelControlValues.append("cue_default"); m_channelControlValues.append("filterHigh"); === modified file 'mixxx/src/engine/ratecontrol.cpp' --- mixxx/src/engine/ratecontrol.cpp 2011-04-26 18:12:18.000000000 +0530 +++ mixxx/src/engine/ratecontrol.cpp 2011-04-26 23:46:47.000000000 +0530 @@ -44,6 +44,8 @@ m_pRateDir = new ControlObject(ConfigKey(_group, "rate_dir")); m_pRateRange = new ControlObject(ConfigKey(_group, "rateRange")); m_pRateSlider = new ControlPotmeter(ConfigKey(_group, "rate"), -1.f, 1.f); + + m_pZoomWaveform = new ControlPotmeter(ConfigKey(_group, "zoom_waveform"), -0.8f, 0.8f); // Search rate. Rate used when searching in sound. This overrules the // playback rate === modified file 'mixxx/src/engine/ratecontrol.h' --- mixxx/src/engine/ratecontrol.h 2011-04-26 18:12:18.000000000 +0530 +++ mixxx/src/engine/ratecontrol.h 2011-04-26 23:46:47.000000000 +0530 @@ -94,6 +94,7 @@ ControlObject *m_pRateDir, *m_pRateRange; ControlPotmeter* m_pRateSlider; ControlPotmeter* m_pRateSearch; + ControlPotmeter* m_pZoomWaveform; ControlPushButton* m_pReverseButton; ControlObject* m_pBackButton; ControlObject* m_pForwardButton; === modified file 'mixxx/src/waveform/waveformrenderbeat.cpp' --- mixxx/src/waveform/waveformrenderbeat.cpp 2011-04-26 18:12:18.000000000 +0530 +++ mixxx/src/waveform/waveformrenderbeat.cpp 2011-04-27 00:21:36.000000000 +0530 @@ -27,7 +27,14 @@ m_dSamplesPerDownsample(-1), m_iNumSamples(0), m_iSampleRate(0), - m_bBeatActive(false) { + m_bBeatActive(false), + zoom(0) { + + m_pZoomWaveform = new ControlObjectThreadMain(ControlObject::getControl(ConfigKey(group, "zoom_waveform"))); + connect(m_pZoomWaveform, SIGNAL(valueChanged(double)), + this, SLOT(slotUpdateZoom(double))); + + m_pTrackSamples = new ControlObjectThreadMain( ControlObject::getControl(ConfigKey(group,"track_samples"))); slotUpdateTrackSamples(m_pTrackSamples->get()); @@ -80,6 +87,11 @@ m_bBeatActive = beatActive > 0; } +// slot to control zooming of waveform +void WaveformRenderBeat::slotUpdateZoom(double newZoom) { + zoom = newZoom; +} + void WaveformRenderBeat::resize(int w, int h) { m_iWidth = w; m_iHeight = h; @@ -130,7 +142,7 @@ // Therefore, sample s is a beat if it satisfies s % 60f/b == 0. // where s is a /mono/ sample - double subpixelsPerPixel = m_pParent->getSubpixelsPerPixel()*(1.0+rateAdjust); + double subpixelsPerPixel = m_pParent->getSubpixelsPerPixel()*(1.0+rateAdjust)*(1.0+zoom); pPainter->save(); pPainter->scale(1.0/subpixelsPerPixel,1.0); @@ -141,8 +153,8 @@ double halfh = m_iHeight/2; // basePos and endPos are in samples - double basePos = iCurPos - m_dSamplesPerPixel * m_iWidth * (1.0+rateAdjust); - double endPos = basePos + (2 * m_iWidth) * m_dSamplesPerPixel * (1.0+rateAdjust); + double basePos = iCurPos - m_dSamplesPerPixel * m_iWidth * (1.0+rateAdjust) * (1.0+zoom); + double endPos = basePos + (2 * m_iWidth) * m_dSamplesPerPixel * (1.0+rateAdjust) * (1.0+zoom); m_beatList.clear(); === modified file 'mixxx/src/waveform/waveformrenderbeat.h' --- mixxx/src/waveform/waveformrenderbeat.h 2011-04-26 18:12:18.000000000 +0530 +++ mixxx/src/waveform/waveformrenderbeat.h 2011-04-27 00:22:22.000000000 +0530 @@ -32,12 +32,14 @@ void slotUpdateTrackSamples(double samples); void slotUpdateBeatActive(double beatActive); void slotUpdateTrackSampleRate(double sampleRate); + void slotUpdateZoom(double newZoom); private: WaveformRenderer *m_pParent; ControlObjectThreadMain* m_pTrackSamples; ControlObjectThreadMain *m_pTrackSampleRate; ControlObjectThreadMain* m_pBeatActive; + ControlObjectThreadMain* m_pZoomWaveform; TrackPointer m_pTrack; int m_iWidth, m_iHeight; QColor colorMarks; @@ -48,6 +50,7 @@ int m_iSampleRate; bool m_bBeatActive; BeatList m_beatList; + float zoom; }; #endif === modified file 'mixxx/src/waveform/waveformrendermark.cpp' --- mixxx/src/waveform/waveformrendermark.cpp 2011-04-26 18:12:18.000000000 +0530 +++ mixxx/src/waveform/waveformrendermark.cpp 2011-04-27 00:42:53.000000000 +0530 @@ -29,7 +29,15 @@ m_bHasCustomPixmap(false), m_dSamplesPerDownsample(-1), m_iNumSamples(0), - m_iSampleRate(-1) { + m_iSampleRate(-1), + zoom(0) + { + + m_pZoomWaveform = new ControlObjectThreadMain( + ControlObject::getControl(ConfigKey(m_pGroup, "zoom_waveform"))); + connect(m_pZoomWaveform, SIGNAL(valueChanged(double)), + this, SLOT(slotUpdateZoom(double))); + m_pTrackSamples = new ControlObjectThreadMain( ControlObject::getControl(ConfigKey(pGroup, "track_samples"))); slotUpdateTrackSamples(m_pTrackSamples->get()); @@ -72,6 +80,11 @@ m_dSamplesPerDownsample = n; } +// slot to control zooming of waveform +void WaveformRenderMark::slotUpdateZoom(double newZoom) { + zoom = newZoom; +} + void WaveformRenderMark::resize(int w, int h) { m_iWidth = w; m_iHeight = h; @@ -157,7 +170,7 @@ if (buffer == NULL) return; - double subpixelsPerPixel = m_pParent->getSubpixelsPerPixel()*(1.0+rateAdjust); + double subpixelsPerPixel = m_pParent->getSubpixelsPerPixel()*(1.0+rateAdjust)* (1.0+zoom); pPainter->save(); pPainter->scale(1.0/subpixelsPerPixel,1.0); === modified file 'mixxx/src/waveform/waveformrendermark.h' --- mixxx/src/waveform/waveformrendermark.h 2011-04-26 18:12:18.000000000 +0530 +++ mixxx/src/waveform/waveformrendermark.h 2011-04-27 00:40:13.000000000 +0530 @@ -34,6 +34,7 @@ void slotUpdateMarkPoint(double mark); void slotUpdateTrackSamples(double samples); void slotUpdateTrackSampleRate(double sampleRate); + void slotUpdateZoom(double newZoom); private: void setupMarkPixmap(); @@ -49,6 +50,7 @@ ControlObjectThreadMain *m_pMarkPoint; ControlObjectThreadMain *m_pTrackSamples; ControlObjectThreadMain *m_pTrackSampleRate; + ControlObjectThreadMain *m_pZoomWaveform; int m_iMarkPoint; int m_iWidth, m_iHeight; @@ -63,6 +65,7 @@ int m_iNumSamples; int m_iSampleRate; + float zoom; }; #endif === modified file 'mixxx/src/waveform/waveformrendersignal.cpp' --- mixxx/src/waveform/waveformrendersignal.cpp 2011-04-26 18:12:18.000000000 +0530 +++ mixxx/src/waveform/waveformrendersignal.cpp 2011-04-27 00:31:54.000000000 +0530 @@ -23,7 +23,15 @@ m_fGain(1), m_lines(0), m_pTrack(NULL), - signalColor(255,255,255) { + signalColor(255,255,255), + zoom(0) + { + + m_pZoomWaveform = new ControlObjectThreadMain( + ControlObject::getControl(ConfigKey(group, "zoom_waveform"))); + connect(m_pZoomWaveform, SIGNAL(valueChanged(double)), + this, SLOT(slotUpdateZoom(double))); + m_pGain = new ControlObjectThreadMain( ControlObject::getControl(ConfigKey(group, "total_gain"))); if (m_pGain != NULL) { @@ -37,6 +45,11 @@ delete m_pGain; } +// slot to control zooming of waveform +void WaveformRenderSignal::slotUpdateZoom(double newZoom) { + zoom = newZoom; +} + void WaveformRenderSignal::resize(int w, int h) { m_iWidth = w; m_iHeight = h; @@ -76,7 +89,7 @@ pPainter->setPen(signalColor); - const double subpixelsPerPixel = m_pParent->getSubpixelsPerPixel() * (1.0 + rateAdjust); + double subpixelsPerPixel = m_pParent->getSubpixelsPerPixel() * (1.0 + rateAdjust) * (1.0 + zoom); int subpixelWidth = int(m_iWidth * subpixelsPerPixel); === modified file 'mixxx/src/waveform/waveformrendersignal.h' --- mixxx/src/waveform/waveformrendersignal.h 2011-04-26 18:12:18.000000000 +0530 +++ mixxx/src/waveform/waveformrendersignal.h 2011-04-27 00:17:58.000000000 +0530 @@ -33,12 +33,15 @@ public slots: void slotUpdateGain(double gain); + void slotUpdateZoom(double newZoom); private: float m_fGain; + float zoom; WaveformRenderer *m_pParent; ControlObjectThreadMain *m_pGain; + ControlObjectThreadMain* m_pZoomWaveform; int m_iWidth, m_iHeight; QVector m_lines; === modified file 'mixxx/src/widget/wglwaveformviewer.cpp' --- mixxx/src/widget/wglwaveformviewer.cpp 2011-04-26 18:12:18.000000000 +0530 +++ mixxx/src/widget/wglwaveformviewer.cpp 2011-04-26 23:53:26.000000000 +0530 @@ -29,6 +29,13 @@ Q_ASSERT(m_pWaveformRenderer); m_pGroup = group; + + zoomAccumulate = 0; + + m_pZoomWaveform = new ControlObjectThreadMain( + ControlObject::getControl(ConfigKey(group, "zoom_waveform"))); + connect(m_pZoomWaveform, SIGNAL(valueChanged(double)), + this, SLOT(slotUpdateZoom(double))); m_pScratchEnable = new ControlObjectThreadMain( ControlObject::getControl(ConfigKey(group, "scratch_position_enable"))); @@ -120,9 +127,34 @@ // unused, stops a bad connect from happening } +void WGLWaveformViewer::slotUpdateZoom(double newZoom) { + zoomAccumulate = newZoom; +} + + bool WGLWaveformViewer::eventFilter(QObject *o, QEvent *e) { QMouseEvent* m = dynamic_cast(e); + + // Captures mouse wheel events for waveform zooming + if(e->type() == QEvent::Wheel) { + QWheelEvent *w = (QWheelEvent*)e; + + if (w->delta() > 0) + zoomAccumulate += 0.2; + else + zoomAccumulate -= 0.2; + + if (zoomAccumulate < -0.8) + zoomAccumulate = -0.8; + + if (zoomAccumulate > 0.8) + zoomAccumulate = 0.8; + + m_pZoomWaveform->slotSet(zoomAccumulate); + } + if(e->type() == QEvent::MouseButtonPress) { + m_iMouseStart = m->x(); if(m->button() == Qt::LeftButton) { m_bScratching = true; @@ -132,6 +164,10 @@ // Set the cursor to a hand while the mouse is down. setCursor(Qt::ClosedHandCursor); } + else if(m->button() == Qt::RightButton) { + zoomAccumulate = 0; + m_pZoomWaveform->slotSet(zoomAccumulate); + } } else if(e->type() == QEvent::MouseMove) { // Only send signals for mouse moving if the left button is pressed if (m_iMouseStart != -1 && m_bScratching) { @@ -146,7 +182,7 @@ double rateAdjust = m_pRateDir->get() * math_min(0.99, m_pRate->get() * m_pRateRange->get()); double targetPosition = (m_iMouseStart - curX) * - samplesPerPixel * (1 + rateAdjust); + samplesPerPixel * (1 + rateAdjust) * (1.0 + zoomAccumulate); //qDebug() << "Target:" << targetPosition; m_pScratch->slotSet(targetPosition); } === modified file 'mixxx/src/widget/wglwaveformviewer.h' --- mixxx/src/widget/wglwaveformviewer.h 2011-04-26 18:12:18.000000000 +0530 +++ mixxx/src/widget/wglwaveformviewer.h 2011-04-26 23:52:44.000000000 +0530 @@ -39,6 +39,7 @@ public slots: void setValue(double); void refresh(); + void slotUpdateZoom(double newZoom); signals: void valueChangedLeftDown(double); @@ -63,12 +64,14 @@ ControlObjectThreadMain* m_pRate; ControlObjectThreadMain* m_pRateRange; ControlObjectThreadMain* m_pRateDir; + ControlObjectThreadMain* m_pZoomWaveform; bool m_bScratching; bool m_painting; QMutex m_paintMutex; const char *m_pGroup; + float zoomAccumulate; }; #endif