Permalink
Browse files

Initial commit. Embedded the standard VSXuWidget into tomahawk. still…

… takes

audio from pulseaudio.
  • Loading branch information...
saidinesh5 committed Feb 6, 2012
1 parent e3f6e61 commit ca369dea78eb51dd05d94ec35c256aed0f8a0080
View
@@ -120,6 +120,8 @@ macro_log_feature(LIBJREEN_FOUND "Jreen" "Qt XMPP Library" "https://github.com/e
macro_optional_find_package(QTweetLib)
macro_log_feature(QTWEETLIB_FOUND "QTweetLib" "Qt Twitter Library" "https://github.com/minimoog/QTweetLib" FALSE "" "QTweetLib is needed for the Twitter SIP plugin.\n")
+macro_optional_find_package(VSXu)
+macro_log_feature(VSXU_FOUND "VSXu" "Vovoid VSXu Ultra" "https://www.vsxu.com" FALSE "" "VSXu is needed for some really cool music visualization.\n")
IF( NOT QuaZip_FOUND )
add_subdirectory( ${CMAKE_SOURCE_DIR}/src/libtomahawk/thirdparty/quazip )
@@ -0,0 +1,48 @@
+# Find VSXU - JSON handling library for Qt
+#
+# This module defines
+# VSXU_FOUND - whether the qsjon library was found
+# VSXU_LIBRARIES - the vsxu library
+# VSXU_INCLUDE_DIRS - the include path of the vsxu library
+#
+
+if (VSXU_INCLUDE_DIRS AND VSXU_LIBRARIES)
+
+ # Already in cache
+ set (VSXU_FOUND TRUE)
+
+else (VSXU_INCLUDE_DIRS AND VSXU_LIBRARIES)
+
+ if (NOT WIN32)
+ # use pkg-config to get the values of VSXU_INCLUDE_DIRS
+ # and VSXU_LIBRARY_DIRS to add as hints to the find commands.
+ include (FindPkgConfig)
+ pkg_check_modules (VSXU REQUIRED libvsxu)
+ endif (NOT WIN32)
+
+ find_library (VSXU_LIBRARIES
+ NAMES
+ libvsxu_engine
+ PATHS
+ ${VSXU_LIBRARY_DIRS}
+ ${LIB_INSTALL_DIR}
+ ${KDE4_LIB_DIR}
+ )
+
+ find_path (VSXU_INCLUDE_DIRS
+ NAMES
+ vsxu_platform.h
+ PATHS
+ ${VSXU_INCLUDE_DIRS}
+ ${INCLUDE_INSTALL_DIR}
+ ${KDE4_INCLUDE_DIR}
+ )
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(VSXu DEFAULT_MSG VSXU_LIBRARIES VSXU_INCLUDE_DIRS)
+
+ if ( UNIX AND NOT APPLE )
+ set ( VSXU_LIBRARIES "${VSXU_LIBRARIES} ${VSXU_LDFLAGS}" CACHE INTERNAL "")
+ endif ()
+
+endif (VSXU_INCLUDE_DIRS AND VSXU_LIBRARIES)
@@ -6,6 +6,10 @@ SET( QT_USE_QTNETWORK TRUE )
SET( QT_USE_QTXML TRUE )
SET( QT_USE_QTUITOOLS TRUE )
+IF(VSXU_FOUND)
+ SET( QT_USE_QTOPENGL TRUE )
+ENDIF(VSXU_FOUND)
+
include( ${QT_USE_FILE} )
add_definitions( ${QT_DEFINITIONS} )
@@ -146,6 +150,9 @@ set( libGuiSources
IF(QCA2_FOUND)
set( libGuiSources ${libGuiSources} utils/groovesharkparser.cpp )
ENDIF(QCA2_FOUND)
+IF(VSXU_FOUND)
+ set(libGuiSources ${libGuiSources} nowplaying/VSXuWidget.cpp nowplaying/nowplayingpage.cpp)
+ENDIF(VSXU_FOUND)
set( libGuiHeaders
actioncollection.h
@@ -283,6 +290,9 @@ set( libGuiHeaders
IF(QCA2_FOUND)
set( libGuiHeaders ${libGuiHeaders} utils/groovesharkparser.h )
ENDIF(QCA2_FOUND)
+IF(VSXU_FOUND)
+ set( libGuiHeaders ${libGuiHeaders} nowplaying/VSXuWidget.h nowplaying/nowplayingpage.h)
+ENDIF(VSXU_FOUND)
set( libSources
tomahawksettings.cpp
@@ -594,6 +604,10 @@ IF(QCA2_FOUND)
INCLUDE_DIRECTORIES( ${QCA2_INCLUDE_DIR} )
ENDIF(QCA2_FOUND)
+IF(VSXU_FOUND)
+ INCLUDE_DIRECTORIES(${VSXU_INCLUDE_DIRS})
+ENDIF(VSXU_FOUND)
+
IF(LIBATTICA_FOUND)
SET( libGuiSources ${libGuiSources} AtticaManager.cpp )
SET( libGuiHeaders ${libGuiHeaders} AtticaManager.h )
@@ -686,6 +700,10 @@ IF(QCA2_FOUND)
SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${QCA2_LIBRARIES} )
ENDIF(QCA2_FOUND)
+IF(VSXU_FOUND)
+ SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${VSXU_LIBRARIES})
+ENDIF(VSXU_FOUND)
+
IF(LIBATTICA_FOUND)
SET( LINK_LIBRARIES ${LINK_LIBRARIES} ${LIBATTICA_LIBRARIES} ${QuaZip_LIBRARIES} )
ENDIF(LIBATTICA_FOUND)
@@ -700,9 +718,7 @@ TARGET_LINK_LIBRARIES( tomahawklib
${TAGLIB_LIBRARIES}
${CLUCENE_LIBRARIES}
${LIBECHONEST_LIBRARY}
- ${QT_QTSQL_LIBRARY}
- ${QT_QTUITOOLS_LIBRARY}
- ${QT_QTGUI_LIBRARY}
+ ${QT_LIBRARIES} #This should do as long as we use ${SET (QT_USE_QTXYZ TRUE)}
${OS_SPECIFIC_LINK_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${LINK_LIBRARIES}
@@ -0,0 +1,80 @@
+#include <QDebug>
+
+#include "VSXuWidget.h"
+
+VSXuWidget::VSXuWidget(QWidget *parent):
+ QGLWidget(parent),
+ m_isActive(true)
+{
+ setWindowTitle("Vovoid VSXu");
+ m_timer = new QTimer(this);
+ connect (m_timer , SIGNAL(timeout()), this, SLOT(update()));
+}
+
+void VSXuWidget::injectSound(float soundData[])
+{
+ /* uncomment for manual sound injection
+ for (unsigned long i = 0; i < 512; i++)
+ {
+ sound_wave_test[i] = (float)(rand()%65535-32768)*(1.0f/32768.0f);
+ }
+ for (unsigned long i = 0; i < 512; i++)
+ {
+ sound_freq_test[i] = (float)(rand()%65535)*(1.0f/65535.0f);
+ }
+ manager->set_sound_freq(&sound_freq_test[0]);
+ manager->set_sound_wave(&sound_wave_test[0]);
+ */
+
+ updateGL();
+}
+
+void VSXuWidget::initializeGL()
+{
+ m_manager = manager_factory();
+ // init manager with the shared path and sound input type.
+ // manual sound injection: manager->init( path.c_str() , "media_player");
+ m_manager->init(0 , "pulseaudio");
+
+ std::vector<std::string> files = m_manager->get_visual_filenames();
+
+ qDebug()<<files.size();
+ for(int i = 0 ; i < files.size(); i++){
+ m_visuals.push_back(QString::fromStdString(files[i]));
+ }
+ qDebug()<<m_visuals;
+
+ glEnable(GL_BLEND);
+ glEnable(GL_POLYGON_SMOOTH);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glClearColor(0, 0, 0, 0);
+
+ glViewport( 0, 0, width(), height());
+
+ if (context()->format().hasOpenGL())
+ qDebug()<<"You have a Valid OpenGL Context";
+ if (context()->format().sampleBuffers())
+ qDebug()<<"You have Sample Buffers";
+ m_timer->start(20);
+}
+
+
+void VSXuWidget::paintGL()
+{
+ if (m_isActive){
+ glViewport(0, 0, m_width, m_height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluOrtho2D(0, m_width, 0, m_height); // set origin to bottom left corner
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ if (m_manager)
+ m_manager->render();
+ }
+}
+
+
+VSXuWidget::~VSXuWidget()
+{}
@@ -0,0 +1,34 @@
+#ifndef VSXuWidget_H
+#define VSXuWidget_H
+
+#include <vsx_manager.h>
+#include <QGLWidget>
+#include <QTimer>
+#include <QStringList>
+
+class VSXuWidget : public QGLWidget
+{
+ Q_OBJECT
+private:
+ vsx_manager_abs* m_manager;
+ QTimer *m_timer; // A Timer to frequently update the display
+
+ QStringList m_visuals;
+ int m_width,m_height;
+ bool m_isActive; // To Save the CPU when we aren't using VSXu.
+
+protected:
+ void initializeGL();
+ void resizeGL(int w, int h){
+ m_width = w;
+ m_height = h;
+ }
+ void paintGL();
+
+public:
+ VSXuWidget(QWidget *parent = NULL);
+ ~VSXuWidget();
+ void injectSound(float soundData[]);
+};
+
+#endif // VSXuWidget_H
@@ -0,0 +1,30 @@
+/*
+ Creates a Now Playing page as a place holder for Music Visuals.
+ Copyright (C) 2012 Dinesh <saidinesh5@gmail.com>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <QVBoxLayout>
+#include <QPushButton>
+#include "nowplayingpage.h"
+
+NowPlayingPage::NowPlayingPage(QWidget* parent):
+ QWidget(parent)
+{
+ QVBoxLayout *layout = new QVBoxLayout;
+ m_VSXuWidget = new VSXuWidget;
+ layout->addWidget(m_VSXuWidget);
+ setLayout(layout);
+}
@@ -0,0 +1,44 @@
+/*
+ Creates a Now Playing page as a place holder for Music Visuals.
+ Copyright (C) 2012 Dinesh <saidinesh5@gmail.com>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef NOWPLAYINGPAGE_H
+#define NOWPLAYINGPAGE_H
+
+#include <viewpage.h>
+#include <QWidget>
+#include "VSXuWidget.h"
+
+class NowPlayingPage : public QWidget,public Tomahawk::ViewPage
+{
+ Q_OBJECT
+
+public:
+ NowPlayingPage( QWidget *parent = 0 );
+ virtual bool jumpToCurrentTrack() { return false; }
+ virtual QString description() const { return QString("VSXu Music Visualizer"); }
+ virtual QString title() const{ return QString("Vovoid VSXu Ultra"); }
+ virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); }
+ virtual QWidget* widget(){ return this; }
+
+private:
+ VSXuWidget *m_VSXuWidget;
+
+};
+
+#endif // NOWPLAYINGPAGE_H
@@ -52,6 +52,7 @@
#include "widgets/animatedsplitter.h"
#include "utils/logger.h"
+#include "nowplaying/nowplayingpage.h"
#define FILTER_TIMEOUT 280
@@ -432,6 +433,14 @@ ViewManager::showTopLovedPage()
return show( m_topLovedWidget );
}
+Tomahawk::ViewPage*
+ViewManager::showNowPlayingPage()
+{
+ if ( !m_nowPlayingWidget )
+ m_nowPlayingWidget = new NowPlayingPage(m_widget);
+
+ return show( m_nowPlayingWidget );
+}
void
ViewManager::setTableMode()
@@ -33,6 +33,7 @@
#include "dllmacro.h"
+class NowPlayingPage;
class AnimatedSplitter;
class AlbumModel;
class AlbumView;
@@ -91,6 +92,7 @@ Q_OBJECT
Tomahawk::ViewPage* welcomeWidget() const { return m_welcomeWidget; }
Tomahawk::ViewPage* whatsHotWidget() const { return m_whatsHotWidget; }
Tomahawk::ViewPage* topLovedWidget() const { return m_topLovedWidget; }
+ Tomahawk::ViewPage* nowPlayingWidget() const { return m_nowPlayingWidget; }
ArtistView* superCollectionView() const { return m_superCollectionView; }
/// Get the view page for the given item. Not pretty...
@@ -135,6 +137,7 @@ public slots:
Tomahawk::ViewPage* showWelcomePage();
Tomahawk::ViewPage* showWhatsHotPage();
Tomahawk::ViewPage* showTopLovedPage();
+ Tomahawk::ViewPage* showNowPlayingPage();
void showCurrentTrack();
// Returns the shown viewpage
@@ -197,6 +200,7 @@ private slots:
WelcomeWidget* m_welcomeWidget;
WhatsHotWidget* m_whatsHotWidget;
Tomahawk::ViewPage* m_topLovedWidget;
+ Tomahawk::ViewPage* m_nowPlayingWidget;
QList< Tomahawk::collection_ptr > m_superCollections;
@@ -285,6 +285,11 @@ SourcesModel::appendGroups()
boost::bind( &ViewManager::showWhatsHotPage, ViewManager::instance() ),
boost::bind( &ViewManager::whatsHotWidget, ViewManager::instance() ) );
hot->setSortValue( -300 );
+
+ GenericPageItem* nowPlaying = new GenericPageItem( this, browse, tr( "Now Playing" ), QIcon( RESPATH "images/charts.png" ),
+ boost::bind( &ViewManager::showNowPlayingPage, ViewManager::instance() ),
+ boost::bind( &ViewManager::nowPlayingWidget, ViewManager::instance() ) );
+ hot->setSortValue( -400 );
m_collectionsGroup = new GroupItem( this, m_rootItem, tr( "Friends" ), 15 );

0 comments on commit ca369de

Please sign in to comment.