1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
39 #include "sound_menu.h"
40 #include "timefuncs.h"
51 #if defined(HAVE_UDA1380)
53 #elif defined(HAVE_TLV320)
56 #include "pcm_record.h"
58 #if defined(HAVE_UDA1380) || defined(HAVE_TLV320)
60 bool pcm_rec_screen(void)
63 char filename
[MAX_PATH
];
64 char *rec_sources
[2] = {"Line-in","Mic"};
67 int rec_monitor
, rec_gain
, rec_vol
, rec_source
, rec_count
, rec_waveform
;
72 lcd_setfont(FONT_SYSFIXED
);
73 lcd_getstringsize("M", &w
, &h
);
74 lcd_setmargins(global_settings
.invert_cursor
? 0 : w
, 8);
80 #if defined(HAVE_UDA1380)
81 uda1380_enable_output(true);
82 #elif defined(HAVE_TLV320)
83 tlv320_enable_output(true);
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
);
92 rec_monitor
= 0; // No record feedback
93 rec_source
= 1; // Mic
100 pcm_set_recording_options(rec_source
, rec_waveform
);
101 pcm_set_recording_gain(rec_gain
, rec_vol
);
103 //rec_create_directory();
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
);
119 rec_time
= pcm_recorded_time();
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
);
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
);
147 button
= button_get_w_tmo(HZ
/8);
155 if (pcm_status() & AUDIO_STATUS_RECORD
)
157 pcm_stop_recording();
161 snprintf(filename
, MAX_PATH
, "/record-%0d.wav", rec_count
++);
162 pcm_record(filename
);
170 rec_source
= 1 - rec_source
;
171 pcm_set_recording_options(rec_source
, rec_waveform
);
175 case BUTTON_RIGHT
| BUTTON_REPEAT
:
179 pcm_set_recording_gain(rec_gain
, rec_vol
);
183 case BUTTON_LEFT
| BUTTON_REPEAT
:
187 pcm_set_recording_gain(rec_gain
, rec_vol
);
191 rec_monitor
= 1 - rec_monitor
;
192 #if defined(HAVE_UDA1380)
193 uda1380_set_monitor(rec_monitor
);
198 rec_waveform
= 1 - rec_waveform
;
199 pcm_set_recording_options(rec_source
, rec_waveform
);
203 case BUTTON_UP
| BUTTON_REPEAT
:
206 pcm_set_recording_gain(rec_gain
, rec_vol
);
210 case BUTTON_DOWN
| BUTTON_REPEAT
:
213 pcm_set_recording_gain(rec_gain
, rec_vol
);
216 case SYS_USB_CONNECTED
:
217 if (pcm_status() & AUDIO_STATUS_RECORD
)
219 // ignore usb while recording
222 pcm_stop_recording();
223 #if defined(HAVE_UDA1380)
224 uda1380_enable_output(false);
225 #elif defined(HAVE_TLV320)
226 tlv320_enable_output(false);
228 default_event_handler(SYS_USB_CONNECTED
);
237 pcm_stop_recording();
238 pcm_close_recording();
240 #if defined(HAVE_UDA1380)
241 uda1380_enable_output(false);
242 #elif defined(HAVE_TLV320)
243 tlv320_enable_output(false);