diff --git a/src/projectM-engine/BeatDetect.cpp b/src/projectM-engine/BeatDetect.cpp index fbfad1b28..dd3d795cf 100755 --- a/src/projectM-engine/BeatDetect.cpp +++ b/src/projectM-engine/BeatDetect.cpp @@ -73,6 +73,14 @@ DLLEXPORT BeatDetect::BeatDetect() { this->pcm = new PCM(); } +DLLEXPORT BeatDetect::~BeatDetect() { + + // Free the pcm buffer + if (pcm) + delete(pcm); + +} + void BeatDetect::reset() { this->treb = 0; this->mid = 0; diff --git a/src/projectM-engine/BeatDetect.hpp b/src/projectM-engine/BeatDetect.hpp index c43b9f8f1..786f74241 100755 --- a/src/projectM-engine/BeatDetect.hpp +++ b/src/projectM-engine/BeatDetect.hpp @@ -34,39 +34,41 @@ #include "projectM.hpp" #include "PCM.hpp" -class BeatDetect { -public: - /** Vars */ - float beat_buffer[32][80], - beat_instant[32], - beat_history[32]; - float beat_val[32], - beat_att[32], - beat_variance[32]; - int beat_buffer_pos; - float vol_buffer[80], - vol_instant, - vol_history; +class BeatDetect +{ + public: + /** Vars */ + float beat_buffer[32][80], + beat_instant[32], + beat_history[32]; + float beat_val[32], + beat_att[32], + beat_variance[32]; + int beat_buffer_pos; + float vol_buffer[80], + vol_instant, + vol_history; - float treb ; - float mid ; - float bass ; - float bass_old ; - float beat_sensitivity; - float treb_att ; - float mid_att ; - float bass_att ; - float vol; + float treb ; + float mid ; + float bass ; + float bass_old ; + float beat_sensitivity; + float treb_att ; + float mid_att ; + float bass_att ; + float vol; - PCM *pcm; + PCM *pcm; - /** Methods */ - DLLEXPORT BeatDetect(); - void initBeatDetect(); - void reset(); - void detectFromSamples(); - void getBeatVals( float *vdataL, float *vdataR); - void freeBeatDetect(); - }; + /** Methods */ + DLLEXPORT BeatDetect(); + DLLEXPORT ~BeatDetect(); + void initBeatDetect(); + void reset(); + void detectFromSamples(); + void getBeatVals ( float *vdataL, float *vdataR ); + +}; #endif /** !_BEAT_DETECT_H */ diff --git a/src/projectM-engine/projectM.cpp b/src/projectM-engine/projectM.cpp index 3f5a8a07c..f3959e48a 100755 --- a/src/projectM-engine/projectM.cpp +++ b/src/projectM-engine/projectM.cpp @@ -79,7 +79,9 @@ DLLEXPORT projectM::projectM(int gx, int gy, int fps, int texsize, int width, in DLLEXPORT projectM::~projectM() { std::cerr << "[projectM] DESTROY PRESET TOOLS BEGIN" << std::endl; destroyPresetTools(); - std::cerr << "[projectM] DESTROY PRESET TOOLS BEGIN" << std::endl; + if (beatDetect) + delete(beatDetect); + std::cerr << "[projectM] DESTROY PRESET TOOLS END" << std::endl; } DLLEXPORT projectM::projectM(std::string config_file) :smoothFrame(0), beatDetect ( 0 ) @@ -854,12 +856,19 @@ int projectM::initPresetTools() projectM_resetengine(); + std::cerr << "[projectM] engine has been reset." << std::endl; return PROJECTM_SUCCESS; } void projectM::destroyPresetTools() { + if (m_presetPos) + delete(m_presetPos); + + /// @slow might not be necessary + m_presetPos = 0; + if ( m_presetChooser ) delete ( m_presetChooser ); @@ -868,7 +877,7 @@ void projectM::destroyPresetTools() if ( m_presetLoader ) delete ( m_presetLoader ); - + /// @slow might not be necessary m_presetLoader = 0;