diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/SOURCES | 3 | ||||
-rw-r--r-- | apps/debug_menu.c | 6 | ||||
-rw-r--r-- | apps/main.c | 6 | ||||
-rw-r--r-- | apps/pcm_recording.c | 226 |
4 files changed, 241 insertions, 0 deletions
diff --git a/apps/SOURCES b/apps/SOURCES index d6ea2c9491..fb8acd75c6 100644 --- a/apps/SOURCES +++ b/apps/SOURCES | |||
@@ -51,4 +51,7 @@ recorder/recording.c | |||
51 | #ifdef IRIVER_H100 | 51 | #ifdef IRIVER_H100 |
52 | playback.c | 52 | playback.c |
53 | metadata.c | 53 | metadata.c |
54 | #ifndef SIMULATOR | ||
55 | pcm_recording.c | ||
56 | #endif | ||
54 | #endif | 57 | #endif |
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 71f730d2c5..7203eb820a 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -58,6 +58,9 @@ | |||
58 | #include "ata_mmc.h" | 58 | #include "ata_mmc.h" |
59 | #endif | 59 | #endif |
60 | #include "logfdisp.h" | 60 | #include "logfdisp.h" |
61 | #if defined(IRIVER_H100) && !defined(SIMULATOR) | ||
62 | extern bool pcm_rec_screen(void); | ||
63 | #endif | ||
61 | 64 | ||
62 | /*---------------------------------------------------*/ | 65 | /*---------------------------------------------------*/ |
63 | /* SPECIAL DEBUG STUFF */ | 66 | /* SPECIAL DEBUG STUFF */ |
@@ -1800,6 +1803,9 @@ bool debug_menu(void) | |||
1800 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 1803 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
1801 | { "CPU frequency", dbg_cpufreq }, | 1804 | { "CPU frequency", dbg_cpufreq }, |
1802 | #endif | 1805 | #endif |
1806 | #if defined(IRIVER_H100) && !defined(SIMULATOR) | ||
1807 | { "PCM recording", pcm_rec_screen }, | ||
1808 | #endif | ||
1803 | #if CONFIG_CPU == SH7034 | 1809 | #if CONFIG_CPU == SH7034 |
1804 | #ifdef HAVE_LCD_BITMAP | 1810 | #ifdef HAVE_LCD_BITMAP |
1805 | #ifdef HAVE_RTC | 1811 | #ifdef HAVE_RTC |
diff --git a/apps/main.c b/apps/main.c index 5a47e720e0..38851a5c7d 100644 --- a/apps/main.c +++ b/apps/main.c | |||
@@ -63,6 +63,9 @@ | |||
63 | #if (CONFIG_HWCODEC == MASNONE) | 63 | #if (CONFIG_HWCODEC == MASNONE) |
64 | #include "pcm_playback.h" | 64 | #include "pcm_playback.h" |
65 | #endif | 65 | #endif |
66 | #if defined(IRIVER_H100) && !defined(SIMULATOR) | ||
67 | #include "pcm_record.h" | ||
68 | #endif | ||
66 | 69 | ||
67 | #ifdef CONFIG_TUNER | 70 | #ifdef CONFIG_TUNER |
68 | #include "radio.h" | 71 | #include "radio.h" |
@@ -293,6 +296,9 @@ void init(void) | |||
293 | #if (CONFIG_HWCODEC == MASNONE) | 296 | #if (CONFIG_HWCODEC == MASNONE) |
294 | pcm_init(); | 297 | pcm_init(); |
295 | #endif | 298 | #endif |
299 | #if defined(IRIVER_H100) && !defined(SIMULATOR) | ||
300 | pcm_init_recording(); | ||
301 | #endif | ||
296 | #ifdef HAVE_CHARGING | 302 | #ifdef HAVE_CHARGING |
297 | car_adapter_mode_init(); | 303 | car_adapter_mode_init(); |
298 | #endif | 304 | #endif |
diff --git a/apps/pcm_recording.c b/apps/pcm_recording.c new file mode 100644 index 0000000000..dbaf4e0c2a --- /dev/null +++ b/apps/pcm_recording.c | |||
@@ -0,0 +1,226 @@ | |||
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 | #include "uda1380.h" | ||
52 | #include "pcm_record.h" | ||
53 | |||
54 | |||
55 | bool pcm_rec_screen(void) | ||
56 | { | ||
57 | char buf[80]; | ||
58 | char filename[MAX_PATH]; | ||
59 | char *rec_sources[2] = {"Line-in","Mic"}; | ||
60 | int line=0; | ||
61 | int play_vol; | ||
62 | int rec_monitor, rec_gain, rec_vol, rec_source, rec_count, rec_waveform; | ||
63 | int rec_time; | ||
64 | int done, button; | ||
65 | int w, h; | ||
66 | |||
67 | lcd_setfont(FONT_SYSFIXED); | ||
68 | lcd_getstringsize("M", &w, &h); | ||
69 | lcd_setmargins(global_settings.invert_cursor ? 0 : w, 8); | ||
70 | |||
71 | play_vol = 120; | ||
72 | |||
73 | //cpu_boost(true); | ||
74 | |||
75 | uda1380_enable_output(true); | ||
76 | uda1380_setvol(play_vol, play_vol); | ||
77 | |||
78 | rec_monitor = 0; // No record feedback | ||
79 | rec_source = 1; // Mic | ||
80 | rec_gain = 0; // 0-15 | ||
81 | rec_vol = 0; // 0-255 | ||
82 | rec_count = 0; | ||
83 | rec_waveform = 0; | ||
84 | |||
85 | pcm_open_recording(); | ||
86 | pcm_set_recording_options(rec_source, rec_waveform); | ||
87 | pcm_set_recording_gain(rec_gain, rec_vol); | ||
88 | |||
89 | //rec_create_directory(); | ||
90 | |||
91 | done = 0; | ||
92 | while(!done) | ||
93 | { | ||
94 | line = 0; | ||
95 | |||
96 | snprintf(buf, sizeof(buf), "PlayVolume: %3d", play_vol); | ||
97 | lcd_puts(0,line++, buf); | ||
98 | snprintf(buf, sizeof(buf), "Gain : %2d Volume : %2d", rec_gain, rec_vol); | ||
99 | lcd_puts(0,line++, buf); | ||
100 | snprintf(buf, sizeof(buf), "Monitor: %2d Waveform: %2d", rec_monitor, rec_waveform); | ||
101 | lcd_puts(0,line++, buf); | ||
102 | |||
103 | line++; | ||
104 | |||
105 | rec_time = pcm_recorded_time(); | ||
106 | |||
107 | snprintf(buf, sizeof(buf), "Status: %s", pcm_status() & AUDIO_STATUS_RECORD ? "RUNNING" : "STOPPED"); | ||
108 | lcd_puts(0,line++, buf); | ||
109 | snprintf(buf, sizeof(buf), "Source: %s", rec_sources[rec_source]); | ||
110 | lcd_puts(0,line++, buf); | ||
111 | snprintf(buf, sizeof(buf), "File : %s", filename); | ||
112 | lcd_puts(0,line++, buf); | ||
113 | snprintf(buf, sizeof(buf), "Time : %02d:%02d.%02d", rec_time/HZ/60, (rec_time/HZ)%60, rec_time%HZ); | ||
114 | lcd_puts(0,line++, buf); | ||
115 | |||
116 | line++; | ||
117 | |||
118 | snprintf(buf, sizeof(buf), "MODE : Select source"); | ||
119 | lcd_puts(0,line++, buf); | ||
120 | snprintf(buf, sizeof(buf), "UP/DOWN : Record volume"); | ||
121 | lcd_puts(0,line++, buf); | ||
122 | snprintf(buf, sizeof(buf), "LFT/RGHT: Record gain"); | ||
123 | lcd_puts(0,line++, buf); | ||
124 | snprintf(buf, sizeof(buf), "RMT MENU: Toggle monitor"); | ||
125 | lcd_puts(0,line++, buf); | ||
126 | snprintf(buf, sizeof(buf), "RMT PLAY: Toggle waveform"); | ||
127 | lcd_puts(0,line++, buf); | ||
128 | |||
129 | |||
130 | lcd_update(); | ||
131 | |||
132 | |||
133 | button = button_get_w_tmo(HZ/8); | ||
134 | switch (button) | ||
135 | { | ||
136 | case BUTTON_OFF: | ||
137 | done = true; | ||
138 | break; | ||
139 | |||
140 | case BUTTON_REC: | ||
141 | if (pcm_status() & AUDIO_STATUS_RECORD) | ||
142 | { | ||
143 | pcm_stop_recording(); | ||
144 | |||
145 | } else | ||
146 | { | ||
147 | snprintf(filename, MAX_PATH, "/record-%0d.wav", rec_count++); | ||
148 | pcm_record(filename); | ||
149 | } | ||
150 | break; | ||
151 | |||
152 | case BUTTON_ON: | ||
153 | break; | ||
154 | |||
155 | case BUTTON_MODE: | ||
156 | rec_source = 1 - rec_source; | ||
157 | pcm_set_recording_options(rec_source, rec_waveform); | ||
158 | break; | ||
159 | |||
160 | case BUTTON_RIGHT: | ||
161 | case BUTTON_RIGHT | BUTTON_REPEAT: | ||
162 | if (rec_gain < 15) | ||
163 | rec_gain++; | ||
164 | |||
165 | pcm_set_recording_gain(rec_gain, rec_vol); | ||
166 | break; | ||
167 | |||
168 | case BUTTON_LEFT: | ||
169 | case BUTTON_LEFT | BUTTON_REPEAT: | ||
170 | if (rec_gain > 0) | ||
171 | rec_gain--; | ||
172 | |||
173 | pcm_set_recording_gain(rec_gain, rec_vol); | ||
174 | break; | ||
175 | |||
176 | case BUTTON_RC_MENU: | ||
177 | rec_monitor = 1 - rec_monitor; | ||
178 | uda1380_set_monitor(rec_monitor); | ||
179 | break; | ||
180 | |||
181 | case BUTTON_RC_ON: | ||
182 | rec_waveform = 1 - rec_waveform; | ||
183 | pcm_set_recording_options(rec_source, rec_waveform); | ||
184 | break; | ||
185 | |||
186 | case BUTTON_UP: | ||
187 | case BUTTON_UP | BUTTON_REPEAT: | ||
188 | if (rec_vol<255) | ||
189 | rec_vol++; | ||
190 | pcm_set_recording_gain(rec_gain, rec_vol); | ||
191 | break; | ||
192 | |||
193 | case BUTTON_DOWN: | ||
194 | case BUTTON_DOWN | BUTTON_REPEAT: | ||
195 | if (rec_vol) | ||
196 | rec_vol--; | ||
197 | pcm_set_recording_gain(rec_gain, rec_vol); | ||
198 | break; | ||
199 | |||
200 | case SYS_USB_CONNECTED: | ||
201 | if (pcm_status() & AUDIO_STATUS_RECORD) | ||
202 | { | ||
203 | // ignore usb while recording | ||
204 | } else | ||
205 | { | ||
206 | pcm_stop_recording(); | ||
207 | |||
208 | uda1380_enable_output(false); | ||
209 | |||
210 | default_event_handler(SYS_USB_CONNECTED); | ||
211 | return false; | ||
212 | } | ||
213 | break; | ||
214 | |||
215 | } | ||
216 | |||
217 | } | ||
218 | |||
219 | pcm_stop_recording(); | ||
220 | pcm_close_recording(); | ||
221 | |||
222 | uda1380_enable_output(false); | ||
223 | |||
224 | return true; | ||
225 | } | ||
226 | |||