File: analysis.h

package info (click to toggle)
gjay 0.2.8.3-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 532 kB
  • ctags: 717
  • sloc: ansic: 6,757; makefile: 101
file content (92 lines) | stat: -rw-r--r-- 2,818 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
 * GJay, copyright (c) 2002 Chuck Groom
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 1, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 *
 * Song analysis is done in a daemon process
 */


#ifndef __ANALYSIS_H__
#define __ANALYSIS_H__

#include <stdint.h>
#include "gjay.h"


/* Shamelessly excerpted from the Linux kernel */
#if __BYTE_ORDER == __BIG_ENDIAN
#define le32_to_cpu(x) __swab32((x))
#define le16_to_cpu(x) __swab16((x))
#elif __BYTE_ORDER == __LITTLE_ENDIAN
#define le32_to_cpu(x) ((uint32_t)(x))
#define le16_to_cpu(x) ((uint16_t)(x))
#endif

#define __swab16(x) \
({ \
         uint16_t __x = (x); \
	 ((uint16_t)( \
	 (((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \
	 (((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \
})
#define __swab32(x) \
({ \
         uint32_t __x = (x); \
	         ((uint32_t)( \
			 (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
             (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) <<  8) | \
             (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >>  8) | \
             (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
})


/* WAV file header */
typedef struct {  
	char		main_chunk[4];	/* 'RIFF' */
	unsigned long	length;		/* length of file */
	char		chunk_type[4];	/* 'WAVE' */
	char		sub_chunk[4];	/* 'fmt' */
	unsigned long	length_chunk;	/* length sub_chunk, always 16 bytes */
	unsigned short	format;		/* always 1 = PCM-Code */
	unsigned short	modus;		/* 1 = Mono, 2 = Stereo */
	unsigned long	sample_fq;	/* Sample Freq */
	unsigned long	byte_p_sec;	/* Data per sec */
	unsigned short	byte_p_spl;	/* Bytes per sample */
	unsigned short	bit_p_spl;	/* bits per sample, 8, 12, 16 */
	char		data_chunk[4];	/* 'data' */
	unsigned long	data_length;	/* length of data */
} waveheaderstruct;


/* Mutex lock for analysis data */
extern song          * analyze_song;
extern int             analyze_percent;

/* Analysis.c */
void     analysis_daemon(void);
//gboolean analyze(song * s);
int      quote_path(char *buf, size_t bufsiz, const char *path);

/* Endian stuff */
void     wav_header_swab(waveheaderstruct * header); 
unsigned long  swab_ul(unsigned long l); 
unsigned short swab_us(unsigned short s);
 
#endif /* __ANALYSIS_H__ */