From 75f2e2a25c2cd0cb7f55cee4896edc0ef3b0e23b Mon Sep 17 00:00:00 2001 From: psperl Date: Fri, 5 Oct 2007 17:13:12 +0000 Subject: [PATCH] PCM moved out of beatdetect. Only projectM.hpp needs to be included, and even more headers removed from installation git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@530 6778bc44-b910-0410-a7a0-be141de4315d --- src/projectM-engine/BeatDetect.cpp | 13 ++++++------- src/projectM-engine/BeatDetect.hpp | 2 +- src/projectM-engine/CMakeLists.txt | 2 +- src/projectM-engine/projectM.cpp | 10 +++++++--- src/projectM-engine/projectM.hpp | 9 ++++++--- src/projectM-libvisual/actor_projectM.cpp | 5 +---- src/projectM-test/projectM-test-memleak.cpp | 3 --- src/projectM-test/projectM-test-texture.cpp | 5 ++--- src/projectM-test/projectM-test.cpp | 5 ++--- src/projectM-xmms/main.cpp | 6 ++---- 10 files changed, 28 insertions(+), 32 deletions(-) diff --git a/src/projectM-engine/BeatDetect.cpp b/src/projectM-engine/BeatDetect.cpp index d4387df3c..57ca15f16 100755 --- a/src/projectM-engine/BeatDetect.cpp +++ b/src/projectM-engine/BeatDetect.cpp @@ -37,9 +37,11 @@ #include "PCM.hpp" #include -DLLEXPORT BeatDetect::BeatDetect() { +DLLEXPORT BeatDetect::BeatDetect(PCM *pcm) { int x,y; + this->pcm=pcm; + this->vol_instant=0; this->vol_history=0; @@ -71,14 +73,11 @@ DLLEXPORT BeatDetect::BeatDetect() { this->bass_att = 0; this->vol = 0; - this->pcm = new PCM(); + } -DLLEXPORT BeatDetect::~BeatDetect() { - - // Free the pcm buffer - if (pcm) - delete(pcm); +DLLEXPORT BeatDetect::~BeatDetect() +{ } diff --git a/src/projectM-engine/BeatDetect.hpp b/src/projectM-engine/BeatDetect.hpp index 96105f3af..31d7a1b5c 100755 --- a/src/projectM-engine/BeatDetect.hpp +++ b/src/projectM-engine/BeatDetect.hpp @@ -62,7 +62,7 @@ class BeatDetect PCM *pcm; /** Methods */ - DLLEXPORT BeatDetect(); + DLLEXPORT BeatDetect(PCM *pcm); DLLEXPORT ~BeatDetect(); void initBeatDetect(); void reset(); diff --git a/src/projectM-engine/CMakeLists.txt b/src/projectM-engine/CMakeLists.txt index 8d326fafa..f192f0294 100644 --- a/src/projectM-engine/CMakeLists.txt +++ b/src/projectM-engine/CMakeLists.txt @@ -34,5 +34,5 @@ FILE(GLOB fonts "fonts/*.ttf") INSTALL(FILES ${fonts} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/projectM/fonts) INSTALL(FILES "${CMAKE_BINARY_DIR}/libprojectM.pc" DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) INSTALL(FILES config.inp DESTINATION ${CMAKE_INSTALL_PREFIX}/share/projectM) -INSTALL(FILES projectM.hpp BeatDetect.hpp Preset.hpp event.h KeyHandler.hpp dlldefs.h fatal.h PresetFrameIO.hpp PCM.hpp DESTINATION include/libprojectM) +INSTALL(FILES projectM.hpp Preset.hpp event.h dlldefs.h fatal.h PresetFrameIO.hpp PCM.hpp DESTINATION include/libprojectM) INSTALL(TARGETS projectM DESTINATION lib) diff --git a/src/projectM-engine/projectM.cpp b/src/projectM-engine/projectM.cpp index 7d49bfffd..257d08921 100755 --- a/src/projectM-engine/projectM.cpp +++ b/src/projectM-engine/projectM.cpp @@ -81,9 +81,11 @@ projectM::~projectM() { destroyPresetTools(); if (renderer) - delete(renderer); + delete(renderer); if (beatDetect) - delete(beatDetect); + delete(beatDetect); + if (pcm) + delete(pcm); } DLLEXPORT unsigned projectM::initRenderToTexture() @@ -350,7 +352,9 @@ void projectM::projectM_reset() this->nohard=fps*5; /** We need to initialise this before the builtin param db otherwise bass/mid etc won't bind correctly */ assert(!beatDetect); - beatDetect = new BeatDetect(); + + pcm = new PCM(); + beatDetect = new BeatDetect(pcm); initPresetTools(); #if 0 diff --git a/src/projectM-engine/projectM.hpp b/src/projectM-engine/projectM.hpp index 38440a8b9..64c4e74a8 100755 --- a/src/projectM-engine/projectM.hpp +++ b/src/projectM-engine/projectM.hpp @@ -66,10 +66,12 @@ #include "event.h" #include "fatal.h" #include "PresetFrameIO.hpp" +#include "PCM.hpp" #include class BeatDetect; +class PCM; class Func; class Renderer; class Preset; @@ -107,9 +109,8 @@ typedef enum { class projectM { public: - - BeatDetect * beatDetect; - + + PCM *pcm; DLLEXPORT projectM(std::string config_file); DLLEXPORT projectM(int gx, int gy, int fps, int texsize, int width, int height,std::string preset_url,std::string title_fonturl, std::string title_menuurl); @@ -124,6 +125,8 @@ public: ~projectM(); private: + + BeatDetect * beatDetect; Renderer *renderer; std::string presetURL; diff --git a/src/projectM-libvisual/actor_projectM.cpp b/src/projectM-libvisual/actor_projectM.cpp index 4972f6dca..9b2244be1 100644 --- a/src/projectM-libvisual/actor_projectM.cpp +++ b/src/projectM-libvisual/actor_projectM.cpp @@ -12,10 +12,7 @@ #include #include -#include -#include #include -#include #include "lvtoprojectM.h" #include "ConfigFile.h" @@ -234,7 +231,7 @@ extern "C" int lv_projectm_render (VisPluginData *plugin, VisVideo *video, VisAu addPCM16Data(pcms,512); */ - priv->PM->beatDetect->pcm->addPCMfloat(*pcm,512); + priv->PM->pcm->addPCMfloat(*pcm,512); priv->PM->renderFrame(); diff --git a/src/projectM-test/projectM-test-memleak.cpp b/src/projectM-test/projectM-test-memleak.cpp index a7c567829..49f1c01b9 100644 --- a/src/projectM-test/projectM-test-memleak.cpp +++ b/src/projectM-test/projectM-test-memleak.cpp @@ -23,10 +23,7 @@ #include #include #include -#include -#include #include -#include #include "sdltoprojectM.h" #include "ConfigFile.h" diff --git a/src/projectM-test/projectM-test-texture.cpp b/src/projectM-test/projectM-test-texture.cpp index b062fa08c..0d90975d1 100644 --- a/src/projectM-test/projectM-test-texture.cpp +++ b/src/projectM-test/projectM-test-texture.cpp @@ -23,10 +23,9 @@ #include #include #include -#include -#include + #include -#include + #include "sdltoprojectM.h" #include "ConfigFile.h" diff --git a/src/projectM-test/projectM-test.cpp b/src/projectM-test/projectM-test.cpp index f20089be7..c8645c518 100644 --- a/src/projectM-test/projectM-test.cpp +++ b/src/projectM-test/projectM-test.cpp @@ -23,10 +23,9 @@ #include #include #include -#include -#include + #include -#include + #include "sdltoprojectM.h" #include "ConfigFile.h" diff --git a/src/projectM-xmms/main.cpp b/src/projectM-xmms/main.cpp index 9573f83ab..f23e66e34 100755 --- a/src/projectM-xmms/main.cpp +++ b/src/projectM-xmms/main.cpp @@ -41,10 +41,8 @@ www.gamedev.net/reference/programming/features/beatdetection/ #include #include "ConfigFile.h" -#include -#include #include -#include + #include "sdltoprojectM.h" #include "video_init.h" @@ -329,7 +327,7 @@ extern "C" void projectM_render_pcm(gint16 pcm_data[2][512]) { //SDL_mutexP(mutex); while ( SDL_SemValue(sem)==1 ) if ( SDL_SemValue(sem)==1 ) - globalPM->beatDetect->pcm->addPCM16(pcm_data); + globalPM->pcm->addPCM16(pcm_data); //SDL_mutexV(mutex);