?? song_drv.lst
字號:
C51 COMPILER V7.50 SONG_DRV 02/16/2009 09:59:52 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE SONG_DRV
OBJECT MODULE PLACED IN song_drv.obj
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE modules\song\song_drv.c LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\song_drv.ls
-t) OBJECT(song_drv.obj)
line level source
1 /*C**************************************************************************
2 * NAME: song_drv.c
3 *----------------------------------------------------------------------------
4 * Copyright (c) 2003 Atmel.
5 *----------------------------------------------------------------------------
6 * RELEASE: snd1c-refd-nf-4_0_3
7 * REVISION: 1.20
8 *----------------------------------------------------------------------------
9 * PURPOSE:
10 * This file contains the song driver routines
11 *****************************************************************************/
12
13 /*_____ I N C L U D E S ____________________________________________________*/
14
15 #include "config.h" /* system configuration */
16 #include "lib_mcu\aud\aud_drv.h" /* dac driver definition */
17 #include "lib_mcu\mp3\mp3_drv.h" /* mp3 driver definition */
18 #include "modules\file\file.h" /* file definition */
19 #include "lib_mcu\clock\clock.h" /* clock definition */
20 #include "song_drv.h" /* song driver definition */
21
22
23 /*_____ M A C R O S ________________________________________________________*/
24
25
26 /*_____ D E F I N I T I O N ________________________________________________*/
27
28 Byte song_sound; /* save the selected sound */
29 Byte mp3_volume;
30 xdata Uint16 song_frame_size; /* Frame size value for one second */
31 idata Byte sound_volume; /* save actual sound level */
32
33 /*_____ D E C L A R A T I O N ______________________________________________*/
34
35 static void song_audio_init (void);
36
37 code Uint16 song_tab_frame_size_00 [2][16] =
38 {/* 44.1 KHz MPEG1 */
39 {0, 104, 130, 156, 182, 208, 261, 313, 365, 417, 522, 626, 731, 835, 1044, 0},
40 /* 22.05 KHz MPEG2 */
41 {0, 26, 52, 78, 104, 130, 156, 182, 208, 261, 313, 365, 417, 470, 522, 0}
42 };
43
44 code Uint16 song_tab_frame_size_01 [2][16] =
45 {
46 /* 48 Khz MPEG1 */
47 {0, 96, 120, 144, 168, 192, 240, 288, 336, 384, 480, 576, 672, 768, 960, 0},
48 /* 24 Khz MPEG2 */
49 {0, 24, 48, 72, 96, 120, 144, 168, 192, 240, 288, 336, 384, 432, 480, 0}
50 };
51
52 code Uint16 song_tab_frame_size_10 [2][16] =
53
54 {/* 32 Khz MPEG1 */
C51 COMPILER V7.50 SONG_DRV 02/16/2009 09:59:52 PAGE 2
55 {0, 144, 180, 216, 252, 288, 360, 432, 504, 576, 720, 864, 1008, 1152, 1440, 0},
56 /* 16 Khz MPEG2 */
57 {0, 36, 72, 108, 144, 180, 216, 252, 288, 360, 432, 504, 576, 648, 720, 0}
58 };
59
60
61 code Uint16 song_tab_seek [2][16]=
62 {
63 {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0},
64 {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0}
65
66 };
67
68
69 /*F**************************************************************************
70 * NAME: song_snd_init
71 *----------------------------------------------------------------------------
72 * PARAMS:
73 *
74 * return:
75 *----------------------------------------------------------------------------
76 * PURPOSE:
77 * Sound control initialization
78 *----------------------------------------------------------------------------
79 * EXAMPLE:
80 *----------------------------------------------------------------------------
81 * NOTE:
82 * Initializes the sound controls to their medium value
83 *----------------------------------------------------------------------------
84 * REQUIREMENTS:
85 *****************************************************************************/
86 void song_snd_init (void)
87 {
88 1 MP3BAS = BASS_MED;
89 1 MP3MED = MEDIUM_MED;
90 1 MP3TRE = TREBLE_MED;
91 1 MP3VOL = VOLUME_MED;
92 1 MP3VOR = VOLUME_MED;
93 1 mp3_volume = VOLUME_MED;
94 1 song_sound = SND_VOLUME; /* volume control selected by default */
95 1 }
96
97
98
99 /*F**************************************************************************
100 * NAME: song_snd_inc
101 *----------------------------------------------------------------------------
102 * PARAMS:
103 *
104 * return:
105 *----------------------------------------------------------------------------
106 * PURPOSE:
107 * Increment the selected sound control
108 *----------------------------------------------------------------------------
109 * EXAMPLE:
110 *----------------------------------------------------------------------------
111 * NOTE:
112 * The number of the current selected sound control is stored in the
113 * variable snd_select (0.Volume; 1.Bass; 2.Medium; 3. Trebble)
114 *----------------------------------------------------------------------------
115 * REQUIREMENTS:
116 *****************************************************************************/
C51 COMPILER V7.50 SONG_DRV 02/16/2009 09:59:52 PAGE 3
117 void song_snd_inc (void)
118 {
119 1 switch (song_sound)
120 1 {
121 2 case SND_VOLUME:
122 2 if (mp3_volume != VOLUME_MAX)
123 2 {
124 3 mp3_volume++;
125 3 if ((MP3CON&MSK_MPBBST) && (MP3VOL > VOLUME_MED || MP3VOR > VOLUME_MED))
126 3 {
127 4 Mp3_clr_bass_boost(); /* should be less than -15dB */
128 4 }
129 3 if (mp3_volume >= 31)
130 3 {
131 4 mp3_volume = 31; // security !
132 4 }
133 3
134 3 MP3VOL = mp3_volume;
135 3 MP3VOR = mp3_volume;
136 3 }
137 2 break;
138 2
139 2 case SND_BASS:
140 2 {
141 3 if (MP3BAS != BASS_MAX)
142 3 MP3BAS++;
143 3 break;
144 3 }
145 2
146 2 case SND_MEDIUM:
147 2 {
148 3 if (MP3MED != MEDIUM_MAX)
149 3 MP3MED++;
150 3 break;
151 3 }
152 2
153 2 case SND_TREBLE:
154 2 {
155 3 if (MP3TRE != TREBLE_MAX)
156 3 MP3TRE++;
157 3 break;
158 3 }
159 2
160 2 case SND_BBOOST:
161 2 if(MP3VOL > VOLUME_MED || MP3VOR > VOLUME_MED) /* should be less than -15dB */
162 2 mp3_volume = MP3VOL = MP3VOR = VOLUME_MED;
163 2 Mp3_set_bass_boost();
164 2 break;
165 2 }
166 1 }
167
168
169 /*F**************************************************************************
170 * NAME: song_snd_dec
171 *----------------------------------------------------------------------------
172 * PARAMS:
173 *
174 * return:
175 *----------------------------------------------------------------------------
176 * PURPOSE:
177 * Decrement the selected sound control
178 *----------------------------------------------------------------------------
C51 COMPILER V7.50 SONG_DRV 02/16/2009 09:59:52 PAGE 4
179 * EXAMPLE:
180 *----------------------------------------------------------------------------
181 * NOTE:
182 * The number of the current selected sound control is stored in the
183 * variable snd_select (0.Volume; 1.Bass; 2.Medium; 3. Trebble)
184 *----------------------------------------------------------------------------
185 * REQUIREMENTS:
186 *****************************************************************************/
187 void song_snd_dec (void)
188 {
189 1 switch (song_sound)
190 1 {
191 2 case SND_VOLUME:
192 2 {
193 3 if (mp3_volume != VOLUME_MIN)
194 3 {
195 4 mp3_volume--;
196 4 MP3VOL = MP3VOR = mp3_volume;
197 4 }
198 3 break;
199 3 }
200 2
201 2 case SND_BASS:
202 2 {
203 3 if (MP3BAS != BASS_MIN)
204 3 MP3BAS--;
205 3 break;
206 3 }
207 2
208 2 case SND_MEDIUM:
209 2 {
210 3 if (MP3MED != MEDIUM_MIN)
211 3 MP3MED--;
212 3 break;
213 3 }
214 2
215 2 case SND_TREBLE:
216 2 {
217 3 if (MP3TRE != TREBLE_MIN)
218 3 MP3TRE--;
219 3 break;
220 3 }
221 2
222 2 case SND_BBOOST:
223 2 Mp3_clr_bass_boost();
224 2 break;
225 2 }
226 1 }
227
228
229 /*F**************************************************************************
230 * NAME: song_snd_select
231 *----------------------------------------------------------------------------
232 * PARAMS:
233 *
234 * return:
235 *----------------------------------------------------------------------------
236 * PURPOSE:
237 * Select next sound control
238 *----------------------------------------------------------------------------
239 * EXAMPLE:
240 *----------------------------------------------------------------------------
C51 COMPILER V7.50 SONG_DRV 02/16/2009 09:59:52 PAGE 5
241 * NOTE:
242 *----------------------------------------------------------------------------
243 * REQUIREMENTS:
244 *****************************************************************************/
245 void song_snd_select (void)
246 {
247 1 song_sound = (song_sound + 1) % NB_SOUND;
248 1 }
249
250
251 /*F**************************************************************************
252 * NAME: song_get_sound
253 *----------------------------------------------------------------------------
254 * PARAMS:
255 *
256 * return:
257 * sound selected: SND_VOLUME, SND_BASS, SND_MEDIUM, SND_TREBLE
258 *----------------------------------------------------------------------------
259 * PURPOSE:
260 * Returns selected sound control
261 *----------------------------------------------------------------------------
262 * EXAMPLE:
263 *----------------------------------------------------------------------------
264 * NOTE:
265 *----------------------------------------------------------------------------
266 * REQUIREMENTS:
267 *****************************************************************************/
268 Byte song_get_sound (void)
269 {
270 1 return (song_sound);
271 1 }
272
273
274 /*F**************************************************************************
275 * NAME: song_get_level
276 *----------------------------------------------------------------------------
277 * PARAMS:
278 *
279 * return:
280 * level of sound selected
281 *----------------------------------------------------------------------------
282 * PURPOSE:
283 * Returns selected sound level
284 *----------------------------------------------------------------------------
285 * EXAMPLE:
286 *----------------------------------------------------------------------------
287 * NOTE:
288 *----------------------------------------------------------------------------
289 * REQUIREMENTS:
290 *****************************************************************************/
291 Byte song_get_level (void)
292 {
293 1 switch (song_sound)
294 1 {
295 2 case SND_VOLUME: return mp3_volume;
296 2 case SND_BASS: return MP3BAS;
297 2 case SND_MEDIUM: return MP3MED;
298 2 case SND_TREBLE: return MP3TRE;
299 2 case SND_BBOOST: return (MP3CON&MSK_MPBBST)?1:0;
300 2 }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -