2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
23 #include "cores/IAudioCallback.h"
24 #include "include/xbmc_vis_types.h"
25 #include "guilib/IRenderingCallback.h"
31 #define AUDIO_BUFFER_SIZE 512 // MUST BE A POWER OF 2!!!
32 #define MAX_AUDIO_BUFFERS 16
34 class CCriticalSection;
36 typedef DllAddon<Visualisation, VIS_PROPS> DllVisualisation;
41 CAudioBuffer(int iSize);
42 virtual ~CAudioBuffer();
43 const float* Get() const;
44 void Set(const float* psBuffer, int iSize);
53 class CVisualisation : public CAddonDll<DllVisualisation, Visualisation, VIS_PROPS>
54 , public IAudioCallback
55 , public IRenderingCallback
58 CVisualisation(const ADDON::AddonProps &props) : CAddonDll<DllVisualisation, Visualisation, VIS_PROPS>(props) {}
59 CVisualisation(const cp_extension_t *ext) : CAddonDll<DllVisualisation, Visualisation, VIS_PROPS>(ext) {}
60 virtual void OnInitialize(int iChannels, int iSamplesPerSec, int iBitsPerSample);
61 virtual void OnAudioData(const float* pAudioData, int iAudioDataLength);
62 bool Create(int x, int y, int w, int h, void *device);
63 void Start(int iChannels, int iSamplesPerSec, int iBitsPerSample, const CStdString &strSongName);
64 void AudioData(const float *pAudioData, int iAudioDataLength, float *pFreqData, int iFreqDataLength);
67 void GetInfo(VIS_INFO *info);
68 bool OnAction(VIS_ACTION action, void *param = NULL);
70 bool HasSubModules() { return !m_submodules.empty(); }
73 CStdString GetPresetName();
74 bool GetPresetList(std::vector<CStdString>& vecpresets);
75 bool GetSubModuleList(std::vector<CStdString>& vecmodules);
76 static CStdString GetFriendlyName(const CStdString& vis, const CStdString& module);
86 // attributes of the viewport we render to
93 std::vector<CStdString> m_presets;
94 // cached submodule list
95 std::vector<CStdString> m_submodules;
100 int m_iSamplesPerSec;
101 int m_iBitsPerSample;
102 std::list<CAudioBuffer*> m_vecBuffers;
103 int m_iNumBuffers; // Number of Audio buffers
105 float m_fFreq[2*AUDIO_BUFFER_SIZE]; // Frequency data
106 bool m_bCalculate_Freq; // True if the vis wants freq data
109 CStdString m_AlbumThumb;