File pitch-effect.patch of Package amarok

--- a/src/CMakeLists.txt	2013-08-14 23:22:51.000000000 +0300
+++ b/src/CMakeLists.txt	2017-08-10 15:48:50.497957363 +0300
@@ -632,6 +632,7 @@ set(amaroklib_LIB_SRCS
     dialogs/DiagnosticDialog.cpp
     dialogs/EditFilterDialog.cpp
     dialogs/EqualizerDialog.cpp
+    dialogs/PitchEffectDialog.cpp
     dialogs/MusicBrainzTagger.cpp
     dialogs/OrganizeCollectionDialog.cpp
     dialogs/TrackOrganizer.cpp
@@ -657,6 +658,7 @@ set(amaroklib_LIB_SRCS
     playback/DelayedDoers.cpp
     playback/Fadeouter.cpp
     playback/PowerManager.cpp
+    playback/PitchEffectController.cpp
     statemanagement/ApplicationController.cpp
     statemanagement/DefaultApplicationController.cpp
     toolbar/CurrentTrackToolbar.cpp
--- a/src/EngineController.cpp	2013-08-14 23:22:51.000000000 +0300
+++ b/src/EngineController.cpp	2017-08-10 15:53:48.050532474 +0300
@@ -96,6 +96,7 @@ EngineController::EngineController()
 
     m_pauseTimer->setSingleShot( true );
     connect( m_pauseTimer, SIGNAL(timeout()), SLOT(slotPause() ) );
+    m_pitchEffectController = new PitchEffectController( this );
 }
 
 EngineController::~EngineController()
@@ -184,6 +185,8 @@ EngineController::initializePhonon()
         }
     }
 
+    m_pitchEffectController->initialize( m_path );
+
     // HACK we turn off replaygain manually on OSX, until the phonon coreaudio backend is fixed.
     // as the default is specified in the .cfg file, we can't just tell it to be a different default on OSX
 #ifdef Q_WS_MAC
@@ -309,6 +312,12 @@ EngineController::slotFillInSupportedMim
     m_supportedMimeTypesSemaphore.release( 100000 );
 }
 
+PitchEffectController*
+EngineController::pitchEffectController() const
+{
+    return m_pitchEffectController;
+}
+
 void
 EngineController::restoreSession()
 {
--- a/src/EngineController.h	2013-08-14 23:22:51.000000000 +0300
+++ b/src/EngineController.h	2017-08-10 15:56:52.594859038 +0300
@@ -24,6 +24,7 @@
 #include "amarok_export.h"
 #include "core/capabilities/BoundedPlaybackCapability.h"
 #include "core/meta/Observer.h"
+#include "playback/PitchEffectController.h"
 
 #include <KUrl>
 
@@ -86,6 +87,11 @@ public:
      */
     QStringList supportedMimeTypes();
 
+    /**
+     * Returns the associated PitchEffectController object.
+     */
+    PitchEffectController *pitchEffectController() const;
+
     /** @return track position (elapsed time) in seconds */
     int trackPosition() const;
 
@@ -552,6 +558,7 @@ private:
     Phonon::Path                            m_path;
     Phonon::Path                            m_dataPath;
 
+    PitchEffectController*                  m_pitchEffectController;
     QWeakPointer<Fadeouter> m_fadeouter;
     QWeakPointer<Phonon::VolumeFaderEffect> m_fader;
 
--- a/src/MainWindow.cpp	2013-08-14 23:22:51.000000000 +0300
+++ b/src/MainWindow.cpp	2017-08-10 16:06:21.663880606 +0300
@@ -48,6 +48,7 @@
 #include "covermanager/CoverManager.h" // for actions
 #include "dialogs/DiagnosticDialog.h"
 #include "dialogs/EqualizerDialog.h"
+#include "dialogs/PitchEffectDialog.h"
 #include "moodbar/MoodbarManager.h"
 #include "network/NetworkAccessManagerProxy.h"
 #ifdef DEBUG_BUILD_TYPE
@@ -514,6 +515,11 @@ void MainWindow::slotShowEqualizer()
     EqualizerDialog::showOnce( this );
 }
 
+void MainWindow::slotShowPitchEffect()
+{
+    PitchEffectDialog::showOnce( this );
+}
+
 void
 MainWindow::slotPlayMedia() //SLOT
 {
@@ -797,6 +803,10 @@ MainWindow::createActions()
     ac->addAction( "equalizer_dialog", action );
     connect( action, SIGNAL(triggered(bool)), SLOT(slotShowEqualizer()) );
 
+    action = new KAction( KIcon( "preferences-other" ), i18n( "Pitch Effect" ), this );
+    ac->addAction( "pitch_effect_dialog", action );
+    connect( action, SIGNAL(triggered(bool)), SLOT(slotShowPitchEffect()) );
+
     action = new KAction( KIcon( "bookmark-new" ), i18n( "Bookmark Playlist Setup" ), this );
     ac->addAction( "bookmark_playlistview", action );
     connect( action, SIGNAL(triggered()), The::amarokUrlHandler(), SLOT(bookmarkCurrentPlaylistView()) );
@@ -1123,6 +1133,7 @@ MainWindow::createMenus()
     m_toolsMenu.data()->addAction( Amarok::actionCollection()->action("bookmark_manager") );
     m_toolsMenu.data()->addAction( Amarok::actionCollection()->action("cover_manager") );
     m_toolsMenu.data()->addAction( Amarok::actionCollection()->action("equalizer_dialog") );
+    m_toolsMenu.data()->addAction( Amarok::actionCollection()->action("pitch_effect_dialog") );
 #ifdef QTSCRIPTQTBINDINGS_FOUND
     m_toolsMenu.data()->addAction( Amarok::actionCollection()->action("script_manager") );
 #endif
--- a/src/MainWindow.h	2013-08-14 23:22:51.000000000 +0300
+++ b/src/MainWindow.h	2017-08-10 16:06:59.379949041 +0300
@@ -150,6 +150,7 @@ class AMAROK_EXPORT MainWindow : public
         void slotEditTrackInfo() const;
         void slotShowBookmarkManager();
         void slotShowEqualizer();
+        void slotShowPitchEffect();
         void slotShowCoverManager();
         void slotShowDiagnosticsDialog();
         void slotShowMenuBar();
--- a/src/amarok.desktop	2013-08-14 23:22:51.000000000 +0300
+++ b/src/amarok.desktop	2017-08-10 16:12:02.124494032 +0300
@@ -122,7 +122,7 @@ GenericName[wa]=Djouweu d' son
 GenericName[x-test]=xxAudio Playerxx
 GenericName[zh_CN]=音频播放器
 GenericName[zh_TW]=音效播放器
-Exec=amarok %U
+Exec=env PHONON_GST_ALL_EFFECTS=1 amarok %U
 Comment=Amarok - Rediscover Your Music!
 Comment[be]=Amarok - адкрыйце для сябе сваю музыку!
 Comment[bg]=Amarok - преоткрийте музиката!
--- a/src/dialogs/PitchEffectDialog.cpp	1970-01-01 03:00:00.000000000 +0300
+++ b/src/dialogs/PitchEffectDialog.cpp	2017-08-10 16:12:23.000000000 +0300
@@ -0,0 +1,73 @@
+#include "PitchEffectDialog.h"
+
+#include "amarokconfig.h"
+#include "EngineController.h"
+
+#include "core/support/Amarok.h"
+#include "core/support/Debug.h"
+
+#include <QComboBox>
+#include <QVBoxLayout>
+#include <QLabel>
+
+
+PitchEffectDialog * PitchEffectDialog::s_instance = 0;
+
+PitchEffectDialog::PitchEffectDialog( QWidget* parent )
+    : QDialog( parent )
+{
+    DEBUG_BLOCK
+
+    setWindowTitle( tr( "Configure Pitch Effect" ) );
+
+//    setupUi( this );
+
+
+    this->resize(300, 200);
+    QWidget *PitchEffectWidget = new QWidget(this);
+    QVBoxLayout *mainLayout = new QVBoxLayout;
+    QLabel *pitchErrorLabel = new QLabel();
+    pitchErrorLabel->setText(tr("Phonon: Pitch Effect not found!"));
+    PitchEffectWidget->setLayout(mainLayout);
+
+    PitchEffectController *pitchEffect = The::engineController()->pitchEffectController();
+    // Check if equalizer is supported - disable controls if not
+    if( !pitchEffect->isPitchSupported() )
+    {
+        mainLayout->addWidget(pitchErrorLabel);
+        PitchEffectWidget->setDisabled( true );
+    }
+    else
+    {
+        mainLayout->addWidget(pitchEffect->pitchWidget());
+    }
+}
+
+//void PitchEffectDialog::setupUi(QWidget *PitchEffectDialog)
+//{
+//    PitchEffectDialog->resize(400, 300);
+//    QWidget *PitchEffectWidget = new QWidget(PitchEffectDialog);
+//    QComboBox *speedSelector = new QComboBox();
+
+//    speedSelector->addItems(QStringList()<<".75x"<<"1x"<<"1.25x"<<"1.5x"<<"2x");
+//    speedSelector->setCurrentIndex(1);
+//    QVBoxLayout *mainLayout = new QVBoxLayout;
+//    mainLayout->addWidget(speedSelector);
+//    PitchEffectWidget->setLayout(mainLayout);
+//}
+
+PitchEffectDialog::~PitchEffectDialog()
+{ }
+
+void PitchEffectDialog::showOnce( QWidget *parent )
+{
+    DEBUG_BLOCK
+
+    if( s_instance == 0 )
+        s_instance = new PitchEffectDialog( parent );
+
+    s_instance->activateWindow();
+    s_instance->show();
+    s_instance->raise();
+//    s_instance->storeOriginalSettings();
+}
--- a/src/dialogs/PitchEffectDialog.h	1970-01-01 03:00:00.000000000 +0300
+++ b/src/dialogs/PitchEffectDialog.h	2017-08-10 16:12:23.000000000 +0300
@@ -0,0 +1,22 @@
+#ifndef PITCHEFFECTDIALOG_H
+#define PITCHEFFECTDIALOG_H
+
+#include <QDialog>
+
+class PitchEffectDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    ~PitchEffectDialog();
+
+    static void showOnce( QWidget *parent = 0 );
+
+private:
+    PitchEffectDialog(QWidget *parent);
+    void setupUi(QWidget *PitchEffectDialog);
+
+    static PitchEffectDialog *s_instance;
+};
+
+#endif // PITCHEFFECTDIALOG_H
--- a/src/playback/PitchEffectController.cpp	1970-01-01 03:00:00.000000000 +0300
+++ b/src/playback/PitchEffectController.cpp	2017-08-10 16:12:23.000000000 +0300
@@ -0,0 +1,71 @@
+#define DEBUG_PREFIX "EqualizerController"
+
+#include "PitchEffectController.h"
+
+#include "amarokconfig.h"
+#include "core/support/Debug.h"
+
+//#include <KLocalizedString>
+
+#include <Phonon/BackendCapabilities>
+#include <Phonon/EffectParameter>
+
+PitchEffectController::PitchEffectController(QObject *parent) : QObject(parent)
+{}
+
+PitchEffectController::~PitchEffectController()
+{}
+
+void
+PitchEffectController::initialize( const Phonon::Path &path )
+{
+    DEBUG_BLOCK
+    m_path = path;
+    delete m_pitch.data();
+
+    using namespace Phonon;
+
+    // Add a pitch effect if available
+    QList<EffectDescription> effects = BackendCapabilities::availableAudioEffects();
+    foreach( const EffectDescription &description, effects )
+    {
+        if( description.name()!="pitch" )
+            continue;
+
+        m_pitch = new Effect( description, this );
+        m_pitchWidget = new Phonon::EffectWidget(m_pitch.data());
+    }
+    // if equalizer not present simply return
+    if( !m_pitch )
+        return;
+    // Insert effect into path if needed
+    if( m_path.effects().indexOf( m_pitch.data() ) == -1 )
+    {
+        if( !m_path.effects().isEmpty() )
+        {
+            m_path.insertEffect( m_pitch.data(), m_path.effects().first() );
+        }
+        else
+        {
+            m_path.insertEffect( m_pitch.data() );
+        }
+    }
+}
+
+bool
+PitchEffectController::isPitchSupported() const
+{
+    // If effect was created it means we have equalizer support
+    return m_pitch;
+}
+
+QWidget *PitchEffectController::pitchWidget() const
+{
+    return m_pitchWidget.data();
+}
+
+//bool
+//PitchEffectController::enabled()
+//{
+//    return AmarokConfig::pitchEffectMode() > 0;
+//}
--- a/src/playback/PitchEffectController.h	1970-01-01 03:00:00.000000000 +0300
+++ b/src/playback/PitchEffectController.h	2017-08-10 16:12:23.000000000 +0300
@@ -0,0 +1,41 @@
+#ifndef PITCHEFFECTCONTROLLER_H
+#define PITCHEFFECTCONTROLLER_H
+
+#include "amarok_export.h"
+
+#include <QWeakPointer>
+
+#include <Phonon/Path>
+#include <Phonon/Effect>
+#include <Phonon/EffectWidget>
+
+class AMAROK_EXPORT PitchEffectController : public QObject
+{
+    Q_OBJECT
+public:
+    PitchEffectController(QObject *parent);
+    ~PitchEffectController();
+
+    void initialize( const Phonon::Path &path );
+
+    /**
+     * Phonon pitch support is required for Amarok to enable pitch effect
+     * this method return whatever phonon support pitch effect.
+     *
+     * @return @c true if the phonon support pitch effect, @c false otherwise
+     */
+    bool isPitchSupported() const;
+//    bool enabled();
+    QWidget *pitchWidget() const;
+
+signals:
+
+public slots:
+
+private:
+    QWeakPointer<Phonon::Effect>            m_pitch;
+    QWeakPointer<Phonon::EffectWidget>      m_pitchWidget;
+    Phonon::Path                            m_path;
+};
+
+#endif // PITCHEFFECTCONTROLLER_H