diff options
-rw-r--r-- | apps/pcm_recording.c | 251 |
1 files changed, 0 insertions, 251 deletions
diff --git a/apps/pcm_recording.c b/apps/pcm_recording.c deleted file mode 100644 index 21ca68f4e0..0000000000 --- a/apps/pcm_recording.c +++ /dev/null | |||
@@ -1,251 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "config.h" | ||
21 | |||
22 | #include <stdio.h> | ||
23 | #include <stdbool.h> | ||
24 | #include <stdlib.h> | ||
25 | |||
26 | #include "system.h" | ||
27 | #include "lcd.h" | ||
28 | #include "led.h" | ||
29 | #include "audio.h" | ||
30 | #include "button.h" | ||
31 | #include "kernel.h" | ||
32 | #include "settings.h" | ||
33 | #include "lang.h" | ||
34 | #include "font.h" | ||
35 | #include "icons.h" | ||
36 | #include "screens.h" | ||
37 | #include "status.h" | ||
38 | #include "menu.h" | ||
39 | #include "sound_menu.h" | ||
40 | #include "timefuncs.h" | ||
41 | #include "debug.h" | ||
42 | #include "misc.h" | ||
43 | #include "tree.h" | ||
44 | #include "string.h" | ||
45 | #include "dir.h" | ||
46 | #include "errno.h" | ||
47 | #include "atoi.h" | ||
48 | #include "sound.h" | ||
49 | #include "ata.h" | ||
50 | #include "logf.h" | ||
51 | #if defined(HAVE_UDA1380) | ||
52 | #include "uda1380.h" | ||
53 | #elif defined(HAVE_TLV320) | ||
54 | #include "tlv320.h" | ||
55 | #endif | ||
56 | #include "pcm_record.h" | ||
57 | |||
58 | #if defined(HAVE_UDA1380) || defined(HAVE_TLV320) | ||
59 | |||
60 | bool pcm_rec_screen(void) | ||
61 | { | ||
62 | char buf[80]; | ||
63 | char filename[MAX_PATH]; | ||
64 | char *rec_sources[2] = {"Line-in","Mic"}; | ||
65 | int line=0; | ||
66 | int play_vol; | ||
67 | int rec_monitor, rec_gain, rec_vol, rec_source, rec_count, rec_waveform; | ||
68 | int rec_time; | ||
69 | int done, button; | ||
70 | int w, h; | ||
71 | |||
72 | lcd_setfont(FONT_SYSFIXED); | ||
73 | lcd_getstringsize("M", &w, &h); | ||
74 | lcd_setmargins(0, 8); | ||
75 | |||
76 | play_vol = 120; | ||
77 | |||
78 | //cpu_boost(true); | ||
79 | |||
80 | #if defined(HAVE_UDA1380) | ||
81 | uda1380_enable_output(true); | ||
82 | #elif defined(HAVE_TLV320) | ||
83 | tlv320_enable_output(true); | ||
84 | #endif | ||
85 | |||
86 | #if defined(HAVE_UDA1380) | ||
87 | uda1380_set_master_vol(play_vol, play_vol); | ||
88 | #elif defined(HAVE_TLV320) | ||
89 | tlv320_set_headphone_vol(play_vol, play_vol); | ||
90 | #endif | ||
91 | |||
92 | rec_monitor = 0; // No record feedback | ||
93 | rec_source = 1; // Mic | ||
94 | rec_gain = 0; // 0-15 | ||
95 | rec_vol = 0; // 0-255 | ||
96 | rec_count = 0; | ||
97 | rec_waveform = 0; | ||
98 | |||
99 | pcm_open_recording(); | ||
100 | pcm_set_recording_options(rec_source, rec_waveform); | ||
101 | pcm_set_recording_gain(rec_gain, rec_vol); | ||
102 | |||
103 | //rec_create_directory(); | ||
104 | |||
105 | done = 0; | ||
106 | while(!done) | ||
107 | { | ||
108 | line = 0; | ||
109 | |||
110 | snprintf(buf, sizeof(buf), "PlayVolume: %3d", play_vol); | ||
111 | lcd_puts(0,line++, buf); | ||
112 | snprintf(buf, sizeof(buf), "Gain : %2d Volume : %2d", rec_gain, rec_vol); | ||
113 | lcd_puts(0,line++, buf); | ||
114 | snprintf(buf, sizeof(buf), "Monitor: %2d Waveform: %2d", rec_monitor, rec_waveform); | ||
115 | lcd_puts(0,line++, buf); | ||
116 | |||
117 | line++; | ||
118 | |||
119 | rec_time = pcm_recorded_time(); | ||
120 | |||
121 | snprintf(buf, sizeof(buf), "Status: %s", pcm_status() & AUDIO_STATUS_RECORD ? "RUNNING" : "STOPPED"); | ||
122 | lcd_puts(0,line++, buf); | ||
123 | snprintf(buf, sizeof(buf), "Source: %s", rec_sources[rec_source]); | ||
124 | lcd_puts(0,line++, buf); | ||
125 | snprintf(buf, sizeof(buf), "File : %s", filename); | ||
126 | lcd_puts(0,line++, buf); | ||
127 | snprintf(buf, sizeof(buf), "Time : %02d:%02d.%02d", rec_time/HZ/60, (rec_time/HZ)%60, rec_time%HZ); | ||
128 | lcd_puts(0,line++, buf); | ||
129 | |||
130 | line++; | ||
131 | |||
132 | snprintf(buf, sizeof(buf), "MODE : Select source"); | ||
133 | lcd_puts(0,line++, buf); | ||
134 | snprintf(buf, sizeof(buf), "UP/DOWN : Record volume"); | ||
135 | lcd_puts(0,line++, buf); | ||
136 | snprintf(buf, sizeof(buf), "LFT/RGHT: Record gain"); | ||
137 | lcd_puts(0,line++, buf); | ||
138 | snprintf(buf, sizeof(buf), "RMT MENU: Toggle monitor"); | ||
139 | lcd_puts(0,line++, buf); | ||
140 | snprintf(buf, sizeof(buf), "RMT PLAY: Toggle waveform"); | ||
141 | lcd_puts(0,line++, buf); | ||
142 | |||
143 | |||
144 | lcd_update(); | ||
145 | |||
146 | |||
147 | button = button_get_w_tmo(HZ/8); | ||
148 | switch (button) | ||
149 | { | ||
150 | case BUTTON_OFF: | ||
151 | done = true; | ||
152 | break; | ||
153 | |||
154 | case BUTTON_REC: | ||
155 | if (pcm_status() & AUDIO_STATUS_RECORD) | ||
156 | { | ||
157 | pcm_stop_recording(); | ||
158 | |||
159 | } else | ||
160 | { | ||
161 | create_numbered_filename(filename, "/", "rec_", ".wav", 4); | ||
162 | pcm_record(filename); | ||
163 | } | ||
164 | break; | ||
165 | |||
166 | case BUTTON_ON: | ||
167 | break; | ||
168 | |||
169 | case BUTTON_MODE: | ||
170 | rec_source = 1 - rec_source; | ||
171 | pcm_set_recording_options(rec_source, rec_waveform); | ||
172 | break; | ||
173 | |||
174 | case BUTTON_RIGHT: | ||
175 | case BUTTON_RIGHT | BUTTON_REPEAT: | ||
176 | if (rec_gain < 15) | ||
177 | rec_gain++; | ||
178 | |||
179 | pcm_set_recording_gain(rec_gain, rec_vol); | ||
180 | break; | ||
181 | |||
182 | case BUTTON_LEFT: | ||
183 | case BUTTON_LEFT | BUTTON_REPEAT: | ||
184 | if (rec_gain > 0) | ||
185 | rec_gain--; | ||
186 | |||
187 | pcm_set_recording_gain(rec_gain, rec_vol); | ||
188 | break; | ||
189 | |||
190 | case BUTTON_RC_MENU: | ||
191 | rec_monitor = 1 - rec_monitor; | ||
192 | #if defined(HAVE_UDA1380) | ||
193 | uda1380_set_monitor(rec_monitor); | ||
194 | #endif | ||
195 | break; | ||
196 | |||
197 | case BUTTON_RC_ON: | ||
198 | rec_waveform = 1 - rec_waveform; | ||
199 | pcm_set_recording_options(rec_source, rec_waveform); | ||
200 | break; | ||
201 | |||
202 | case BUTTON_UP: | ||
203 | case BUTTON_UP | BUTTON_REPEAT: | ||
204 | if (rec_vol<255) | ||
205 | rec_vol++; | ||
206 | pcm_set_recording_gain(rec_gain, rec_vol); | ||
207 | break; | ||
208 | |||
209 | case BUTTON_DOWN: | ||
210 | case BUTTON_DOWN | BUTTON_REPEAT: | ||
211 | if (rec_vol) | ||
212 | rec_vol--; | ||
213 | pcm_set_recording_gain(rec_gain, rec_vol); | ||
214 | break; | ||
215 | |||
216 | case SYS_USB_CONNECTED: | ||
217 | if (pcm_status() & AUDIO_STATUS_RECORD) | ||
218 | { | ||
219 | // ignore usb while recording | ||
220 | } else | ||
221 | { | ||
222 | pcm_stop_recording(); | ||
223 | #if defined(HAVE_UDA1380) | ||
224 | uda1380_enable_output(false); | ||
225 | #elif defined(HAVE_TLV320) | ||
226 | tlv320_enable_output(false); | ||
227 | #endif | ||
228 | default_event_handler(SYS_USB_CONNECTED); | ||
229 | return false; | ||
230 | } | ||
231 | break; | ||
232 | |||
233 | } | ||
234 | |||
235 | } | ||
236 | |||
237 | pcm_stop_recording(); | ||
238 | pcm_close_recording(); | ||
239 | |||
240 | #if defined(HAVE_UDA1380) | ||
241 | uda1380_enable_output(false); | ||
242 | #elif defined(HAVE_TLV320) | ||
243 | tlv320_enable_output(false); | ||
244 | #endif | ||
245 | |||
246 | return true; | ||
247 | } | ||
248 | |||
249 | #endif | ||
250 | |||
251 | |||