HAVE_ADJUSTABLE_CPU_FREQ isn't defined for simulators, so we don't have to check...
[Rockbox.git] / apps / recorder / recording.c
blob5fa0f398fe0159133b31682c25afb6acea645a35
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
20 #include "config.h"
22 #include <stdio.h>
23 #include <stdbool.h>
24 #include <stdlib.h>
26 #include "system.h"
27 #include "lcd.h"
28 #include "led.h"
29 #include "mpeg.h"
30 #include "audio.h"
31 #if CONFIG_CODEC == SWCODEC
32 #include "pcm_record.h"
33 #endif
34 #ifdef HAVE_UDA1380
35 #include "uda1380.h"
36 #endif
38 #include "mp3_playback.h"
39 #include "mas.h"
40 #include "button.h"
41 #include "kernel.h"
42 #include "settings.h"
43 #include "lang.h"
44 #include "font.h"
45 #include "icons.h"
46 #include "icon.h"
47 #include "screens.h"
48 #include "peakmeter.h"
49 #include "statusbar.h"
50 #include "menu.h"
51 #include "sound_menu.h"
52 #include "timefuncs.h"
53 #include "debug.h"
54 #include "misc.h"
55 #include "tree.h"
56 #include "string.h"
57 #include "dir.h"
58 #include "errno.h"
59 #include "talk.h"
60 #include "atoi.h"
61 #include "sound.h"
62 #include "ata.h"
63 #include "splash.h"
64 #include "screen_access.h"
65 #ifdef HAVE_RECORDING
68 #if CONFIG_KEYPAD == RECORDER_PAD
69 #define REC_SHUTDOWN (BUTTON_OFF | BUTTON_REPEAT)
70 #define REC_STOPEXIT BUTTON_OFF
71 #define REC_RECPAUSE BUTTON_PLAY
72 #define REC_INC BUTTON_RIGHT
73 #define REC_DEC BUTTON_LEFT
74 #define REC_NEXT BUTTON_DOWN
75 #define REC_PREV BUTTON_UP
76 #define REC_SETTINGS BUTTON_F1
77 #define REC_F2 BUTTON_F2
78 #define REC_F3 BUTTON_F3
80 #elif CONFIG_KEYPAD == ONDIO_PAD /* only limited features */
81 #define REC_SHUTDOWN (BUTTON_OFF | BUTTON_REPEAT)
82 #define REC_STOPEXIT BUTTON_OFF
83 #define REC_RECPAUSE_PRE BUTTON_MENU
84 #define REC_RECPAUSE (BUTTON_MENU | BUTTON_REL)
85 #define REC_INC BUTTON_RIGHT
86 #define REC_DEC BUTTON_LEFT
87 #define REC_NEXT BUTTON_DOWN
88 #define REC_PREV BUTTON_UP
89 #define REC_SETTINGS (BUTTON_MENU | BUTTON_REPEAT)
91 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
92 #define REC_SHUTDOWN (BUTTON_OFF | BUTTON_REPEAT)
93 #define REC_STOPEXIT BUTTON_OFF
94 #define REC_RECPAUSE BUTTON_REC
95 #define REC_INC BUTTON_RIGHT
96 #define REC_DEC BUTTON_LEFT
97 #define REC_NEXT BUTTON_DOWN
98 #define REC_PREV BUTTON_UP
99 #define REC_SETTINGS BUTTON_MODE
101 #elif CONFIG_KEYPAD == GMINI100_PAD
102 #define REC_SHUTDOWN (BUTTON_OFF | BUTTON_REPEAT)
103 #define REC_STOPEXIT BUTTON_OFF
104 #define REC_RECPAUSE BUTTON_ON
105 #define REC_INC BUTTON_RIGHT
106 #define REC_DEC BUTTON_LEFT
107 #endif
109 #if (CONFIG_REMOTE_KEYPAD == H100_REMOTE) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
110 #define REC_RC_SHUTDOWN (BUTTON_RC_STOP | BUTTON_REPEAT)
111 #define REC_RC_STOPEXIT BUTTON_RC_STOP
112 #define REC_RC_RECPAUSE BUTTON_RC_ON
113 #define REC_RC_INC BUTTON_RC_BITRATE
114 #define REC_RC_DEC BUTTON_RC_SOURCE
115 #define REC_RC_NEXT BUTTON_RC_FF
116 #define REC_RC_PREV BUTTON_RC_REW
117 #define REC_RC_SETTINGS BUTTON_RC_MODE
118 #endif
120 bool f2_rec_screen(void);
121 bool f3_rec_screen(void);
123 #define SOURCE_MIC 0
124 #define SOURCE_LINE 1
125 #ifdef HAVE_SPDIF_IN
126 #define SOURCE_SPDIF 2
127 #define MAX_SOURCE SOURCE_SPDIF
128 #else
129 #define MAX_SOURCE SOURCE_LINE
130 #endif
132 #if CONFIG_CODEC == SWCODEC
133 #define REC_FILE_ENDING ".wav"
134 #else
135 #define REC_FILE_ENDING ".mp3"
136 #endif
138 #define MAX_FILE_SIZE 0x7FF00000 /* 2 GB - 1 MB */
140 const char* const freq_str[6] =
142 "44.1kHz",
143 "48kHz",
144 "32kHz",
145 "22.05kHz",
146 "24kHz",
147 "16kHz"
150 static void set_gain(void)
152 if(global_settings.rec_source == SOURCE_MIC)
154 audio_set_recording_gain(global_settings.rec_mic_gain,
155 0, AUDIO_GAIN_MIC);
156 #ifdef HAVE_UDA1380
157 audio_set_recording_gain(global_settings.rec_mic_decimator_left_gain,
158 global_settings.rec_mic_decimator_right_gain,
159 AUDIO_GAIN_DECIMATOR);
160 #endif
162 else
164 audio_set_recording_gain(global_settings.rec_left_gain,
165 global_settings.rec_right_gain,
166 AUDIO_GAIN_LINEIN);
167 #ifdef HAVE_UDA1380
168 audio_set_recording_gain(global_settings.rec_linein_decimator_left_gain,
169 global_settings.rec_linein_decimator_right_gain,
170 AUDIO_GAIN_DECIMATOR);
171 #endif
175 static const char* const fmtstr[] =
177 "%c%d %s", /* no decimals */
178 "%c%d.%d %s ", /* 1 decimal */
179 "%c%d.%02d %s " /* 2 decimals */
182 char *fmt_gain(int snd, int val, char *str, int len)
184 int i, d, numdec;
185 const char *unit;
187 val = sound_val2phys(snd, val);
188 char sign = ' ';
189 if(val < 0)
191 sign = '-';
192 val = abs(val);
194 numdec = sound_numdecimals(snd);
195 unit = sound_unit(snd);
197 if(numdec)
199 i = val / (10*numdec);
200 d = val % (10*numdec);
201 snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
203 else
204 snprintf(str, len, fmtstr[numdec], sign, val, unit);
206 return str;
209 char *fmt_gain2(int snd1, int val1, int snd2, int val2, char *str, int len)
211 /* same as above but for combined (added) values (recording gain) */
212 int i, d, numdec;
213 const char *unit;
215 int val = sound_val2phys(snd1, val1) + sound_val2phys(snd2, val2);
216 char sign = ' ';
217 if(val < 0)
219 sign = '-';
220 val = abs(val);
222 numdec = MAX(sound_numdecimals(snd1), sound_numdecimals(snd2));
223 unit = sound_unit(snd1); /* should be same! */
225 if(numdec)
227 i = val / (10*numdec);
228 d = val % (10*numdec);
229 snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
231 else
232 snprintf(str, len, fmtstr[numdec], sign, val, unit);
234 return str;
237 static int cursor;
239 void adjust_cursor(void)
241 int max_cursor;
243 if(cursor < 0)
244 cursor = 0;
246 switch(global_settings.rec_source)
248 case SOURCE_MIC:
249 max_cursor = 1;
250 break;
251 case SOURCE_LINE:
252 max_cursor = 3;
253 break;
254 default:
255 max_cursor = 0;
256 break;
259 if(cursor > max_cursor)
260 cursor = max_cursor;
263 char *rec_create_filename(char *buffer)
265 if(global_settings.rec_directory)
266 getcwd(buffer, MAX_PATH);
267 else
268 strncpy(buffer, rec_base_directory, MAX_PATH);
270 #ifdef CONFIG_RTC
271 create_datetime_filename(buffer, buffer, "R", REC_FILE_ENDING);
272 #else
273 create_numbered_filename(buffer, buffer, "rec_", REC_FILE_ENDING, 4);
274 #endif
275 return buffer;
278 int rec_create_directory(void)
280 int rc;
282 /* Try to create the base directory if needed */
283 if(global_settings.rec_directory == 0)
285 rc = mkdir(rec_base_directory, 0);
286 if(rc < 0 && errno != EEXIST)
288 gui_syncsplash(HZ * 2, true,
289 "Can't create the %s directory. Error code %d.",
290 rec_base_directory, rc);
291 return -1;
293 else
295 /* If we have created the directory, we want the dir browser to
296 be refreshed even if we haven't recorded anything */
297 if(errno != EEXIST)
298 return 1;
301 return 0;
304 static char path_buffer[MAX_PATH];
306 /* used in trigger_listerner and recording_screen */
307 static unsigned int last_seconds = 0;
310 * Callback function so that the peak meter code can send an event
311 * to this application. This function can be passed to
312 * peak_meter_set_trigger_listener in order to activate the trigger.
314 static void trigger_listener(int trigger_status)
316 switch (trigger_status)
318 case TRIG_GO:
319 if((audio_status() & AUDIO_STATUS_RECORD) != AUDIO_STATUS_RECORD)
321 talk_buffer_steal(); /* we use the mp3 buffer */
322 audio_record(rec_create_filename(path_buffer));
324 /* give control to mpeg thread so that it can start recording */
325 yield(); yield(); yield();
328 /* if we're already recording this is a retrigger */
329 else
331 audio_new_file(rec_create_filename(path_buffer));
332 /* tell recording_screen to reset the time */
333 last_seconds = 0;
335 break;
337 /* A _change_ to TRIG_READY means the current recording has stopped */
338 case TRIG_READY:
339 if(audio_status() & AUDIO_STATUS_RECORD)
341 audio_stop();
342 if (global_settings.rec_trigger_mode != TRIG_MODE_REARM)
344 peak_meter_set_trigger_listener(NULL);
345 peak_meter_trigger(false);
348 break;
352 #ifdef HAVE_UDA1380
353 /* Handles combined recording gain changes.
354 GAIN RANGE = negative digital / analog / positive digital
356 void change_recording_gain(bool increment, bool left, bool right,
357 int ana_mic_size, int ana_line_size)
359 if (increment)
361 if(global_settings.rec_source == SOURCE_MIC)
363 /* always changed as stereo */
364 if(global_settings.rec_mic_decimator_left_gain <
365 sound_max(SOUND_DECIMATOR_LEFT_GAIN))
367 /* increase digital gain by 1 if below max */
368 global_settings.rec_mic_decimator_left_gain++;
369 global_settings.rec_mic_decimator_right_gain =
370 global_settings.rec_mic_decimator_left_gain;
373 /* mono increase */
374 if((global_settings.rec_mic_decimator_left_gain >= ana_mic_size) &&
375 (global_settings.rec_mic_gain < sound_max(SOUND_MIC_GAIN)))
377 /* in analogue range, cycle digital gain for each analogue */
378 global_settings.rec_mic_decimator_left_gain = 0;
379 global_settings.rec_mic_decimator_right_gain =
380 global_settings.rec_mic_decimator_left_gain;
381 global_settings.rec_mic_gain++;
384 else
386 if(((left) && (right)) &&
387 (global_settings.rec_linein_decimator_left_gain <
388 sound_max(SOUND_DECIMATOR_LEFT_GAIN)) &&
389 (global_settings.rec_linein_decimator_right_gain <
390 sound_max(SOUND_DECIMATOR_RIGHT_GAIN)) )
392 /* increase digital gain by 1 if below max*/
393 global_settings.rec_linein_decimator_left_gain++;
394 global_settings.rec_linein_decimator_right_gain++;
396 else if((right) && (!left) &&
397 (global_settings.rec_linein_decimator_right_gain <
398 sound_max(SOUND_DECIMATOR_RIGHT_GAIN)))
400 global_settings.rec_linein_decimator_right_gain++;
402 else if((left) && (!right) &&
403 (global_settings.rec_linein_decimator_left_gain <
404 sound_max(SOUND_DECIMATOR_LEFT_GAIN)))
406 global_settings.rec_linein_decimator_left_gain++;
409 /* Stereo increase */
410 if((left) &&
411 (global_settings.rec_linein_decimator_left_gain >=
412 ana_line_size) &&
413 (global_settings.rec_left_gain < sound_max(SOUND_LEFT_GAIN)))
415 /* if analogue range cycle left digital gain for each */
416 global_settings.rec_linein_decimator_left_gain = 0;
417 global_settings.rec_left_gain++;
419 if((right) &&
420 (global_settings.rec_linein_decimator_right_gain >=
421 ana_line_size) &&
422 (global_settings.rec_right_gain < sound_max(SOUND_RIGHT_GAIN)))
424 /* if analogue range cycle right digital for each */
425 global_settings.rec_linein_decimator_right_gain = 0;
426 global_settings.rec_right_gain++;
430 else
432 if(global_settings.rec_source == SOURCE_MIC)
434 /* always changed as stereo */
435 if(global_settings.rec_mic_decimator_left_gain >
436 sound_min(SOUND_DECIMATOR_LEFT_GAIN))
438 /* decrease digital gain by 1 if above minimum */
439 global_settings.rec_mic_decimator_left_gain--;
440 global_settings.rec_mic_decimator_right_gain =
441 global_settings.rec_mic_decimator_left_gain;
444 /* mono decrease */
445 if((global_settings.rec_mic_decimator_left_gain < 0) &&
446 (global_settings.rec_mic_gain > sound_min(SOUND_MIC_GAIN)))
448 /* if analogue in range, cycle digital gain for each */
449 global_settings.rec_mic_decimator_left_gain = ana_mic_size - 1;
450 global_settings.rec_mic_decimator_right_gain =
451 global_settings.rec_mic_decimator_left_gain;
452 global_settings.rec_mic_gain--;
455 else
457 if( ((left) && (right)) &&
458 (global_settings.rec_linein_decimator_left_gain >
459 sound_min(SOUND_DECIMATOR_LEFT_GAIN)) &&
460 (global_settings.rec_linein_decimator_right_gain >
461 sound_min(SOUND_DECIMATOR_RIGHT_GAIN)) )
463 /* decrease digital gain by 1 if above minimum */
464 global_settings.rec_linein_decimator_left_gain--;
465 global_settings.rec_linein_decimator_right_gain--;
467 else if((right) && (!left) &&
468 (global_settings.rec_linein_decimator_right_gain >
469 sound_min(SOUND_DECIMATOR_RIGHT_GAIN)))
471 global_settings.rec_linein_decimator_right_gain--;
473 else if((left) && (!right) &&
474 (global_settings.rec_linein_decimator_left_gain >
475 sound_min(SOUND_DECIMATOR_LEFT_GAIN)))
477 global_settings.rec_linein_decimator_left_gain--;
480 /* Stereo decrease */
481 if((left) &&
482 (global_settings.rec_linein_decimator_left_gain < 0) &&
483 (global_settings.rec_left_gain > sound_min(SOUND_LEFT_GAIN)))
485 /* if in analogue range cycle left digital gain for each */
486 global_settings.rec_left_gain--;
487 global_settings.rec_linein_decimator_left_gain =
488 ana_line_size - 1;
490 if((right) &&
491 (global_settings.rec_linein_decimator_right_gain < 0) &&
492 (global_settings.rec_right_gain > sound_min(SOUND_RIGHT_GAIN)))
494 /* if in analogue range cycle right digital gain for each */
495 global_settings.rec_right_gain--;
496 global_settings.rec_linein_decimator_right_gain =
497 ana_line_size - 1;
502 #endif /* UDA1380 */
504 bool recording_screen(void)
506 long button;
507 long lastbutton = BUTTON_NONE;
508 bool done = false;
509 char buf[32];
510 char buf2[32];
511 int w, h;
512 int update_countdown = 1;
513 bool have_recorded = false;
514 unsigned int seconds;
515 int hours, minutes;
516 char path_buffer[MAX_PATH];
517 bool been_in_usb_mode = false;
518 int last_audio_stat = -1;
519 int audio_stat;
520 #if CONFIG_LED == LED_REAL
521 bool led_state = false;
522 int led_countdown = 2;
523 #endif
524 int i;
526 #ifdef HAVE_UDA1380
527 /*calculate no. of digital steps to each analogue step. Assuming
528 left dig step = right dig step, and there is an integer no. of digital steps
529 in each analogue*/
530 int ana_mic_size = sound_val2phys(SOUND_MIC_GAIN, 1) /
531 sound_val2phys(SOUND_DECIMATOR_LEFT_GAIN, 1);
532 int ana_line_size = sound_val2phys(SOUND_LEFT_GAIN, 1) /
533 sound_val2phys(SOUND_DECIMATOR_LEFT_GAIN, 1);
535 if(global_settings.rec_source == SOURCE_MIC)
537 global_settings.rec_mic_decimator_left_gain =
538 global_settings.rec_mic_decimator_right_gain;
540 #endif
542 const unsigned char *byte_units[] = {
543 ID2P(LANG_BYTE),
544 ID2P(LANG_KILOBYTE),
545 ID2P(LANG_MEGABYTE),
546 ID2P(LANG_GIGABYTE)
549 cursor = 0;
550 #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
551 ata_set_led_enabled(false);
552 #endif
553 audio_init_recording();
555 sound_set_volume(global_settings.volume);
557 #if CONFIG_CODEC == SWCODEC
558 audio_stop();
559 /* Set peak meter to recording mode */
560 peak_meter_playback(false);
561 cpu_boost(true);
562 #else
563 /* Yes, we use the D/A for monitoring */
564 peak_meter_playback(true);
565 #endif
566 peak_meter_enabled = true;
568 if (global_settings.rec_prerecord_time)
569 talk_buffer_steal(); /* will use the mp3 buffer */
571 audio_set_recording_options(global_settings.rec_frequency,
572 global_settings.rec_quality,
573 global_settings.rec_source,
574 global_settings.rec_channels,
575 global_settings.rec_editable,
576 global_settings.rec_prerecord_time);
578 set_gain();
580 settings_apply_trigger();
582 FOR_NB_SCREENS(i)
584 screens[i].setfont(FONT_SYSFIXED);
585 screens[i].getstringsize("M", &w, &h);
586 screens[i].setmargins(global_settings.invert_cursor ? 0 : w, 8);
589 if(rec_create_directory() > 0)
590 have_recorded = true;
592 while(!done)
594 #if CONFIG_CODEC == SWCODEC
595 audio_stat = pcm_rec_status();
596 #else
597 audio_stat = audio_status();
598 #endif
600 #if CONFIG_LED == LED_REAL
603 * Flash the LED while waiting to record. Turn it on while
604 * recording.
606 if(audio_stat & AUDIO_STATUS_RECORD)
608 if (audio_stat & AUDIO_STATUS_PAUSE)
610 if (--led_countdown <= 0)
612 led_state = !led_state;
613 led(led_state);
614 led_countdown = 2;
617 else
619 /* trigger is on in status TRIG_READY (no check needed) */
620 led(true);
623 else
625 int trigStat = peak_meter_trigger_status();
627 * other trigger stati than trig_off and trig_steady
628 * already imply that we are recording.
630 if (trigStat == TRIG_STEADY)
632 if (--led_countdown <= 0)
634 led_state = !led_state;
635 led(led_state);
636 led_countdown = 2;
639 else
641 /* trigger is on in status TRIG_READY (no check needed) */
642 led(false);
645 #endif /* CONFIG_LED */
647 /* Wait for a button a while (HZ/10) drawing the peak meter */
648 button = peak_meter_draw_get_btn(0, 8 + h*2, h*2);
650 if (last_audio_stat != audio_stat)
652 if (audio_stat == AUDIO_STATUS_RECORD)
654 have_recorded = true;
656 last_audio_stat = audio_stat;
659 switch(button)
661 case REC_STOPEXIT:
662 case REC_SHUTDOWN:
663 #ifdef REC_RC_STOPEXIT
664 case REC_RC_STOPEXIT:
665 #endif
666 #ifdef REC_RC_SHUTDOWN
667 case REC_RC_SHUTDOWN:
668 #endif
669 /* turn off the trigger */
670 peak_meter_trigger(false);
671 peak_meter_set_trigger_listener(NULL);
673 if(audio_stat & AUDIO_STATUS_RECORD)
675 audio_stop_recording();
677 else
679 peak_meter_playback(true);
680 #if CONFIG_CODEC != SWCODEC
681 peak_meter_enabled = false;
682 #endif
683 done = true;
685 update_countdown = 1; /* Update immediately */
686 break;
688 case REC_RECPAUSE:
689 #ifdef REC_RC_RECPAUSE
690 case REC_RC_RECPAUSE:
691 #endif
692 #ifdef REC_RECPAUSE_PRE
693 if (lastbutton != REC_RECPAUSE_PRE)
694 break;
695 #endif
696 /* Only act if the mpeg is stopped */
697 if(!(audio_stat & AUDIO_STATUS_RECORD))
699 /* is this manual or triggered recording? */
700 if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
701 (peak_meter_trigger_status() != TRIG_OFF))
703 /* manual recording */
704 have_recorded = true;
705 talk_buffer_steal(); /* we use the mp3 buffer */
706 audio_record(rec_create_filename(path_buffer));
707 last_seconds = 0;
708 if (global_settings.talk_menu)
709 { /* no voice possible here, but a beep */
710 audio_beep(HZ/2); /* longer beep on start */
714 /* this is triggered recording */
715 else
717 /* we don't start recording now, but enable the
718 trigger and let the callback function
719 trigger_listener control when the recording starts */
720 peak_meter_trigger(true);
721 peak_meter_set_trigger_listener(&trigger_listener);
724 else
726 if(audio_stat & AUDIO_STATUS_PAUSE)
728 audio_resume_recording();
729 if (global_settings.talk_menu)
730 { /* no voice possible here, but a beep */
731 audio_beep(HZ/4); /* short beep on resume */
734 else
736 audio_pause_recording();
739 update_countdown = 1; /* Update immediately */
740 break;
742 #ifdef REC_PREV
743 case REC_PREV:
744 #ifdef REC_RC_PREV
745 case REC_RC_PREV:
746 #endif
747 cursor--;
748 adjust_cursor();
749 update_countdown = 1; /* Update immediately */
750 break;
751 #endif
753 #ifdef REC_NEXT
754 case REC_NEXT:
755 #ifdef REC_RC_NEXT
756 case REC_RC_NEXT:
757 #endif
758 cursor++;
759 adjust_cursor();
760 update_countdown = 1; /* Update immediately */
761 break;
762 #endif
764 case REC_INC:
765 case REC_INC | BUTTON_REPEAT:
766 #ifdef REC_RC_INC
767 case REC_RC_INC:
768 case REC_RC_INC | BUTTON_REPEAT:
769 #endif
770 switch(cursor)
772 case 0:
773 if(global_settings.volume <
774 sound_max(SOUND_VOLUME))
775 global_settings.volume++;
776 sound_set_volume(global_settings.volume);
777 break;
778 #ifdef HAVE_UDA1380
779 case 1:
780 change_recording_gain(true, true, true,
781 ana_mic_size, ana_line_size);
782 break;
783 case 2:
784 change_recording_gain(true, true, false,
785 ana_mic_size, ana_line_size);
786 break;
787 case 3:
788 change_recording_gain(true, false, true,
789 ana_mic_size, ana_line_size);
790 break;
791 #else
792 case 1:
793 if(global_settings.rec_source == SOURCE_MIC)
795 if(global_settings.rec_mic_gain <
796 sound_max(SOUND_MIC_GAIN))
797 global_settings.rec_mic_gain++;
799 else
801 if(global_settings.rec_left_gain <
802 sound_max(SOUND_LEFT_GAIN))
803 global_settings.rec_left_gain++;
804 if(global_settings.rec_right_gain <
805 sound_max(SOUND_RIGHT_GAIN))
806 global_settings.rec_right_gain++;
808 break;
809 case 2:
810 if(global_settings.rec_left_gain <
811 sound_max(SOUND_LEFT_GAIN))
812 global_settings.rec_left_gain++;
813 break;
814 case 3:
815 if(global_settings.rec_right_gain <
816 sound_max(SOUND_RIGHT_GAIN))
817 global_settings.rec_right_gain++;
818 break;
819 #endif
821 set_gain();
822 update_countdown = 1; /* Update immediately */
823 break;
825 case REC_DEC:
826 case REC_DEC | BUTTON_REPEAT:
827 #ifdef REC_RC_INC
828 case REC_RC_DEC:
829 case REC_RC_DEC | BUTTON_REPEAT:
830 #endif
831 switch(cursor)
833 case 0:
834 if(global_settings.volume >
835 sound_min(SOUND_VOLUME))
836 global_settings.volume--;
837 sound_set_volume(global_settings.volume);
838 break;
839 #ifdef HAVE_UDA1380
840 case 1:
841 /* both channels */
842 change_recording_gain(false, true, true,
843 ana_mic_size, ana_line_size);
844 break;
845 case 2:
846 /* only left */
847 change_recording_gain(false, true, false,
848 ana_mic_size, ana_line_size);
849 break;
850 case 3:
851 /* only right */
852 change_recording_gain(false, false, true,
853 ana_mic_size, ana_line_size);
854 break;
855 #else
856 case 1:
857 if(global_settings.rec_source == SOURCE_MIC)
859 if(global_settings.rec_mic_gain >
860 sound_min(SOUND_MIC_GAIN))
861 global_settings.rec_mic_gain--;
863 else
865 if(global_settings.rec_left_gain >
866 sound_min(SOUND_LEFT_GAIN))
867 global_settings.rec_left_gain--;
868 if(global_settings.rec_right_gain >
869 sound_min(SOUND_RIGHT_GAIN))
870 global_settings.rec_right_gain--;
872 break;
873 case 2:
874 if(global_settings.rec_left_gain >
875 sound_min(SOUND_LEFT_GAIN))
876 global_settings.rec_left_gain--;
877 break;
878 case 3:
879 if(global_settings.rec_right_gain >
880 sound_min(SOUND_RIGHT_GAIN))
881 global_settings.rec_right_gain--;
882 break;
883 #endif
885 set_gain();
886 update_countdown = 1; /* Update immediately */
887 break;
889 #ifdef REC_SETTINGS
890 case REC_SETTINGS:
891 #ifdef REC_RC_SETTINGS
892 case REC_RC_SETTINGS:
893 #endif
894 if(audio_stat != AUDIO_STATUS_RECORD)
896 #if CONFIG_LED == LED_REAL
897 /* led is restored at begin of loop / end of function */
898 led(false);
899 #endif
900 if (recording_menu(false))
902 return SYS_USB_CONNECTED;
904 settings_save();
906 if (global_settings.rec_prerecord_time)
907 talk_buffer_steal(); /* will use the mp3 buffer */
909 audio_set_recording_options(global_settings.rec_frequency,
910 global_settings.rec_quality,
911 global_settings.rec_source,
912 global_settings.rec_channels,
913 global_settings.rec_editable,
914 global_settings.rec_prerecord_time);
916 adjust_cursor();
917 set_gain();
918 update_countdown = 1; /* Update immediately */
920 FOR_NB_SCREENS(i)
922 screens[i].setfont(FONT_SYSFIXED);
923 screens[i].setmargins(global_settings.invert_cursor ? 0 : w, 8);
926 break;
927 #endif
929 #ifdef REC_F2
930 case REC_F2:
931 if(audio_stat != AUDIO_STATUS_RECORD)
933 #if CONFIG_LED == LED_REAL
934 /* led is restored at begin of loop / end of function */
935 led(false);
936 #endif
937 if (f2_rec_screen())
939 have_recorded = true;
940 done = true;
942 else
943 update_countdown = 1; /* Update immediately */
945 break;
946 #endif
948 #ifdef REC_F3
949 case REC_F3:
950 if(audio_stat & AUDIO_STATUS_RECORD)
952 audio_new_file(rec_create_filename(path_buffer));
953 last_seconds = 0;
955 else
957 if(audio_stat != AUDIO_STATUS_RECORD)
959 #if CONFIG_LED == LED_REAL
960 /* led is restored at begin of loop / end of function */
961 led(false);
962 #endif
963 if (f3_rec_screen())
965 have_recorded = true;
966 done = true;
968 else
969 update_countdown = 1; /* Update immediately */
972 break;
973 #endif
975 case SYS_USB_CONNECTED:
976 /* Only accept USB connection when not recording */
977 if(audio_stat != AUDIO_STATUS_RECORD)
979 default_event_handler(SYS_USB_CONNECTED);
980 done = true;
981 been_in_usb_mode = true;
983 break;
985 default:
986 default_event_handler(button);
987 break;
989 if (button != BUTTON_NONE)
990 lastbutton = button;
992 FOR_NB_SCREENS(i)
993 screens[i].setfont(FONT_SYSFIXED);
995 seconds = audio_recorded_time() / HZ;
997 update_countdown--;
998 if(update_countdown == 0 || seconds > last_seconds)
1000 unsigned int dseconds, dhours, dminutes;
1001 unsigned long num_recorded_bytes;
1002 int pos = 0;
1004 update_countdown = 5;
1005 last_seconds = seconds;
1007 FOR_NB_SCREENS(i)
1008 screens[i].clear_display();
1010 hours = seconds / 3600;
1011 minutes = (seconds - (hours * 3600)) / 60;
1012 snprintf(buf, 32, "%s %02d:%02d:%02d",
1013 str(LANG_RECORDING_TIME),
1014 hours, minutes, seconds%60);
1015 FOR_NB_SCREENS(i)
1016 screens[i].puts(0, 0, buf);
1018 dseconds = rec_timesplit_seconds();
1019 num_recorded_bytes = audio_num_recorded_bytes();
1021 if(audio_stat & AUDIO_STATUS_PRERECORD)
1023 snprintf(buf, 32, "%s...", str(LANG_RECORD_PRERECORD));
1025 else
1027 /* Display the split interval if the record timesplit
1028 is active */
1029 if (global_settings.rec_timesplit)
1031 /* Display the record timesplit interval rather
1032 than the file size if the record timer is
1033 active */
1034 dhours = dseconds / 3600;
1035 dminutes = (dseconds - (dhours * 3600)) / 60;
1036 snprintf(buf, 32, "%s %02d:%02d",
1037 str(LANG_RECORD_TIMESPLIT_REC),
1038 dhours, dminutes);
1040 else
1042 output_dyn_value(buf2, sizeof buf2,
1043 num_recorded_bytes,
1044 byte_units, true);
1045 snprintf(buf, 32, "%s %s",
1046 str(LANG_RECORDING_SIZE), buf2);
1049 FOR_NB_SCREENS(i)
1050 screens[i].puts(0, 1, buf);
1052 /* We will do file splitting regardless, either at the end of
1053 a split interval, or when the filesize approaches the 2GB
1054 FAT file size (compatibility) limit. */
1055 if (audio_stat &&
1056 ((global_settings.rec_timesplit && (seconds >= dseconds))
1057 || (num_recorded_bytes >= MAX_FILE_SIZE)))
1059 audio_new_file(rec_create_filename(path_buffer));
1060 update_countdown = 1;
1061 last_seconds = 0;
1064 snprintf(buf, 32, "%s: %s", str(LANG_VOLUME),
1065 fmt_gain(SOUND_VOLUME,
1066 global_settings.volume,
1067 buf2, sizeof(buf2)));
1069 if (global_settings.invert_cursor && (pos++ == cursor))
1071 FOR_NB_SCREENS(i)
1072 screens[i].puts_style_offset(0, 4, buf, STYLE_INVERT,0);
1074 else
1076 FOR_NB_SCREENS(i)
1077 screens[i].puts(0, 4, buf);
1080 if(global_settings.rec_source == SOURCE_MIC)
1082 #ifdef HAVE_UDA1380
1084 /*****************test info code***********************
1085 snprintf(buf, 32, "Aa:(2x) %d DigL:(0.5x) %d ",
1086 global_settings.rec_mic_gain,
1087 global_settings.rec_mic_decimator_left_gain);
1088 lcd_puts(0, 10, buf);
1089 snprintf(buf, 32, "DigR:(0.5x) %d",
1090 global_settings.rec_mic_decimator_right_gain);
1091 lcd_puts(9, 12, buf);
1092 *****************test info code***********************/
1094 snprintf(buf, 32, "%s:%s (%s)",
1095 str(LANG_RECORDING_GAIN),
1096 fmt_gain2(SOUND_MIC_GAIN,
1097 global_settings.rec_mic_gain,
1098 SOUND_DECIMATOR_LEFT_GAIN,
1099 global_settings.rec_mic_decimator_left_gain,
1100 buf2, sizeof(buf2)),
1101 (((global_settings.rec_mic_gain ==
1102 sound_max(SOUND_MIC_GAIN)) &&
1103 (global_settings.rec_mic_decimator_left_gain > 0))||
1104 ((global_settings.rec_mic_gain ==
1105 sound_min(SOUND_MIC_GAIN)) &&
1106 (global_settings.rec_mic_decimator_left_gain < 0)))?
1107 str(LANG_RECORDING_GAIN_DIGITAL) :
1108 str(LANG_RECORDING_GAIN_ANALOG)
1110 #else /* HAVE_UDA1380 */
1111 snprintf(buf, 32, "%s:%s", str(LANG_RECORDING_GAIN),
1112 fmt_gain(SOUND_MIC_GAIN,
1113 global_settings.rec_mic_gain,
1114 buf2, sizeof(buf2)));
1115 #endif
1116 if(global_settings.invert_cursor && ((1==cursor)||(2==cursor)))
1118 FOR_NB_SCREENS(i)
1119 screens[i].puts_style_offset(0, 5, buf, STYLE_INVERT,0);
1121 else
1123 FOR_NB_SCREENS(i)
1124 screens[i].puts(0, 5, buf);
1127 else if(global_settings.rec_source == SOURCE_LINE)
1129 #ifdef HAVE_UDA1380
1131 /*****************test info code***********************
1132 snprintf(buf, 32, "AL:(3x) %d DigL:(0.5x) %d",
1133 global_settings.rec_left_gain,
1134 global_settings.rec_linein_decimator_left_gain);
1135 lcd_puts(0, 10, buf);
1136 snprintf(buf, 32, "AR:(3x) %d DigR:(0.5x) %d",
1137 global_settings.rec_right_gain,
1138 global_settings.rec_linein_decimator_right_gain);
1139 lcd_puts(0, 12, buf);
1140 *****************test info code***********************/
1142 snprintf(buf, 32, "%s:%s (%s)",
1143 str(LANG_RECORDING_LEFT),
1144 fmt_gain2(SOUND_LEFT_GAIN,
1145 global_settings.rec_left_gain,
1146 SOUND_DECIMATOR_LEFT_GAIN,
1147 global_settings.rec_linein_decimator_left_gain,
1148 buf2, sizeof(buf2)),
1149 (((global_settings.rec_left_gain ==
1150 sound_max(SOUND_LEFT_GAIN)) &&
1151 (global_settings.rec_linein_decimator_left_gain
1152 > 0)) ||
1153 ((global_settings.rec_left_gain ==
1154 sound_min(SOUND_LEFT_GAIN)) &&
1155 (global_settings.rec_linein_decimator_left_gain
1156 < 0))) ?
1157 str(LANG_RECORDING_GAIN_DIGITAL) :
1158 str(LANG_RECORDING_GAIN_ANALOG)
1160 #else /* HAVE_UDA1380 */
1161 snprintf(buf, 32, "%s:%s",
1162 str(LANG_RECORDING_LEFT),
1163 fmt_gain(SOUND_LEFT_GAIN,
1164 global_settings.rec_left_gain,
1165 buf2, sizeof(buf2)));
1166 #endif /* HAVE_UDA1380 */
1167 if(global_settings.invert_cursor && ((1==cursor)||(2==cursor)))
1169 FOR_NB_SCREENS(i)
1170 screens[i].puts_style_offset(0, 5, buf, STYLE_INVERT,0);
1172 else
1174 FOR_NB_SCREENS(i)
1175 screens[i].puts(0, 5, buf);
1178 #ifdef HAVE_UDA1380
1179 snprintf(buf, 32, "%s:%s (%s)",
1180 str(LANG_RECORDING_RIGHT),
1181 fmt_gain2(SOUND_RIGHT_GAIN,
1182 global_settings.rec_right_gain,
1183 SOUND_DECIMATOR_RIGHT_GAIN,
1184 global_settings.rec_linein_decimator_right_gain,
1185 buf2, sizeof(buf2)),
1186 (((global_settings.rec_right_gain ==
1187 sound_max(SOUND_RIGHT_GAIN)) &&
1188 (global_settings.rec_linein_decimator_right_gain
1189 > 0)) ||
1190 ((global_settings.rec_right_gain ==
1191 sound_min(SOUND_RIGHT_GAIN)) &&
1192 (global_settings.rec_linein_decimator_right_gain
1193 < 0))) ?
1194 str(LANG_RECORDING_GAIN_DIGITAL) :
1195 str(LANG_RECORDING_GAIN_ANALOG)
1197 #else /* HAVE_UDA1380 */
1198 snprintf(buf, 32, "%s:%s",
1199 str(LANG_RECORDING_RIGHT),
1200 fmt_gain(SOUND_RIGHT_GAIN,
1201 global_settings.rec_right_gain,
1202 buf2, sizeof(buf2)));
1203 #endif /* HAVE_UDA1380 */
1204 if(global_settings.invert_cursor && ((1==cursor)||(3==cursor)))
1206 FOR_NB_SCREENS(i)
1207 screens[i].puts_style_offset(0, 6, buf, STYLE_INVERT,0);
1209 else
1211 FOR_NB_SCREENS(i)
1212 screens[i].puts(0, 6, buf);
1216 if(!global_settings.invert_cursor){
1217 switch(cursor)
1219 case 1:
1220 FOR_NB_SCREENS(i)
1221 screen_put_cursorxy(&screens[i], 0, 5, true);
1223 if(global_settings.rec_source != SOURCE_MIC)
1225 FOR_NB_SCREENS(i)
1226 screen_put_cursorxy(&screens[i], 0, 6, true);
1228 break;
1229 case 2:
1230 FOR_NB_SCREENS(i)
1231 screen_put_cursorxy(&screens[i], 0, 5, true);
1232 break;
1233 case 3:
1234 FOR_NB_SCREENS(i)
1235 screen_put_cursorxy(&screens[i], 0, 6, true);
1236 break;
1237 default:
1238 FOR_NB_SCREENS(i)
1239 screen_put_cursorxy(&screens[i], 0, 4, true);
1243 snprintf(buf, 32, "%s %s",
1244 freq_str[global_settings.rec_frequency],
1245 global_settings.rec_channels?
1246 str(LANG_CHANNEL_MONO):str(LANG_CHANNEL_STEREO));
1248 /* Main screen only for this info */
1249 lcd_puts(0, 8, buf);
1251 gui_syncstatusbar_draw(&statusbars, true);
1253 FOR_NB_SCREENS(i)
1255 peak_meter_screen(&screens[i], 0, 8 + h*2, h*2);
1256 screens[i].update();
1259 /* draw the trigger status */
1260 if (peak_meter_trigger_status() != TRIG_OFF)
1262 peak_meter_draw_trig(LCD_WIDTH - TRIG_WIDTH, 4 * h);
1263 lcd_update_rect(LCD_WIDTH - (TRIG_WIDTH + 2), 4 * h,
1264 TRIG_WIDTH + 2, TRIG_HEIGHT);
1268 if(audio_stat & AUDIO_STATUS_ERROR)
1270 done = true;
1275 #if CONFIG_CODEC == SWCODEC
1276 audio_stat = pcm_rec_status();
1277 #else
1278 audio_stat = audio_status();
1279 #endif
1280 if (audio_stat & AUDIO_STATUS_ERROR)
1282 gui_syncsplash(0, true, str(LANG_DISK_FULL));
1283 gui_syncstatusbar_draw(&statusbars, true);
1284 lcd_update();
1285 audio_error_clear();
1287 while(1)
1289 button = button_get(true);
1290 if(button == (REC_STOPEXIT | BUTTON_REL))
1291 break;
1295 #if CONFIG_CODEC == SWCODEC
1296 audio_stop_recording();
1297 audio_close_recording();
1298 cpu_boost(false);
1299 #else
1300 audio_init_playback();
1301 #endif
1303 /* make sure the trigger is really turned off */
1304 peak_meter_trigger(false);
1305 peak_meter_set_trigger_listener(NULL);
1307 sound_settings_apply();
1309 lcd_setfont(FONT_UI);
1311 if (have_recorded)
1312 reload_directory();
1314 #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
1315 ata_set_led_enabled(true);
1316 #endif
1317 return been_in_usb_mode;
1320 #ifdef REC_F2
1321 bool f2_rec_screen(void)
1323 bool exit = false;
1324 bool used = false;
1325 int w, h;
1326 char buf[32];
1327 int button;
1329 lcd_setfont(FONT_SYSFIXED);
1330 lcd_getstringsize("A",&w,&h);
1332 while (!exit) {
1333 const char* ptr=NULL;
1335 lcd_clear_display();
1337 /* Recording quality */
1338 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_RECORDING_QUALITY));
1339 snprintf(buf, 32, "%d", global_settings.rec_quality);
1340 lcd_putsxy(0, LCD_HEIGHT/2-h, buf);
1341 lcd_mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
1342 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
1344 /* Frequency */
1345 snprintf(buf, sizeof buf, "%s:", str(LANG_RECORDING_FREQUENCY));
1346 lcd_getstringsize(buf,&w,&h);
1347 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf);
1348 ptr = freq_str[global_settings.rec_frequency];
1349 lcd_getstringsize(ptr, &w, &h);
1350 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr);
1351 lcd_mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
1352 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
1354 /* Channel mode */
1355 switch ( global_settings.rec_channels ) {
1356 case 0:
1357 ptr = str(LANG_CHANNEL_STEREO);
1358 break;
1360 case 1:
1361 ptr = str(LANG_CHANNEL_MONO);
1362 break;
1365 lcd_getstringsize(str(LANG_RECORDING_CHANNELS), &w, &h);
1366 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2,
1367 str(LANG_RECORDING_CHANNELS));
1368 lcd_getstringsize(str(LANG_F2_MODE), &w, &h);
1369 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F2_MODE));
1370 lcd_getstringsize(ptr, &w, &h);
1371 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr);
1372 lcd_mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
1373 LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8);
1375 lcd_update();
1377 button = button_get(true);
1378 switch (button) {
1379 case BUTTON_LEFT:
1380 case BUTTON_F2 | BUTTON_LEFT:
1381 global_settings.rec_quality++;
1382 if(global_settings.rec_quality > 7)
1383 global_settings.rec_quality = 0;
1384 used = true;
1385 break;
1387 case BUTTON_DOWN:
1388 case BUTTON_F2 | BUTTON_DOWN:
1389 global_settings.rec_frequency++;
1390 if(global_settings.rec_frequency > 5)
1391 global_settings.rec_frequency = 0;
1392 used = true;
1393 break;
1395 case BUTTON_RIGHT:
1396 case BUTTON_F2 | BUTTON_RIGHT:
1397 global_settings.rec_channels++;
1398 if(global_settings.rec_channels > 1)
1399 global_settings.rec_channels = 0;
1400 used = true;
1401 break;
1403 case BUTTON_F2 | BUTTON_REL:
1404 if ( used )
1405 exit = true;
1406 used = true;
1407 break;
1409 case BUTTON_F2 | BUTTON_REPEAT:
1410 used = true;
1411 break;
1413 default:
1414 if(default_event_handler(button) == SYS_USB_CONNECTED)
1415 return true;
1416 break;
1420 if (global_settings.rec_prerecord_time)
1421 talk_buffer_steal(); /* will use the mp3 buffer */
1423 audio_set_recording_options(global_settings.rec_frequency,
1424 global_settings.rec_quality,
1425 global_settings.rec_source,
1426 global_settings.rec_channels,
1427 global_settings.rec_editable,
1428 global_settings.rec_prerecord_time);
1430 set_gain();
1432 settings_save();
1433 lcd_setfont(FONT_UI);
1435 return false;
1437 #endif /* #ifdef REC_F2 */
1439 #ifdef REC_F3
1440 bool f3_rec_screen(void)
1442 bool exit = false;
1443 bool used = false;
1444 int w, h;
1445 int button;
1446 char *src_str[] =
1448 str(LANG_RECORDING_SRC_MIC),
1449 str(LANG_RECORDING_SRC_LINE),
1450 str(LANG_RECORDING_SRC_DIGITAL)
1453 lcd_setfont(FONT_SYSFIXED);
1454 lcd_getstringsize("A",&w,&h);
1456 while (!exit) {
1457 char* ptr=NULL;
1459 lcd_clear_display();
1461 /* Recording source */
1462 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_RECORDING_SOURCE));
1463 ptr = src_str[global_settings.rec_source];
1464 lcd_getstringsize(ptr, &w, &h);
1465 lcd_putsxy(0, LCD_HEIGHT/2-h, ptr);
1466 lcd_mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
1467 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
1469 /* trigger setup */
1470 ptr = str(LANG_RECORD_TRIGGER);
1471 lcd_getstringsize(ptr,&w,&h);
1472 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, ptr);
1473 lcd_mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
1474 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
1476 lcd_update();
1478 button = button_get(true);
1479 switch (button) {
1480 case BUTTON_DOWN:
1481 case BUTTON_F3 | BUTTON_DOWN:
1482 #ifndef SIMULATOR
1483 rectrigger();
1484 settings_apply_trigger();
1485 #endif
1486 exit = true;
1487 break;
1489 case BUTTON_LEFT:
1490 case BUTTON_F3 | BUTTON_LEFT:
1491 global_settings.rec_source++;
1492 if(global_settings.rec_source > MAX_SOURCE)
1493 global_settings.rec_source = 0;
1494 used = true;
1495 break;
1497 case BUTTON_F3 | BUTTON_REL:
1498 if ( used )
1499 exit = true;
1500 used = true;
1501 break;
1503 case BUTTON_F3 | BUTTON_REPEAT:
1504 used = true;
1505 break;
1507 default:
1508 if(default_event_handler(button) == SYS_USB_CONNECTED)
1509 return true;
1510 break;
1514 if (global_settings.rec_prerecord_time)
1515 talk_buffer_steal(); /* will use the mp3 buffer */
1517 audio_set_recording_options(global_settings.rec_frequency,
1518 global_settings.rec_quality,
1519 global_settings.rec_source,
1520 global_settings.rec_channels,
1521 global_settings.rec_editable,
1522 global_settings.rec_prerecord_time);
1525 set_gain();
1527 settings_save();
1528 lcd_setfont(FONT_UI);
1530 return false;
1532 #endif /* #ifdef REC_F3 */
1534 #if CONFIG_CODEC == SWCODEC
1535 void audio_beep(int duration)
1537 /* dummy */
1538 (void)duration;
1541 #ifdef SIMULATOR
1542 /* stubs for recording sim */
1543 void audio_init_recording(void)
1547 void audio_close_recording(void)
1551 unsigned long audio_recorded_time(void)
1553 return 123;
1556 unsigned long audio_num_recorded_bytes(void)
1558 return 5 * 1024 * 1024;
1561 void audio_set_recording_options(int frequency, int quality,
1562 int source, int channel_mode,
1563 bool editable, int prerecord_time)
1565 frequency = frequency;
1566 quality = quality;
1567 source = source;
1568 channel_mode = channel_mode;
1569 editable = editable;
1570 prerecord_time = prerecord_time;
1573 void audio_set_recording_gain(int left, int right, int type)
1575 left = left;
1576 right = right;
1577 type = type;
1580 void audio_stop_recording(void)
1584 void audio_pause_recording(void)
1588 void audio_resume_recording(void)
1592 void pcm_rec_get_peaks(int *left, int *right)
1594 if (left)
1595 *left = 0;
1596 if (right)
1597 *right = 0;
1600 void audio_record(const char *filename)
1602 filename = filename;
1605 void audio_new_file(const char *filename)
1607 filename = filename;
1610 unsigned long pcm_rec_status(void)
1612 return 0;
1615 #endif /* #ifdef SIMULATOR */
1616 #endif /* #ifdef CONFIG_CODEC == SWCODEC */
1619 #endif /* HAVE_RECORDING */