1 /* Libvisual - The audio visualisation framework.
2  *
3  * Copyright (C) 2004, 2005 Dennis Smit <ds@nerds-incorporated.org>
4  *
5  * Authors: Dennis Smit <ds@nerds-incorporated.org>
6  *
7  * $Id:
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as
11  * published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */
23 
24 #ifndef _LV_AUDIO_H
25 #define _LV_AUDIO_H
26 
27 #include <libvisual/lv_fft.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32 
33 #define VISUAL_AUDIO(obj)				(VISUAL_CHECK_CAST ((obj), 0, VisAudio))
34 
35 typedef struct _VisAudio VisAudio;
36 
37 /**
38  * The VisAudio structure contains the sample and extra information
39  * about the sample like a 256 bands analyzer, sound energy and
40  * in the future BPM detection.
41  *
42  * @see visual_audio_new
43  */
44 struct _VisAudio {
45 	VisObject	 object;			/**< The VisObject data. */
46 
47 	short		 plugpcm[2][512];		/**< PCM data that comes from the input plugin
48 							 * or a callback function. */
49 	short		 pcm[3][512];			/**< PCM data that should be used within plugins
50 							 * pcm[0][x] is the left channel, pcm[1][x] is the right
51 							 * channel and pcm[2][x] is an average of both channels. */
52 	short		 freq[3][256];			/**< Frequency data as a 256 bands analyzer, with the channels
53 							 * like with the pcm element. */
54 	short		 freqnorm[3][256];		/**< Frequency data like the freq member, however this time the bands
55 							 * are normalized. */
56 	VisFFTState	*fft_state;			/**< Private member that contains context information for the FFT engine. */
57 
58 	short int	 bpmhistory[1024][6];		/**< Private member for BPM detection, not implemented right now. */
59 	short int	 bpmdata[1024][6];		/**< Private member for BPM detection, not implemented right now. */
60 	short int	 bpmenergy[6];			/**< Private member for BPM detection, not implemented right now. */
61 	int		 energy;			/**< Audio energy level. */
62 };
63 
64 VisAudio *visual_audio_new (void);
65 int visual_audio_analyze (VisAudio *audio);
66 
67 #ifdef __cplusplus
68 }
69 #endif /* __cplusplus */
70 
71 #endif /* _LV_AUDIO_H */
72