summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer/include/audio.hch
blob: 051e8fb4c46ca8c3a8e2149a1be7df8471aec707 (plain)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*! \file audio.hch
 *
 * \section generic Graphic Equalizer API
 *
 * \section project Project information.
 * Project Graphic Equalizer\n
 * \author O.M. Schinagl
 * \date 20041021
 * \version 0.1
 *
 * \section copyright Copyright
 * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved
 *
 * \section history Change history
 * 20041021: O.M. Schinagl\n	Initial version
 *
 ********************************************************************/
 
#ifndef _AUDIO_HCH
#define _AUDIO_HCH 1

/*
 * Type definition of the shared memory to be used in various processes
 */
typedef struct {
	mpram {
		ram unsigned 7 write[256];	
		rom unsigned 7 read[256];
	} fft_info with { block = "BlockRAM"};
	mpram {
		ram unsigned 6 write[256];	
		rom unsigned 6 read[256];
	} ifft_info with { block = "BlockRAM"};
	unsigned 4 *equalizer_levels_ptr;
	unsigned 1 display_log;
	unsigned 1 saturated;
	unsigned 1 play;
} audiodata_t;




/*
 * States used to indicate wether audio data is sampled.
 */
#define AUDIO_NOT_READY	0
#define AUDIO_READY	1



/*
 * Line in or Mic in aliases for audio_init.
 */
#define LINE_IN	RC200AudioInLineIn
#define	MIC_IN	RC200AudioInMicrophone



/*
 * Sample Rate Aliases for audio_init.
 */
#define SR_8000		RC200AudioSampleRate8000
#define SR_11025	RC200AudioSampleRate11025
#define SR_16000	RC200AudioSampleRate16000
#define SR_22050	RC200AudioSampleRate22050
#define SR_44100	RC200AudioSampleRate44100
#define SR_48000	RC200AudioSampleRate48000



/*
 * Convert microseconds to something our code understands.
 */
#define AUDIOINITDELAY ((PAL_ACTUAL_CLOCK_RATE *AUDIOINIT_MICROSECONDS) /1000000)



/*
 * Initialize the Audio sub-system. Input_source chooses between line in or mic
 * in. The sample_rate is set to supplied rate. Defines for these are mentioned
 * above.
 */
macro proc audio_init(input_source, sample_rate, AUDIOIN, AUDIOOUT);



/*
 * Main audiodriver loop. This procedure never returns! It handles audio io and
 * updates the shared memory. It needs Audio I/O handlers passed.
 */
macro proc audio_main(audiodata, AUDIOIN, AUDIOOUT);

/*
 *	FFT loop, waits until 64 samples are read from the audio input
 *	before switching the pointers needed for double and quadruple buffering, after that
 *	sequentially calling the perform_fft, equalize_audio and perform_ifft functions.
 */
macro proc run_fft(audiodata);

/*
 *	Sampling loop, fills the audio input and output arrays and uses FFT_Sync
 * 	to notify the FFT when 64 samples are read from the audio input.
 */
macro proc sample_audio(audiodata, AUDIOOIN);

/*
 *	Audio output loop, writes the modified audio samples to the audio output.	
 */
macro proc output_audio(AUDIOOUT);

#else
#error "ERROR file audio.hch multiple times included"
#endif /* --- _AUDIO_HCH --- */