beatcontroller.h
Go to the documentation of this file.
00001 /****************************************************************
00002  *
00003  * Copyright (c) 2010
00004  *
00005  * Fraunhofer Institute for Manufacturing Engineering   
00006  * and Automation (IPA)
00007  *
00008  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00009  *
00010  * Project name: care-o-bot
00011  * ROS stack name: cob_driver
00012  * ROS package name: cob_light
00013  * Description: Switch robots led color by sending data to
00014  * the led-µC over serial connection.
00015  *                              
00016  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00017  *          
00018  * Author: Benjamin Maidel, email:benjamin.maidel@ipa.fraunhofer.de
00019  * Supervised by: Benjamin Maidel, email:benjamin.maidel@ipa.fraunhofer.de
00020  *
00021  * Date of creation: August 2012
00022  * ToDo:
00023  *
00024  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00025  *
00026  * Redistribution and use in source and binary forms, with or without
00027  * modification, are permitted provided that the following conditions are met:
00028  *
00029  *     * Redistributions of source code must retain the above copyright
00030  *       notice, this list of conditions and the following disclaimer.
00031  *     * Redistributions in binary form must reproduce the above copyright
00032  *       notice, this list of conditions and the following disclaimer in the
00033  *       documentation and/or other materials provided with the distribution.
00034  *     * Neither the name of the Fraunhofer Institute for Manufacturing 
00035  *       Engineering and Automation (IPA) nor the names of its
00036  *       contributors may be used to endorse or promote products derived from
00037  *       this software without specific prior written permission.
00038  *
00039  * This program is free software: you can redistribute it and/or modify
00040  * it under the terms of the GNU Lesser General Public License LGPL as 
00041  * published by the Free Software Foundation, either version 3 of the 
00042  * License, or (at your option) any later version.
00043  * 
00044  * This program is distributed in the hope that it will be useful,
00045  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00046  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00047  * GNU Lesser General Public License LGPL for more details.
00048  * 
00049  * You should have received a copy of the GNU Lesser General Public 
00050  * License LGPL along with this program. 
00051  * If not, see <http://www.gnu.org/licenses/>.
00052  *
00053  ****************************************************************/
00054 
00055 #ifndef CONTROLLER_H
00056 #define CONTROLLER_H
00057 #define USE_ALSA
00058 
00059 #ifdef USE_ALSA
00060 #include "alsarecorder.h"
00061 #endif
00062 #ifdef USE_PULSE
00063 #include "pulserecorder.h"
00064 #endif
00065 #include "fft.h"
00066 #include "soundbuffer.h"
00067 #include "beatanalyser.h"
00068 
00069 #include <tr1/unordered_set>
00070 
00071 namespace mybeat
00072 {
00073     class BeatController
00074     {
00075     public:
00076         
00077         BeatController (uint16_t recordSize = 0, uint32_t sampleRate = 0, uint16_t m_bandCount = 0, uint16_t channels = 2);
00078         ~BeatController();
00079 
00080         std::vector<FFT*> getFFTs(){return m_FFTs;}
00081 
00082         std::vector<BeatAnalyser*> getAnalysers(){return m_Analysers;}
00083 
00084         std::vector<SoundBuffer*> getBuffers(){return m_Buffers;}
00085 
00086         void start();
00087 
00088         void stop();
00089 
00090         bool getEnabled();
00091 
00092         void addCustomBeat(uint16_t value){m_customBeats.insert(value);}
00093 
00094         void removeCustomBeat(uint16_t value){m_customBeats.erase(value);}
00095 
00096         boost::signals2::signal<void ()>* signalProcessingDone(){return &m_sigProcessingDone;}
00097         boost::signals2::signal<void ()>* signalBeatDrum(){return &m_sigBeatDrum;}
00098         boost::signals2::signal<void ()>* signalBeatSnare(){return &m_sigBeatSnare;}
00099         boost::signals2::signal<void (std::tr1::unordered_set<uint16_t>)>* signalBeatCustom(){return &m_sigCustom;}
00100 
00101     private:
00102 
00103         SoundRecorder *m_Recorder;
00104         std::vector<FFT*> m_FFTs;
00105         std::vector<SoundBuffer*> m_Buffers;
00106         std::vector<BeatAnalyser*> m_Analysers;
00107         bool m_enabled;
00108 
00109         std::tr1::unordered_set<uint16_t> m_customBeats;
00110 
00111 
00112         void processNewData();
00113         
00114         boost::signals2::connection m_connectionProcessingDone;
00115         boost::signals2::signal<void ()> m_sigProcessingDone;
00116         boost::signals2::signal<void ()> m_sigBeatDrum;
00117         boost::signals2::signal<void ()> m_sigBeatSnare;
00118         boost::signals2::signal<void (std::tr1::unordered_set<uint16_t>)> m_sigCustom;        
00119     };
00120 }
00121 
00122 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


cob_lightmode
Author(s): Benjamin Maidel
autogenerated on Thu Jan 17 2013 12:16:04