2002-11-10 16:42:31 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
2003-09-20 18:02:05 +00:00
|
|
|
#include <stdlib.h>
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
#include "system.h"
|
|
|
|
#include "lcd.h"
|
2004-06-22 10:52:39 +00:00
|
|
|
#include "led.h"
|
2002-11-10 16:42:31 +00:00
|
|
|
#include "mpeg.h"
|
2005-04-04 12:06:29 +00:00
|
|
|
#include "audio.h"
|
2005-11-12 04:00:56 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
#include "pcm_record.h"
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_UDA1380
|
|
|
|
#include "uda1380.h"
|
|
|
|
#endif
|
|
|
|
|
2004-01-05 20:42:51 +00:00
|
|
|
#include "mp3_playback.h"
|
2002-11-19 21:07:44 +00:00
|
|
|
#include "mas.h"
|
2002-11-10 16:42:31 +00:00
|
|
|
#include "button.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "settings.h"
|
|
|
|
#include "lang.h"
|
|
|
|
#include "font.h"
|
|
|
|
#include "icons.h"
|
|
|
|
#include "screens.h"
|
|
|
|
#include "peakmeter.h"
|
2005-11-20 01:02:14 +00:00
|
|
|
#include "statusbar.h"
|
2002-11-10 16:42:31 +00:00
|
|
|
#include "menu.h"
|
2002-11-10 23:18:33 +00:00
|
|
|
#include "sound_menu.h"
|
2002-11-20 00:02:52 +00:00
|
|
|
#include "timefuncs.h"
|
|
|
|
#include "debug.h"
|
2003-03-10 12:19:49 +00:00
|
|
|
#include "misc.h"
|
2004-01-21 14:58:40 +00:00
|
|
|
#include "tree.h"
|
|
|
|
#include "string.h"
|
|
|
|
#include "dir.h"
|
|
|
|
#include "errno.h"
|
2004-03-19 22:15:53 +00:00
|
|
|
#include "talk.h"
|
2004-10-17 10:00:46 +00:00
|
|
|
#include "atoi.h"
|
2005-04-01 13:41:03 +00:00
|
|
|
#include "sound.h"
|
2005-04-04 09:12:12 +00:00
|
|
|
#include "ata.h"
|
2005-11-16 15:12:15 +00:00
|
|
|
#include "splash.h"
|
2004-09-29 19:51:41 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
|
2004-10-09 11:39:30 +00:00
|
|
|
|
|
|
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
|
|
|
#define REC_STOPEXIT BUTTON_OFF
|
|
|
|
#define REC_RECPAUSE BUTTON_PLAY
|
|
|
|
#define REC_INC BUTTON_RIGHT
|
|
|
|
#define REC_DEC BUTTON_LEFT
|
|
|
|
#define REC_NEXT BUTTON_DOWN
|
|
|
|
#define REC_PREV BUTTON_UP
|
|
|
|
#define REC_SETTINGS BUTTON_F1
|
|
|
|
#define REC_F2 BUTTON_F2
|
|
|
|
#define REC_F3 BUTTON_F3
|
2005-09-05 19:17:23 +00:00
|
|
|
|
2004-10-09 11:39:30 +00:00
|
|
|
#elif CONFIG_KEYPAD == ONDIO_PAD /* only limited features */
|
|
|
|
#define REC_STOPEXIT BUTTON_OFF
|
2005-09-05 19:17:23 +00:00
|
|
|
#define REC_RECPAUSE_PRE BUTTON_MENU
|
|
|
|
#define REC_RECPAUSE (BUTTON_MENU | BUTTON_REL)
|
|
|
|
#define REC_INC BUTTON_RIGHT
|
|
|
|
#define REC_DEC BUTTON_LEFT
|
|
|
|
#define REC_NEXT BUTTON_DOWN
|
|
|
|
#define REC_PREV BUTTON_UP
|
2004-10-09 11:39:30 +00:00
|
|
|
#define REC_SETTINGS (BUTTON_MENU | BUTTON_REPEAT)
|
2005-09-05 19:17:23 +00:00
|
|
|
|
2005-12-18 10:02:41 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
|
2005-12-17 10:13:29 +00:00
|
|
|
#define REC_STOPEXIT BUTTON_OFF
|
2005-11-12 04:00:56 +00:00
|
|
|
#define REC_RECPAUSE BUTTON_REC
|
2005-02-08 15:38:01 +00:00
|
|
|
#define REC_INC BUTTON_RIGHT
|
|
|
|
#define REC_DEC BUTTON_LEFT
|
2005-11-12 04:00:56 +00:00
|
|
|
#define REC_NEXT BUTTON_DOWN
|
|
|
|
#define REC_PREV BUTTON_UP
|
|
|
|
#define REC_SETTINGS BUTTON_MODE
|
2005-09-05 19:17:23 +00:00
|
|
|
|
2005-02-08 15:38:01 +00:00
|
|
|
#elif CONFIG_KEYPAD == GMINI100_PAD
|
|
|
|
#define REC_STOPEXIT BUTTON_OFF
|
|
|
|
#define REC_RECPAUSE BUTTON_ON
|
2005-02-02 21:48:47 +00:00
|
|
|
#define REC_INC BUTTON_RIGHT
|
|
|
|
#define REC_DEC BUTTON_LEFT
|
2004-10-09 11:39:30 +00:00
|
|
|
#endif
|
|
|
|
|
2002-11-10 16:42:31 +00:00
|
|
|
bool f2_rec_screen(void);
|
|
|
|
bool f3_rec_screen(void);
|
|
|
|
|
2005-09-06 20:48:28 +00:00
|
|
|
#define SOURCE_MIC 0
|
|
|
|
#define SOURCE_LINE 1
|
|
|
|
#ifdef HAVE_SPDIF_IN
|
2002-11-10 16:42:31 +00:00
|
|
|
#define SOURCE_SPDIF 2
|
2005-09-06 20:48:28 +00:00
|
|
|
#define MAX_SOURCE SOURCE_SPDIF
|
|
|
|
#else
|
|
|
|
#define MAX_SOURCE SOURCE_LINE
|
|
|
|
#endif
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2005-11-12 04:00:56 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
#define REC_FILE_ENDING ".wav"
|
|
|
|
#else
|
|
|
|
#define REC_FILE_ENDING ".mp3"
|
|
|
|
#endif
|
|
|
|
|
2005-06-04 12:14:46 +00:00
|
|
|
#define MAX_FILE_SIZE 0x7FF00000 /* 2 GB - 1 MB */
|
|
|
|
|
2004-08-01 23:34:44 +00:00
|
|
|
const char* const freq_str[6] =
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
|
|
|
"44.1kHz",
|
|
|
|
"48kHz",
|
|
|
|
"32kHz",
|
|
|
|
"22.05kHz",
|
|
|
|
"24kHz",
|
|
|
|
"16kHz"
|
|
|
|
};
|
|
|
|
|
|
|
|
static void set_gain(void)
|
|
|
|
{
|
2002-11-10 23:18:33 +00:00
|
|
|
if(global_settings.rec_source == SOURCE_MIC)
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
2006-02-08 13:08:55 +00:00
|
|
|
audio_set_recording_gain(global_settings.rec_mic_gain,
|
|
|
|
0, AUDIO_GAIN_MIC);
|
|
|
|
#ifdef HAVE_UDA1380
|
|
|
|
audio_set_recording_gain(global_settings.rec_mic_decimator_left_gain,
|
|
|
|
global_settings.rec_mic_decimator_right_gain,
|
|
|
|
AUDIO_GAIN_DECIMATOR);
|
|
|
|
#endif
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_set_recording_gain(global_settings.rec_left_gain,
|
2006-02-08 13:08:55 +00:00
|
|
|
global_settings.rec_right_gain,
|
|
|
|
AUDIO_GAIN_LINEIN);
|
2005-11-12 04:00:56 +00:00
|
|
|
#ifdef HAVE_UDA1380
|
2006-02-08 13:08:55 +00:00
|
|
|
audio_set_recording_gain(global_settings.rec_linein_decimator_left_gain,
|
|
|
|
global_settings.rec_linein_decimator_right_gain,
|
|
|
|
AUDIO_GAIN_DECIMATOR);
|
2005-11-12 04:00:56 +00:00
|
|
|
#endif
|
2006-02-08 13:08:55 +00:00
|
|
|
}
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
|
2004-08-01 23:34:44 +00:00
|
|
|
static const char* const fmtstr[] =
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
2006-02-08 13:08:55 +00:00
|
|
|
"%c%d %s", /* no decimals */
|
|
|
|
"%c%d.%d %s ", /* 1 decimal */
|
|
|
|
"%c%d.%02d %s " /* 2 decimals */
|
2002-11-10 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
char *fmt_gain(int snd, int val, char *str, int len)
|
|
|
|
{
|
2006-02-08 13:08:55 +00:00
|
|
|
int i, d, numdec;
|
2004-07-20 22:13:24 +00:00
|
|
|
const char *unit;
|
2006-02-08 13:08:55 +00:00
|
|
|
|
|
|
|
val = sound_val2phys(snd, val);
|
|
|
|
char sign = ' ';
|
|
|
|
if(val < 0)
|
|
|
|
{
|
|
|
|
sign = '-';
|
|
|
|
val = abs(val);
|
|
|
|
}
|
2005-04-01 13:41:03 +00:00
|
|
|
numdec = sound_numdecimals(snd);
|
|
|
|
unit = sound_unit(snd);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2005-11-13 15:16:27 +00:00
|
|
|
if(numdec)
|
|
|
|
{
|
2006-02-08 13:08:55 +00:00
|
|
|
i = val / (10*numdec);
|
|
|
|
d = val % (10*numdec);
|
|
|
|
snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
|
2005-11-13 15:16:27 +00:00
|
|
|
}
|
|
|
|
else
|
2006-02-08 13:08:55 +00:00
|
|
|
snprintf(str, len, fmtstr[numdec], sign, val, unit);
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *fmt_gain2(int snd1, int val1, int snd2, int val2, char *str, int len)
|
|
|
|
{
|
|
|
|
/* same as above but for combined (added) values (recording gain) */
|
|
|
|
int i, d, numdec;
|
|
|
|
const char *unit;
|
|
|
|
|
|
|
|
int val = sound_val2phys(snd1, val1) + sound_val2phys(snd2, val2);
|
|
|
|
char sign = ' ';
|
|
|
|
if(val < 0)
|
|
|
|
{
|
|
|
|
sign = '-';
|
|
|
|
val = abs(val);
|
|
|
|
}
|
|
|
|
numdec = MAX(sound_numdecimals(snd1), sound_numdecimals(snd2));
|
|
|
|
unit = sound_unit(snd1); /* should be same! */
|
|
|
|
|
|
|
|
if(numdec)
|
|
|
|
{
|
|
|
|
i = val / (10*numdec);
|
|
|
|
d = val % (10*numdec);
|
|
|
|
snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
snprintf(str, len, fmtstr[numdec], sign, val, unit);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2002-12-18 14:57:45 +00:00
|
|
|
static int cursor;
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
void adjust_cursor(void)
|
|
|
|
{
|
2005-11-13 15:16:27 +00:00
|
|
|
int max_cursor;
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2005-11-13 15:16:27 +00:00
|
|
|
if(cursor < 0)
|
2002-11-10 16:42:31 +00:00
|
|
|
cursor = 0;
|
2005-11-13 15:16:27 +00:00
|
|
|
|
|
|
|
switch(global_settings.rec_source)
|
|
|
|
{
|
|
|
|
case SOURCE_MIC:
|
|
|
|
max_cursor = 1;
|
|
|
|
break;
|
|
|
|
case SOURCE_LINE:
|
|
|
|
max_cursor = 3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
max_cursor = 0;
|
|
|
|
break;
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
2006-02-08 13:08:55 +00:00
|
|
|
|
2005-11-13 15:16:27 +00:00
|
|
|
if(cursor > max_cursor)
|
|
|
|
cursor = max_cursor;
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
|
2004-01-21 14:58:40 +00:00
|
|
|
char *rec_create_filename(char *buffer)
|
2002-11-20 00:02:52 +00:00
|
|
|
{
|
2004-01-21 14:58:40 +00:00
|
|
|
if(global_settings.rec_directory)
|
|
|
|
getcwd(buffer, MAX_PATH);
|
|
|
|
else
|
|
|
|
strncpy(buffer, rec_base_directory, MAX_PATH);
|
2002-11-20 00:02:52 +00:00
|
|
|
|
2005-12-04 15:23:47 +00:00
|
|
|
#ifdef CONFIG_RTC
|
2005-11-12 04:00:56 +00:00
|
|
|
create_datetime_filename(buffer, buffer, "R", REC_FILE_ENDING);
|
2004-10-17 10:00:46 +00:00
|
|
|
#else
|
2005-11-12 04:00:56 +00:00
|
|
|
create_numbered_filename(buffer, buffer, "rec_", REC_FILE_ENDING, 4);
|
2004-10-17 10:00:46 +00:00
|
|
|
#endif
|
2004-01-21 14:58:40 +00:00
|
|
|
return buffer;
|
2002-11-20 00:02:52 +00:00
|
|
|
}
|
|
|
|
|
2004-06-04 12:34:29 +00:00
|
|
|
int rec_create_directory(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* Try to create the base directory if needed */
|
|
|
|
if(global_settings.rec_directory == 0)
|
|
|
|
{
|
|
|
|
rc = mkdir(rec_base_directory, 0);
|
|
|
|
if(rc < 0 && errno != EEXIST)
|
|
|
|
{
|
2005-11-16 15:12:15 +00:00
|
|
|
gui_syncsplash(HZ * 2, true,
|
2004-06-04 12:34:29 +00:00
|
|
|
"Can't create the %s directory. Error code %d.",
|
|
|
|
rec_base_directory, rc);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* If we have created the directory, we want the dir browser to
|
|
|
|
be refreshed even if we haven't recorded anything */
|
|
|
|
if(errno != EEXIST)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-04 09:12:12 +00:00
|
|
|
static char path_buffer[MAX_PATH];
|
|
|
|
|
|
|
|
/* used in trigger_listerner and recording_screen */
|
|
|
|
static unsigned int last_seconds = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback function so that the peak meter code can send an event
|
|
|
|
* to this application. This function can be passed to
|
|
|
|
* peak_meter_set_trigger_listener in order to activate the trigger.
|
|
|
|
*/
|
|
|
|
static void trigger_listener(int trigger_status)
|
|
|
|
{
|
|
|
|
switch (trigger_status)
|
|
|
|
{
|
|
|
|
case TRIG_GO:
|
2005-04-04 12:06:29 +00:00
|
|
|
if((audio_status() & AUDIO_STATUS_RECORD) != AUDIO_STATUS_RECORD)
|
2005-04-04 09:12:12 +00:00
|
|
|
{
|
|
|
|
talk_buffer_steal(); /* we use the mp3 buffer */
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_record(rec_create_filename(path_buffer));
|
2005-04-04 09:12:12 +00:00
|
|
|
|
|
|
|
/* give control to mpeg thread so that it can start recording */
|
|
|
|
yield(); yield(); yield();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we're already recording this is a retrigger */
|
|
|
|
else
|
|
|
|
{
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_new_file(rec_create_filename(path_buffer));
|
2005-04-04 09:12:12 +00:00
|
|
|
/* tell recording_screen to reset the time */
|
|
|
|
last_seconds = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* A _change_ to TRIG_READY means the current recording has stopped */
|
|
|
|
case TRIG_READY:
|
2005-04-04 12:06:29 +00:00
|
|
|
if(audio_status() & AUDIO_STATUS_RECORD)
|
2005-04-04 09:12:12 +00:00
|
|
|
{
|
2005-04-04 12:06:29 +00:00
|
|
|
audio_stop();
|
2005-04-04 09:12:12 +00:00
|
|
|
if (global_settings.rec_trigger_mode != TRIG_MODE_REARM)
|
|
|
|
{
|
|
|
|
peak_meter_set_trigger_listener(NULL);
|
|
|
|
peak_meter_trigger(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-08 13:08:55 +00:00
|
|
|
#ifdef HAVE_UDA1380
|
|
|
|
/* Handles combined recording gain changes.
|
|
|
|
GAIN RANGE = negative digital / analog / positive digital
|
|
|
|
*/
|
|
|
|
void change_recording_gain(bool increment, bool left, bool right,
|
|
|
|
int ana_mic_size, int ana_line_size)
|
|
|
|
{
|
|
|
|
if (increment)
|
|
|
|
{
|
|
|
|
if(global_settings.rec_source == SOURCE_MIC)
|
|
|
|
{
|
|
|
|
/* always changed as stereo */
|
|
|
|
if(global_settings.rec_mic_decimator_left_gain <
|
|
|
|
sound_max(SOUND_DECIMATOR_LEFT_GAIN))
|
|
|
|
{
|
|
|
|
/* increase digital gain by 1 if below max */
|
|
|
|
global_settings.rec_mic_decimator_left_gain++;
|
|
|
|
global_settings.rec_mic_decimator_right_gain =
|
|
|
|
global_settings.rec_mic_decimator_left_gain;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mono increase */
|
|
|
|
if((global_settings.rec_mic_decimator_left_gain >= ana_mic_size) &&
|
|
|
|
(global_settings.rec_mic_gain < sound_max(SOUND_MIC_GAIN)))
|
|
|
|
{
|
|
|
|
/* in analogue range, cycle digital gain for each analogue */
|
|
|
|
global_settings.rec_mic_decimator_left_gain = 0;
|
|
|
|
global_settings.rec_mic_decimator_right_gain =
|
|
|
|
global_settings.rec_mic_decimator_left_gain;
|
|
|
|
global_settings.rec_mic_gain++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(((left) && (right)) &&
|
|
|
|
(global_settings.rec_linein_decimator_left_gain <
|
|
|
|
sound_max(SOUND_DECIMATOR_LEFT_GAIN)) &&
|
|
|
|
(global_settings.rec_linein_decimator_right_gain <
|
|
|
|
sound_max(SOUND_DECIMATOR_RIGHT_GAIN)) )
|
|
|
|
{
|
|
|
|
/* increase digital gain by 1 if below max*/
|
|
|
|
global_settings.rec_linein_decimator_left_gain++;
|
|
|
|
global_settings.rec_linein_decimator_right_gain++;
|
|
|
|
}
|
|
|
|
else if((right) && (!left) &&
|
|
|
|
(global_settings.rec_linein_decimator_right_gain <
|
|
|
|
sound_max(SOUND_DECIMATOR_RIGHT_GAIN)))
|
|
|
|
{
|
|
|
|
global_settings.rec_linein_decimator_right_gain++;
|
|
|
|
}
|
|
|
|
else if((left) && (!right) &&
|
|
|
|
(global_settings.rec_linein_decimator_left_gain <
|
|
|
|
sound_max(SOUND_DECIMATOR_LEFT_GAIN)))
|
|
|
|
{
|
|
|
|
global_settings.rec_linein_decimator_left_gain++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Stereo increase */
|
|
|
|
if((left) &&
|
|
|
|
(global_settings.rec_linein_decimator_left_gain >=
|
|
|
|
ana_line_size) &&
|
|
|
|
(global_settings.rec_left_gain < sound_max(SOUND_LEFT_GAIN)))
|
|
|
|
{
|
|
|
|
/* if analogue range cycle left digital gain for each */
|
|
|
|
global_settings.rec_linein_decimator_left_gain = 0;
|
|
|
|
global_settings.rec_left_gain++;
|
|
|
|
}
|
|
|
|
if((right) &&
|
|
|
|
(global_settings.rec_linein_decimator_right_gain >=
|
|
|
|
ana_line_size) &&
|
|
|
|
(global_settings.rec_right_gain < sound_max(SOUND_RIGHT_GAIN)))
|
|
|
|
{
|
|
|
|
/* if analogue range cycle right digital for each */
|
|
|
|
global_settings.rec_linein_decimator_right_gain = 0;
|
|
|
|
global_settings.rec_right_gain++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(global_settings.rec_source == SOURCE_MIC)
|
|
|
|
{
|
|
|
|
/* always changed as stereo */
|
|
|
|
if(global_settings.rec_mic_decimator_left_gain >
|
|
|
|
sound_min(SOUND_DECIMATOR_LEFT_GAIN))
|
|
|
|
{
|
|
|
|
/* decrease digital gain by 1 if above minimum */
|
|
|
|
global_settings.rec_mic_decimator_left_gain--;
|
|
|
|
global_settings.rec_mic_decimator_right_gain =
|
|
|
|
global_settings.rec_mic_decimator_left_gain;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mono decrease */
|
|
|
|
if((global_settings.rec_mic_decimator_left_gain < 0) &&
|
|
|
|
(global_settings.rec_mic_gain > sound_min(SOUND_MIC_GAIN)))
|
|
|
|
{
|
|
|
|
/* if analogue in range, cycle digital gain for each */
|
|
|
|
global_settings.rec_mic_decimator_left_gain = ana_mic_size - 1;
|
|
|
|
global_settings.rec_mic_decimator_right_gain =
|
|
|
|
global_settings.rec_mic_decimator_left_gain;
|
|
|
|
global_settings.rec_mic_gain--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( ((left) && (right)) &&
|
|
|
|
(global_settings.rec_linein_decimator_left_gain >
|
|
|
|
sound_min(SOUND_DECIMATOR_LEFT_GAIN)) &&
|
|
|
|
(global_settings.rec_linein_decimator_right_gain >
|
|
|
|
sound_min(SOUND_DECIMATOR_RIGHT_GAIN)) )
|
|
|
|
{
|
|
|
|
/* decrease digital gain by 1 if above minimum */
|
|
|
|
global_settings.rec_linein_decimator_left_gain--;
|
|
|
|
global_settings.rec_linein_decimator_right_gain--;
|
|
|
|
}
|
|
|
|
else if((right) && (!left) &&
|
|
|
|
(global_settings.rec_linein_decimator_right_gain >
|
|
|
|
sound_min(SOUND_DECIMATOR_RIGHT_GAIN)))
|
|
|
|
{
|
|
|
|
global_settings.rec_linein_decimator_right_gain--;
|
|
|
|
}
|
|
|
|
else if((left) && (!right) &&
|
|
|
|
(global_settings.rec_linein_decimator_left_gain >
|
|
|
|
sound_min(SOUND_DECIMATOR_LEFT_GAIN)))
|
|
|
|
{
|
|
|
|
global_settings.rec_linein_decimator_left_gain--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Stereo decrease */
|
|
|
|
if((left) &&
|
|
|
|
(global_settings.rec_linein_decimator_left_gain < 0) &&
|
|
|
|
(global_settings.rec_left_gain > sound_min(SOUND_LEFT_GAIN)))
|
|
|
|
{
|
|
|
|
/* if in analogue range cycle left digital gain for each */
|
|
|
|
global_settings.rec_left_gain--;
|
|
|
|
global_settings.rec_linein_decimator_left_gain =
|
|
|
|
ana_line_size - 1;
|
|
|
|
}
|
|
|
|
if((right) &&
|
|
|
|
(global_settings.rec_linein_decimator_right_gain < 0) &&
|
|
|
|
(global_settings.rec_right_gain > sound_min(SOUND_RIGHT_GAIN)))
|
|
|
|
{
|
|
|
|
/* if in analogue range cycle right digital gain for each */
|
|
|
|
global_settings.rec_right_gain--;
|
|
|
|
global_settings.rec_linein_decimator_right_gain =
|
|
|
|
ana_line_size - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* UDA1380 */
|
|
|
|
|
2002-11-10 16:42:31 +00:00
|
|
|
bool recording_screen(void)
|
|
|
|
{
|
2005-02-16 11:04:35 +00:00
|
|
|
long button;
|
2005-09-05 19:17:23 +00:00
|
|
|
long lastbutton = BUTTON_NONE;
|
2002-11-10 16:42:31 +00:00
|
|
|
bool done = false;
|
|
|
|
char buf[32];
|
|
|
|
char buf2[32];
|
|
|
|
int w, h;
|
|
|
|
int update_countdown = 1;
|
2002-11-11 13:19:17 +00:00
|
|
|
bool have_recorded = false;
|
2003-11-20 00:33:43 +00:00
|
|
|
unsigned int seconds;
|
2002-11-19 21:07:44 +00:00
|
|
|
int hours, minutes;
|
2004-01-21 14:58:40 +00:00
|
|
|
char path_buffer[MAX_PATH];
|
|
|
|
bool been_in_usb_mode = false;
|
2005-04-04 12:06:29 +00:00
|
|
|
int last_audio_stat = -1;
|
2005-11-12 04:00:56 +00:00
|
|
|
int audio_stat;
|
2005-06-04 23:15:52 +00:00
|
|
|
#if CONFIG_LED == LED_REAL
|
2005-06-04 10:19:45 +00:00
|
|
|
bool led_state = false;
|
|
|
|
int led_countdown = 2;
|
2005-05-01 20:10:39 +00:00
|
|
|
#endif
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2006-02-08 13:08:55 +00:00
|
|
|
#ifdef HAVE_UDA1380
|
|
|
|
/*calculate no. of digital steps to each analogue step. Assuming
|
|
|
|
left dig step = right dig step, and there is an integer no. of digital steps
|
|
|
|
in each analogue*/
|
|
|
|
int ana_mic_size = sound_val2phys(SOUND_MIC_GAIN, 1) /
|
|
|
|
sound_val2phys(SOUND_DECIMATOR_LEFT_GAIN, 1);
|
|
|
|
int ana_line_size = sound_val2phys(SOUND_LEFT_GAIN, 1) /
|
|
|
|
sound_val2phys(SOUND_DECIMATOR_LEFT_GAIN, 1);
|
|
|
|
|
|
|
|
if(global_settings.rec_source == SOURCE_MIC)
|
|
|
|
{
|
|
|
|
global_settings.rec_mic_decimator_left_gain =
|
|
|
|
global_settings.rec_mic_decimator_right_gain;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-01-31 00:39:20 +00:00
|
|
|
const unsigned char *byte_units[] = {
|
|
|
|
ID2P(LANG_BYTE),
|
|
|
|
ID2P(LANG_KILOBYTE),
|
|
|
|
ID2P(LANG_MEGABYTE),
|
|
|
|
ID2P(LANG_GIGABYTE)
|
|
|
|
};
|
|
|
|
|
2002-11-10 16:42:31 +00:00
|
|
|
cursor = 0;
|
2005-06-04 23:15:52 +00:00
|
|
|
#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
|
2005-04-04 09:12:12 +00:00
|
|
|
ata_set_led_enabled(false);
|
|
|
|
#endif
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_init_recording();
|
2002-11-24 00:23:49 +00:00
|
|
|
|
2005-11-06 23:12:11 +00:00
|
|
|
sound_set_volume(global_settings.volume);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2005-11-12 04:00:56 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
audio_stop();
|
2005-12-02 01:04:03 +00:00
|
|
|
/* Set peak meter to recording mode */
|
|
|
|
peak_meter_playback(false);
|
|
|
|
cpu_boost(true);
|
|
|
|
#else
|
|
|
|
/* Yes, we use the D/A for monitoring */
|
|
|
|
peak_meter_playback(true);
|
2005-11-12 04:00:56 +00:00
|
|
|
#endif
|
2005-12-02 01:04:03 +00:00
|
|
|
peak_meter_enabled = true;
|
2005-11-12 04:00:56 +00:00
|
|
|
|
2004-03-19 22:15:53 +00:00
|
|
|
if (global_settings.rec_prerecord_time)
|
|
|
|
talk_buffer_steal(); /* will use the mp3 buffer */
|
|
|
|
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_set_recording_options(global_settings.rec_frequency,
|
2002-11-10 23:18:33 +00:00
|
|
|
global_settings.rec_quality,
|
|
|
|
global_settings.rec_source,
|
2003-04-20 22:00:30 +00:00
|
|
|
global_settings.rec_channels,
|
2003-12-31 03:13:29 +00:00
|
|
|
global_settings.rec_editable,
|
2005-11-12 14:49:43 +00:00
|
|
|
global_settings.rec_prerecord_time);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2002-11-13 08:27:18 +00:00
|
|
|
set_gain();
|
|
|
|
|
2005-04-04 09:12:12 +00:00
|
|
|
settings_apply_trigger();
|
|
|
|
|
2003-01-15 13:57:10 +00:00
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
2002-11-10 16:42:31 +00:00
|
|
|
lcd_getstringsize("M", &w, &h);
|
2005-09-01 08:04:37 +00:00
|
|
|
lcd_setmargins(global_settings.invert_cursor ? 0 : w, 8);
|
2002-11-20 00:02:52 +00:00
|
|
|
|
2004-06-04 12:34:29 +00:00
|
|
|
if(rec_create_directory() > 0)
|
|
|
|
have_recorded = true;
|
2004-06-22 10:52:39 +00:00
|
|
|
|
2002-11-10 16:42:31 +00:00
|
|
|
while(!done)
|
|
|
|
{
|
2005-11-12 04:00:56 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
audio_stat = pcm_rec_status();
|
|
|
|
#else
|
|
|
|
audio_stat = audio_status();
|
|
|
|
#endif
|
|
|
|
|
2005-06-04 23:15:52 +00:00
|
|
|
#if CONFIG_LED == LED_REAL
|
2005-04-04 09:12:12 +00:00
|
|
|
|
2004-06-22 10:52:39 +00:00
|
|
|
/*
|
|
|
|
* Flash the LED while waiting to record. Turn it on while
|
|
|
|
* recording.
|
|
|
|
*/
|
2005-04-04 12:06:29 +00:00
|
|
|
if(audio_stat & AUDIO_STATUS_RECORD)
|
2004-06-22 10:52:39 +00:00
|
|
|
{
|
2005-04-04 12:06:29 +00:00
|
|
|
if (audio_stat & AUDIO_STATUS_PAUSE)
|
2005-04-04 09:12:12 +00:00
|
|
|
{
|
2005-06-04 10:19:45 +00:00
|
|
|
if (--led_countdown <= 0)
|
2005-04-04 09:12:12 +00:00
|
|
|
{
|
2005-06-04 10:19:45 +00:00
|
|
|
led_state = !led_state;
|
|
|
|
led(led_state);
|
|
|
|
led_countdown = 2;
|
2005-04-04 09:12:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2004-06-22 10:52:39 +00:00
|
|
|
{
|
2005-04-04 09:12:12 +00:00
|
|
|
/* trigger is on in status TRIG_READY (no check needed) */
|
|
|
|
led(true);
|
2004-06-22 10:52:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-04-04 09:12:12 +00:00
|
|
|
int trigStat = peak_meter_trigger_status();
|
2005-06-04 10:19:45 +00:00
|
|
|
/*
|
|
|
|
* other trigger stati than trig_off and trig_steady
|
|
|
|
* already imply that we are recording.
|
|
|
|
*/
|
2005-04-04 09:12:12 +00:00
|
|
|
if (trigStat == TRIG_STEADY)
|
2004-06-22 10:52:39 +00:00
|
|
|
{
|
2005-06-04 10:19:45 +00:00
|
|
|
if (--led_countdown <= 0)
|
2005-04-04 09:12:12 +00:00
|
|
|
{
|
2005-06-04 10:19:45 +00:00
|
|
|
led_state = !led_state;
|
|
|
|
led(led_state);
|
|
|
|
led_countdown = 2;
|
2005-04-04 09:12:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* trigger is on in status TRIG_READY (no check needed) */
|
|
|
|
led(false);
|
2004-06-22 10:52:39 +00:00
|
|
|
}
|
|
|
|
}
|
2005-06-04 23:15:52 +00:00
|
|
|
#endif /* CONFIG_LED */
|
2004-06-22 10:52:39 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
/* Wait for a button a while (HZ/10) drawing the peak meter */
|
2005-04-04 09:12:12 +00:00
|
|
|
button = peak_meter_draw_get_btn(0, 8 + h*2, LCD_WIDTH, h);
|
|
|
|
|
2005-04-04 12:06:29 +00:00
|
|
|
if (last_audio_stat != audio_stat)
|
2005-04-04 09:12:12 +00:00
|
|
|
{
|
2005-04-04 12:06:29 +00:00
|
|
|
if (audio_stat == AUDIO_STATUS_RECORD)
|
2005-04-04 09:12:12 +00:00
|
|
|
{
|
|
|
|
have_recorded = true;
|
|
|
|
}
|
2005-04-04 12:06:29 +00:00
|
|
|
last_audio_stat = audio_stat;
|
2005-04-04 09:12:12 +00:00
|
|
|
}
|
|
|
|
|
2002-11-10 16:42:31 +00:00
|
|
|
switch(button)
|
|
|
|
{
|
2004-10-09 11:39:30 +00:00
|
|
|
case REC_STOPEXIT:
|
2005-06-04 10:19:45 +00:00
|
|
|
/* turn off the trigger */
|
|
|
|
peak_meter_trigger(false);
|
|
|
|
peak_meter_set_trigger_listener(NULL);
|
|
|
|
|
2005-04-04 12:06:29 +00:00
|
|
|
if(audio_stat & AUDIO_STATUS_RECORD)
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_stop_recording();
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
peak_meter_playback(true);
|
2005-12-02 01:04:03 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2002-11-10 16:42:31 +00:00
|
|
|
peak_meter_enabled = false;
|
2005-12-02 01:04:03 +00:00
|
|
|
#endif
|
2002-11-10 16:42:31 +00:00
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
update_countdown = 1; /* Update immediately */
|
|
|
|
break;
|
|
|
|
|
2004-10-09 11:39:30 +00:00
|
|
|
case REC_RECPAUSE:
|
2005-09-05 19:17:23 +00:00
|
|
|
#ifdef REC_RECPAUSE_PRE
|
|
|
|
if (lastbutton != REC_RECPAUSE_PRE)
|
|
|
|
break;
|
|
|
|
#endif
|
2002-11-11 08:16:18 +00:00
|
|
|
/* Only act if the mpeg is stopped */
|
2005-04-04 12:06:29 +00:00
|
|
|
if(!(audio_stat & AUDIO_STATUS_RECORD))
|
2005-04-04 09:12:12 +00:00
|
|
|
{
|
|
|
|
/* is this manual or triggered recording? */
|
|
|
|
if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
|
|
|
|
(peak_meter_trigger_status() != TRIG_OFF))
|
2005-05-26 20:02:12 +00:00
|
|
|
{
|
2005-04-04 09:12:12 +00:00
|
|
|
/* manual recording */
|
2005-05-26 20:02:12 +00:00
|
|
|
have_recorded = true;
|
|
|
|
talk_buffer_steal(); /* we use the mp3 buffer */
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_record(rec_create_filename(path_buffer));
|
2005-05-26 20:02:12 +00:00
|
|
|
last_seconds = 0;
|
|
|
|
if (global_settings.talk_menu)
|
|
|
|
{ /* no voice possible here, but a beep */
|
|
|
|
audio_beep(HZ/2); /* longer beep on start */
|
|
|
|
}
|
2004-12-24 08:42:45 +00:00
|
|
|
}
|
2005-04-04 09:12:12 +00:00
|
|
|
|
|
|
|
/* this is triggered recording */
|
2005-05-26 20:02:12 +00:00
|
|
|
else
|
|
|
|
{
|
2005-04-04 09:12:12 +00:00
|
|
|
/* we don't start recording now, but enable the
|
|
|
|
trigger and let the callback function
|
|
|
|
trigger_listener control when the recording starts */
|
|
|
|
peak_meter_trigger(true);
|
|
|
|
peak_meter_set_trigger_listener(&trigger_listener);
|
|
|
|
}
|
|
|
|
}
|
2003-11-02 11:24:38 +00:00
|
|
|
else
|
|
|
|
{
|
2005-04-04 12:06:29 +00:00
|
|
|
if(audio_stat & AUDIO_STATUS_PAUSE)
|
2004-06-03 12:10:40 +00:00
|
|
|
{
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_resume_recording();
|
2004-12-21 23:49:43 +00:00
|
|
|
if (global_settings.talk_menu)
|
|
|
|
{ /* no voice possible here, but a beep */
|
2005-04-04 12:06:29 +00:00
|
|
|
audio_beep(HZ/4); /* short beep on resume */
|
2004-12-21 23:49:43 +00:00
|
|
|
}
|
2004-06-03 12:10:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_pause_recording();
|
2004-06-03 12:10:40 +00:00
|
|
|
}
|
2003-11-02 11:24:38 +00:00
|
|
|
}
|
2005-06-04 10:19:45 +00:00
|
|
|
update_countdown = 1; /* Update immediately */
|
2002-11-10 16:42:31 +00:00
|
|
|
break;
|
|
|
|
|
2004-10-09 11:39:30 +00:00
|
|
|
#ifdef REC_PREV
|
|
|
|
case REC_PREV:
|
2002-11-10 16:42:31 +00:00
|
|
|
cursor--;
|
|
|
|
adjust_cursor();
|
|
|
|
update_countdown = 1; /* Update immediately */
|
|
|
|
break;
|
2004-10-09 11:39:30 +00:00
|
|
|
#endif
|
2004-09-19 21:58:37 +00:00
|
|
|
|
2004-10-09 11:39:30 +00:00
|
|
|
#ifdef REC_NEXT
|
|
|
|
case REC_NEXT:
|
2002-11-10 16:42:31 +00:00
|
|
|
cursor++;
|
|
|
|
adjust_cursor();
|
|
|
|
update_countdown = 1; /* Update immediately */
|
|
|
|
break;
|
2004-10-09 11:39:30 +00:00
|
|
|
#endif
|
2006-02-08 13:08:55 +00:00
|
|
|
|
2004-10-09 11:39:30 +00:00
|
|
|
case REC_INC:
|
|
|
|
case REC_INC | BUTTON_REPEAT:
|
2002-11-10 16:42:31 +00:00
|
|
|
switch(cursor)
|
|
|
|
{
|
|
|
|
case 0:
|
2005-11-13 15:16:27 +00:00
|
|
|
if(global_settings.volume <
|
|
|
|
sound_max(SOUND_VOLUME))
|
|
|
|
global_settings.volume++;
|
|
|
|
sound_set_volume(global_settings.volume);
|
|
|
|
break;
|
2006-02-08 13:08:55 +00:00
|
|
|
#ifdef HAVE_UDA1380
|
|
|
|
case 1:
|
|
|
|
change_recording_gain(true, true, true,
|
|
|
|
ana_mic_size, ana_line_size);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
change_recording_gain(true, true, false,
|
|
|
|
ana_mic_size, ana_line_size);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
change_recording_gain(true, false, true,
|
|
|
|
ana_mic_size, ana_line_size);
|
|
|
|
break;
|
|
|
|
#else
|
2005-11-13 15:16:27 +00:00
|
|
|
case 1:
|
2002-11-10 23:18:33 +00:00
|
|
|
if(global_settings.rec_source == SOURCE_MIC)
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
2005-06-04 10:19:45 +00:00
|
|
|
if(global_settings.rec_mic_gain <
|
2005-04-01 13:41:03 +00:00
|
|
|
sound_max(SOUND_MIC_GAIN))
|
2005-06-04 10:19:45 +00:00
|
|
|
global_settings.rec_mic_gain++;
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-08 13:08:55 +00:00
|
|
|
if(global_settings.rec_left_gain <
|
|
|
|
sound_max(SOUND_LEFT_GAIN))
|
|
|
|
global_settings.rec_left_gain++;
|
|
|
|
if(global_settings.rec_right_gain <
|
|
|
|
sound_max(SOUND_RIGHT_GAIN))
|
|
|
|
global_settings.rec_right_gain++;
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
break;
|
2005-11-13 15:16:27 +00:00
|
|
|
case 2:
|
2005-06-04 10:19:45 +00:00
|
|
|
if(global_settings.rec_left_gain <
|
2005-04-01 13:41:03 +00:00
|
|
|
sound_max(SOUND_LEFT_GAIN))
|
2005-06-04 10:19:45 +00:00
|
|
|
global_settings.rec_left_gain++;
|
2002-11-10 16:42:31 +00:00
|
|
|
break;
|
2005-11-13 15:16:27 +00:00
|
|
|
case 3:
|
2005-06-04 10:19:45 +00:00
|
|
|
if(global_settings.rec_right_gain <
|
2005-04-01 13:41:03 +00:00
|
|
|
sound_max(SOUND_RIGHT_GAIN))
|
2005-06-04 10:19:45 +00:00
|
|
|
global_settings.rec_right_gain++;
|
2002-11-10 16:42:31 +00:00
|
|
|
break;
|
2006-02-08 13:08:55 +00:00
|
|
|
#endif
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
set_gain();
|
|
|
|
update_countdown = 1; /* Update immediately */
|
|
|
|
break;
|
|
|
|
|
2004-10-09 11:39:30 +00:00
|
|
|
case REC_DEC:
|
|
|
|
case REC_DEC | BUTTON_REPEAT:
|
2002-11-10 16:42:31 +00:00
|
|
|
switch(cursor)
|
|
|
|
{
|
|
|
|
case 0:
|
2005-11-13 15:16:27 +00:00
|
|
|
if(global_settings.volume >
|
|
|
|
sound_min(SOUND_VOLUME))
|
|
|
|
global_settings.volume--;
|
|
|
|
sound_set_volume(global_settings.volume);
|
|
|
|
break;
|
2006-02-08 13:08:55 +00:00
|
|
|
#ifdef HAVE_UDA1380
|
|
|
|
case 1:
|
|
|
|
/* both channels */
|
|
|
|
change_recording_gain(false, true, true,
|
|
|
|
ana_mic_size, ana_line_size);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* only left */
|
|
|
|
change_recording_gain(false, true, false,
|
|
|
|
ana_mic_size, ana_line_size);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
/* only right */
|
|
|
|
change_recording_gain(false, false, true,
|
|
|
|
ana_mic_size, ana_line_size);
|
|
|
|
break;
|
|
|
|
#else
|
2005-11-13 15:16:27 +00:00
|
|
|
case 1:
|
2002-11-10 23:18:33 +00:00
|
|
|
if(global_settings.rec_source == SOURCE_MIC)
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
2005-06-04 10:19:45 +00:00
|
|
|
if(global_settings.rec_mic_gain >
|
2005-04-01 13:41:03 +00:00
|
|
|
sound_min(SOUND_MIC_GAIN))
|
2005-06-04 10:19:45 +00:00
|
|
|
global_settings.rec_mic_gain--;
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-08 13:08:55 +00:00
|
|
|
if(global_settings.rec_left_gain >
|
|
|
|
sound_min(SOUND_LEFT_GAIN))
|
|
|
|
global_settings.rec_left_gain--;
|
|
|
|
if(global_settings.rec_right_gain >
|
|
|
|
sound_min(SOUND_RIGHT_GAIN))
|
|
|
|
global_settings.rec_right_gain--;
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
break;
|
2005-11-13 15:16:27 +00:00
|
|
|
case 2:
|
2005-06-04 10:19:45 +00:00
|
|
|
if(global_settings.rec_left_gain >
|
2005-04-01 13:41:03 +00:00
|
|
|
sound_min(SOUND_LEFT_GAIN))
|
2005-06-04 10:19:45 +00:00
|
|
|
global_settings.rec_left_gain--;
|
2002-11-10 16:42:31 +00:00
|
|
|
break;
|
2005-11-13 15:16:27 +00:00
|
|
|
case 3:
|
2005-06-04 10:19:45 +00:00
|
|
|
if(global_settings.rec_right_gain >
|
|
|
|
sound_min(SOUND_RIGHT_GAIN))
|
|
|
|
global_settings.rec_right_gain--;
|
2002-11-10 16:42:31 +00:00
|
|
|
break;
|
2006-02-08 13:08:55 +00:00
|
|
|
#endif
|
2005-11-13 15:16:27 +00:00
|
|
|
}
|
2002-11-10 16:42:31 +00:00
|
|
|
set_gain();
|
|
|
|
update_countdown = 1; /* Update immediately */
|
|
|
|
break;
|
|
|
|
|
2004-10-09 11:39:30 +00:00
|
|
|
#ifdef REC_SETTINGS
|
|
|
|
case REC_SETTINGS:
|
2005-04-04 12:06:29 +00:00
|
|
|
if(audio_stat != AUDIO_STATUS_RECORD)
|
2004-10-24 22:30:55 +00:00
|
|
|
{
|
2005-06-04 23:15:52 +00:00
|
|
|
#if CONFIG_LED == LED_REAL
|
2005-04-04 09:12:12 +00:00
|
|
|
/* led is restored at begin of loop / end of function */
|
|
|
|
led(false);
|
2005-05-01 20:10:39 +00:00
|
|
|
#endif
|
2004-10-24 22:30:55 +00:00
|
|
|
if (recording_menu(false))
|
2005-04-04 09:12:12 +00:00
|
|
|
{
|
2004-10-24 22:30:55 +00:00
|
|
|
return SYS_USB_CONNECTED;
|
2005-04-04 09:12:12 +00:00
|
|
|
}
|
2004-10-24 22:30:55 +00:00
|
|
|
settings_save();
|
|
|
|
|
|
|
|
if (global_settings.rec_prerecord_time)
|
|
|
|
talk_buffer_steal(); /* will use the mp3 buffer */
|
|
|
|
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_set_recording_options(global_settings.rec_frequency,
|
2004-10-24 22:30:55 +00:00
|
|
|
global_settings.rec_quality,
|
|
|
|
global_settings.rec_source,
|
|
|
|
global_settings.rec_channels,
|
|
|
|
global_settings.rec_editable,
|
2005-11-12 14:49:43 +00:00
|
|
|
global_settings.rec_prerecord_time);
|
2005-11-13 15:16:27 +00:00
|
|
|
|
|
|
|
adjust_cursor();
|
2004-10-24 22:30:55 +00:00
|
|
|
set_gain();
|
|
|
|
update_countdown = 1; /* Update immediately */
|
2003-12-20 22:15:45 +00:00
|
|
|
|
2004-10-24 22:30:55 +00:00
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
2005-09-01 08:04:37 +00:00
|
|
|
lcd_setmargins(global_settings.invert_cursor ? 0 : w, 8);
|
2004-10-24 22:30:55 +00:00
|
|
|
}
|
2002-11-10 23:18:33 +00:00
|
|
|
break;
|
2004-10-09 11:39:30 +00:00
|
|
|
#endif
|
2002-11-10 23:18:33 +00:00
|
|
|
|
2004-10-09 11:39:30 +00:00
|
|
|
#ifdef REC_F2
|
|
|
|
case REC_F2:
|
2005-04-04 12:06:29 +00:00
|
|
|
if(audio_stat != AUDIO_STATUS_RECORD)
|
2003-04-20 22:00:30 +00:00
|
|
|
{
|
2005-06-04 23:15:52 +00:00
|
|
|
#if CONFIG_LED == LED_REAL
|
2005-04-04 09:12:12 +00:00
|
|
|
/* led is restored at begin of loop / end of function */
|
|
|
|
led(false);
|
2005-05-01 20:10:39 +00:00
|
|
|
#endif
|
2003-04-20 22:00:30 +00:00
|
|
|
if (f2_rec_screen())
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
|
|
|
have_recorded = true;
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
update_countdown = 1; /* Update immediately */
|
2003-04-20 22:00:30 +00:00
|
|
|
}
|
2002-11-10 16:42:31 +00:00
|
|
|
break;
|
2004-10-09 11:39:30 +00:00
|
|
|
#endif
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2004-10-09 11:39:30 +00:00
|
|
|
#ifdef REC_F3
|
|
|
|
case REC_F3:
|
2005-04-04 12:06:29 +00:00
|
|
|
if(audio_stat & AUDIO_STATUS_RECORD)
|
2003-04-20 22:00:30 +00:00
|
|
|
{
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_new_file(rec_create_filename(path_buffer));
|
2004-06-03 12:10:40 +00:00
|
|
|
last_seconds = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-04-04 12:06:29 +00:00
|
|
|
if(audio_stat != AUDIO_STATUS_RECORD)
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
2005-06-04 23:15:52 +00:00
|
|
|
#if CONFIG_LED == LED_REAL
|
2005-04-04 09:12:12 +00:00
|
|
|
/* led is restored at begin of loop / end of function */
|
|
|
|
led(false);
|
2005-05-01 20:10:39 +00:00
|
|
|
#endif
|
2004-06-03 12:10:40 +00:00
|
|
|
if (f3_rec_screen())
|
|
|
|
{
|
|
|
|
have_recorded = true;
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
update_countdown = 1; /* Update immediately */
|
2003-11-20 00:33:43 +00:00
|
|
|
}
|
2003-04-20 22:00:30 +00:00
|
|
|
}
|
2002-11-10 16:42:31 +00:00
|
|
|
break;
|
2004-10-09 11:39:30 +00:00
|
|
|
#endif
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2003-11-20 00:33:43 +00:00
|
|
|
case SYS_USB_CONNECTED:
|
|
|
|
/* Only accept USB connection when not recording */
|
2005-04-04 12:06:29 +00:00
|
|
|
if(audio_stat != AUDIO_STATUS_RECORD)
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
2004-07-26 16:06:59 +00:00
|
|
|
default_event_handler(SYS_USB_CONNECTED);
|
2003-11-20 00:33:43 +00:00
|
|
|
done = true;
|
2004-01-21 14:58:40 +00:00
|
|
|
been_in_usb_mode = true;
|
2003-11-20 00:33:43 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-07-26 16:06:59 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
default_event_handler(button);
|
|
|
|
break;
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
2005-09-05 19:17:23 +00:00
|
|
|
if (button != BUTTON_NONE)
|
|
|
|
lastbutton = button;
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2005-11-12 04:00:56 +00:00
|
|
|
seconds = audio_recorded_time() / HZ;
|
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
update_countdown--;
|
|
|
|
if(update_countdown == 0 || seconds > last_seconds)
|
|
|
|
{
|
|
|
|
unsigned int dseconds, dhours, dminutes;
|
2005-06-04 12:14:46 +00:00
|
|
|
unsigned long num_recorded_bytes;
|
2005-06-04 10:19:45 +00:00
|
|
|
int pos = 0;
|
2003-04-24 12:57:15 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
update_countdown = 5;
|
|
|
|
last_seconds = seconds;
|
2002-11-19 21:07:44 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
lcd_clear_display();
|
2002-11-19 21:07:44 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
hours = seconds / 3600;
|
|
|
|
minutes = (seconds - (hours * 3600)) / 60;
|
|
|
|
snprintf(buf, 32, "%s %02d:%02d:%02d",
|
|
|
|
str(LANG_RECORDING_TIME),
|
|
|
|
hours, minutes, seconds%60);
|
|
|
|
lcd_puts(0, 0, buf);
|
2003-06-04 13:48:50 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
dseconds = rec_timesplit_seconds();
|
2005-11-12 04:00:56 +00:00
|
|
|
num_recorded_bytes = audio_num_recorded_bytes();
|
2003-06-04 13:48:50 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
if(audio_stat & AUDIO_STATUS_PRERECORD)
|
|
|
|
{
|
|
|
|
snprintf(buf, 32, "%s...", str(LANG_RECORD_PRERECORD));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Display the split interval if the record timesplit
|
|
|
|
is active */
|
|
|
|
if (global_settings.rec_timesplit)
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
2005-06-04 10:19:45 +00:00
|
|
|
/* Display the record timesplit interval rather
|
|
|
|
than the file size if the record timer is
|
|
|
|
active */
|
|
|
|
dhours = dseconds / 3600;
|
|
|
|
dminutes = (dseconds - (dhours * 3600)) / 60;
|
|
|
|
snprintf(buf, 32, "%s %02d:%02d",
|
|
|
|
str(LANG_RECORD_TIMESPLIT_REC),
|
|
|
|
dhours, dminutes);
|
2003-06-04 13:48:50 +00:00
|
|
|
}
|
|
|
|
else
|
2003-12-31 03:13:29 +00:00
|
|
|
{
|
2005-06-04 10:19:45 +00:00
|
|
|
output_dyn_value(buf2, sizeof buf2,
|
2005-06-04 12:14:46 +00:00
|
|
|
num_recorded_bytes,
|
2005-06-04 10:19:45 +00:00
|
|
|
byte_units, true);
|
|
|
|
snprintf(buf, 32, "%s %s",
|
|
|
|
str(LANG_RECORDING_SIZE), buf2);
|
2003-12-31 03:13:29 +00:00
|
|
|
}
|
2005-06-04 10:19:45 +00:00
|
|
|
}
|
|
|
|
lcd_puts(0, 1, buf);
|
2003-02-14 02:48:12 +00:00
|
|
|
|
2005-09-11 17:57:31 +00:00
|
|
|
/* We will do file splitting regardless, either at the end of
|
|
|
|
a split interval, or when the filesize approaches the 2GB
|
|
|
|
FAT file size (compatibility) limit. */
|
2005-06-04 12:14:46 +00:00
|
|
|
if (audio_stat &&
|
|
|
|
((global_settings.rec_timesplit && (seconds >= dseconds))
|
|
|
|
|| (num_recorded_bytes >= MAX_FILE_SIZE)))
|
2005-06-04 10:19:45 +00:00
|
|
|
{
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_new_file(rec_create_filename(path_buffer));
|
2005-06-04 10:19:45 +00:00
|
|
|
update_countdown = 1;
|
|
|
|
last_seconds = 0;
|
|
|
|
}
|
2003-11-20 00:33:43 +00:00
|
|
|
|
2005-11-13 15:16:27 +00:00
|
|
|
snprintf(buf, 32, "%s: %s", str(LANG_VOLUME),
|
|
|
|
fmt_gain(SOUND_VOLUME,
|
|
|
|
global_settings.volume,
|
|
|
|
buf2, sizeof(buf2)));
|
|
|
|
|
|
|
|
if (global_settings.invert_cursor && (pos++ == cursor))
|
|
|
|
lcd_puts_style(0, 3, buf, STYLE_INVERT);
|
|
|
|
else
|
|
|
|
lcd_puts(0, 3, buf);
|
2006-02-08 13:08:55 +00:00
|
|
|
|
2005-11-13 15:16:27 +00:00
|
|
|
|
2005-09-06 20:48:28 +00:00
|
|
|
if(global_settings.rec_source == SOURCE_MIC)
|
2006-02-08 13:08:55 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_UDA1380
|
|
|
|
|
|
|
|
/*****************test info code***********************
|
|
|
|
snprintf(buf, 32, "Aa:(2x) %d DigL:(0.5x) %d ",
|
|
|
|
global_settings.rec_mic_gain,
|
|
|
|
global_settings.rec_mic_decimator_left_gain);
|
|
|
|
lcd_puts(0, 10, buf);
|
|
|
|
snprintf(buf, 32, "DigR:(0.5x) %d",
|
|
|
|
global_settings.rec_mic_decimator_right_gain);
|
|
|
|
lcd_puts(9, 12, buf);
|
|
|
|
*****************test info code***********************/
|
|
|
|
|
|
|
|
snprintf(buf, 32, "%s:%s (%s)",
|
|
|
|
str(LANG_RECORDING_GAIN),
|
|
|
|
fmt_gain2(SOUND_MIC_GAIN,
|
|
|
|
global_settings.rec_mic_gain,
|
|
|
|
SOUND_DECIMATOR_LEFT_GAIN,
|
|
|
|
global_settings.rec_mic_decimator_left_gain,
|
|
|
|
buf2, sizeof(buf2)),
|
|
|
|
(((global_settings.rec_mic_gain ==
|
|
|
|
sound_max(SOUND_MIC_GAIN)) &&
|
|
|
|
(global_settings.rec_mic_decimator_left_gain > 0))||
|
|
|
|
((global_settings.rec_mic_gain ==
|
|
|
|
sound_min(SOUND_MIC_GAIN)) &&
|
|
|
|
(global_settings.rec_mic_decimator_left_gain < 0)))?
|
|
|
|
str(LANG_RECORDING_GAIN_DIGITAL) :
|
|
|
|
str(LANG_RECORDING_GAIN_ANALOG)
|
|
|
|
);
|
|
|
|
#else /* HAVE_UDA1380 */
|
|
|
|
snprintf(buf, 32, "%s:%s", str(LANG_RECORDING_GAIN),
|
2005-06-04 10:19:45 +00:00
|
|
|
fmt_gain(SOUND_MIC_GAIN,
|
|
|
|
global_settings.rec_mic_gain,
|
|
|
|
buf2, sizeof(buf2)));
|
2006-02-08 13:08:55 +00:00
|
|
|
#endif
|
|
|
|
if(global_settings.invert_cursor && ((1==cursor)||(2==cursor)))
|
2005-06-04 10:19:45 +00:00
|
|
|
lcd_puts_style(0, 4, buf, STYLE_INVERT);
|
|
|
|
else
|
|
|
|
lcd_puts(0, 4, buf);
|
|
|
|
}
|
2006-02-08 13:08:55 +00:00
|
|
|
else if(global_settings.rec_source == SOURCE_LINE)
|
2005-06-04 10:19:45 +00:00
|
|
|
{
|
2006-02-08 13:08:55 +00:00
|
|
|
#ifdef HAVE_UDA1380
|
2003-02-14 03:31:45 +00:00
|
|
|
|
2006-02-08 13:08:55 +00:00
|
|
|
/*****************test info code***********************
|
|
|
|
snprintf(buf, 32, "AL:(3x) %d DigL:(0.5x) %d",
|
|
|
|
global_settings.rec_left_gain,
|
|
|
|
global_settings.rec_linein_decimator_left_gain);
|
|
|
|
lcd_puts(0, 10, buf);
|
|
|
|
snprintf(buf, 32, "AR:(3x) %d DigR:(0.5x) %d",
|
|
|
|
global_settings.rec_right_gain,
|
|
|
|
global_settings.rec_linein_decimator_right_gain);
|
|
|
|
lcd_puts(0, 12, buf);
|
|
|
|
*****************test info code***********************/
|
|
|
|
|
|
|
|
snprintf(buf, 32, "%s:%s (%s)",
|
|
|
|
str(LANG_RECORDING_LEFT),
|
|
|
|
fmt_gain2(SOUND_LEFT_GAIN,
|
|
|
|
global_settings.rec_left_gain,
|
|
|
|
SOUND_DECIMATOR_LEFT_GAIN,
|
|
|
|
global_settings.rec_linein_decimator_left_gain,
|
|
|
|
buf2, sizeof(buf2)),
|
|
|
|
(((global_settings.rec_left_gain ==
|
|
|
|
sound_max(SOUND_LEFT_GAIN)) &&
|
|
|
|
(global_settings.rec_linein_decimator_left_gain
|
|
|
|
> 0)) ||
|
|
|
|
((global_settings.rec_left_gain ==
|
|
|
|
sound_min(SOUND_LEFT_GAIN)) &&
|
|
|
|
(global_settings.rec_linein_decimator_left_gain
|
|
|
|
< 0))) ?
|
|
|
|
str(LANG_RECORDING_GAIN_DIGITAL) :
|
|
|
|
str(LANG_RECORDING_GAIN_ANALOG)
|
|
|
|
);
|
|
|
|
#else /* HAVE_UDA1380 */
|
|
|
|
snprintf(buf, 32, "%s:%s",
|
|
|
|
str(LANG_RECORDING_LEFT),
|
|
|
|
fmt_gain(SOUND_LEFT_GAIN,
|
|
|
|
global_settings.rec_left_gain,
|
|
|
|
buf2, sizeof(buf2)));
|
|
|
|
#endif /* HAVE_UDA1380 */
|
|
|
|
if(global_settings.invert_cursor && ((1==cursor)||(2==cursor)))
|
|
|
|
lcd_puts_style(0, 4, buf, STYLE_INVERT);
|
|
|
|
else
|
|
|
|
lcd_puts(0, 4, buf);
|
|
|
|
#ifdef HAVE_UDA1380
|
|
|
|
snprintf(buf, 32, "%s:%s (%s)",
|
|
|
|
str(LANG_RECORDING_RIGHT),
|
|
|
|
fmt_gain2(SOUND_RIGHT_GAIN,
|
|
|
|
global_settings.rec_right_gain,
|
|
|
|
SOUND_DECIMATOR_RIGHT_GAIN,
|
|
|
|
global_settings.rec_linein_decimator_right_gain,
|
|
|
|
buf2, sizeof(buf2)),
|
|
|
|
(((global_settings.rec_right_gain ==
|
|
|
|
sound_max(SOUND_RIGHT_GAIN)) &&
|
|
|
|
(global_settings.rec_linein_decimator_right_gain
|
|
|
|
> 0)) ||
|
|
|
|
((global_settings.rec_right_gain ==
|
|
|
|
sound_min(SOUND_RIGHT_GAIN)) &&
|
|
|
|
(global_settings.rec_linein_decimator_right_gain
|
|
|
|
< 0))) ?
|
|
|
|
str(LANG_RECORDING_GAIN_DIGITAL) :
|
|
|
|
str(LANG_RECORDING_GAIN_ANALOG)
|
|
|
|
);
|
|
|
|
#else /* HAVE_UDA1380 */
|
|
|
|
snprintf(buf, 32, "%s:%s",
|
|
|
|
str(LANG_RECORDING_RIGHT),
|
|
|
|
fmt_gain(SOUND_RIGHT_GAIN,
|
|
|
|
global_settings.rec_right_gain,
|
|
|
|
buf2, sizeof(buf2)));
|
|
|
|
#endif /* HAVE_UDA1380 */
|
|
|
|
if(global_settings.invert_cursor && ((1==cursor)||(3==cursor)))
|
|
|
|
lcd_puts_style(0, 5, buf, STYLE_INVERT);
|
|
|
|
else
|
|
|
|
lcd_puts(0, 5, buf);
|
|
|
|
}
|
|
|
|
switch(cursor)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
put_cursorxy(0, 4, true);
|
|
|
|
|
|
|
|
if(global_settings.rec_source != SOURCE_MIC)
|
|
|
|
put_cursorxy(0, 5, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
put_cursorxy(0, 4, true);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
put_cursorxy(0, 5, true);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
put_cursorxy(0, 0, true);
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
2005-04-04 09:12:12 +00:00
|
|
|
|
2006-02-08 13:08:55 +00:00
|
|
|
snprintf(buf, 32, "%s %s",
|
|
|
|
freq_str[global_settings.rec_frequency],
|
|
|
|
global_settings.rec_channels?
|
|
|
|
str(LANG_CHANNEL_MONO):str(LANG_CHANNEL_STEREO));
|
|
|
|
lcd_puts(0, 7, buf);
|
|
|
|
|
2005-11-20 01:02:14 +00:00
|
|
|
gui_syncstatusbar_draw(&statusbars, true);
|
2005-06-04 10:19:45 +00:00
|
|
|
peak_meter_draw(0, 8 + h*2, LCD_WIDTH, h);
|
|
|
|
|
|
|
|
lcd_update();
|
|
|
|
|
2005-04-04 09:12:12 +00:00
|
|
|
/* draw the trigger status */
|
|
|
|
if (peak_meter_trigger_status() != TRIG_OFF)
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
2005-04-04 09:12:12 +00:00
|
|
|
peak_meter_draw_trig(LCD_WIDTH - TRIG_WIDTH, 4 * h);
|
|
|
|
lcd_update_rect(LCD_WIDTH - (TRIG_WIDTH + 2), 4 * h,
|
|
|
|
TRIG_WIDTH + 2, TRIG_HEIGHT);
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
}
|
2003-06-19 12:08:22 +00:00
|
|
|
|
2005-04-04 12:06:29 +00:00
|
|
|
if(audio_stat & AUDIO_STATUS_ERROR)
|
2003-06-19 12:08:22 +00:00
|
|
|
{
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
}
|
2004-11-08 13:20:43 +00:00
|
|
|
|
2005-11-12 04:00:56 +00:00
|
|
|
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
audio_stat = pcm_rec_status();
|
|
|
|
#else
|
|
|
|
audio_stat = audio_status();
|
|
|
|
#endif
|
|
|
|
if (audio_stat & AUDIO_STATUS_ERROR)
|
2003-06-19 12:08:22 +00:00
|
|
|
{
|
2005-11-16 15:12:15 +00:00
|
|
|
gui_syncsplash(0, true, str(LANG_DISK_FULL));
|
2005-11-20 01:02:14 +00:00
|
|
|
gui_syncstatusbar_draw(&statusbars, true);
|
2003-06-19 12:08:22 +00:00
|
|
|
lcd_update();
|
2005-04-04 12:06:29 +00:00
|
|
|
audio_error_clear();
|
2003-06-19 12:08:22 +00:00
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
button = button_get(true);
|
2004-10-09 11:39:30 +00:00
|
|
|
if(button == (REC_STOPEXIT | BUTTON_REL))
|
2003-06-19 12:08:22 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
|
2005-11-12 04:00:56 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
audio_stop_recording();
|
|
|
|
audio_close_recording();
|
2005-12-02 01:04:03 +00:00
|
|
|
cpu_boost(false);
|
2005-11-12 04:00:56 +00:00
|
|
|
#else
|
2005-04-04 12:06:29 +00:00
|
|
|
audio_init_playback();
|
2005-11-12 04:00:56 +00:00
|
|
|
#endif
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2005-04-04 09:12:12 +00:00
|
|
|
/* make sure the trigger is really turned off */
|
|
|
|
peak_meter_trigger(false);
|
|
|
|
peak_meter_set_trigger_listener(NULL);
|
|
|
|
|
2004-07-06 12:17:14 +00:00
|
|
|
sound_settings_apply();
|
2003-11-20 00:33:43 +00:00
|
|
|
|
2003-01-15 13:57:10 +00:00
|
|
|
lcd_setfont(FONT_UI);
|
2004-01-21 14:58:40 +00:00
|
|
|
|
|
|
|
if (have_recorded)
|
|
|
|
reload_directory();
|
|
|
|
|
2005-06-04 23:15:52 +00:00
|
|
|
#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
|
2005-04-04 09:12:12 +00:00
|
|
|
ata_set_led_enabled(true);
|
|
|
|
#endif
|
2004-01-21 14:58:40 +00:00
|
|
|
return been_in_usb_mode;
|
2004-10-09 11:39:30 +00:00
|
|
|
/*
|
|
|
|
#endif
|
|
|
|
*/
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
|
2004-10-09 11:39:30 +00:00
|
|
|
#ifdef REC_F2
|
2002-11-10 16:42:31 +00:00
|
|
|
bool f2_rec_screen(void)
|
|
|
|
{
|
|
|
|
bool exit = false;
|
|
|
|
bool used = false;
|
|
|
|
int w, h;
|
|
|
|
char buf[32];
|
2004-07-26 16:06:59 +00:00
|
|
|
int button;
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
|
|
|
lcd_getstringsize("A",&w,&h);
|
|
|
|
|
|
|
|
while (!exit) {
|
2004-08-01 23:34:44 +00:00
|
|
|
const char* ptr=NULL;
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
|
|
|
/* Recording quality */
|
|
|
|
lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_RECORDING_QUALITY));
|
2002-11-10 23:18:33 +00:00
|
|
|
snprintf(buf, 32, "%d", global_settings.rec_quality);
|
2002-11-10 16:42:31 +00:00
|
|
|
lcd_putsxy(0, LCD_HEIGHT/2-h, buf);
|
2005-07-06 22:58:02 +00:00
|
|
|
lcd_mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
|
|
|
|
LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
/* Frequency */
|
|
|
|
snprintf(buf, sizeof buf, "%s:", str(LANG_RECORDING_FREQUENCY));
|
|
|
|
lcd_getstringsize(buf,&w,&h);
|
|
|
|
lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf);
|
2002-11-10 23:18:33 +00:00
|
|
|
ptr = freq_str[global_settings.rec_frequency];
|
2002-11-10 16:42:31 +00:00
|
|
|
lcd_getstringsize(ptr, &w, &h);
|
|
|
|
lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr);
|
2005-07-06 22:58:02 +00:00
|
|
|
lcd_mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
|
|
|
|
LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
/* Channel mode */
|
2002-11-10 23:18:33 +00:00
|
|
|
switch ( global_settings.rec_channels ) {
|
2002-11-10 16:42:31 +00:00
|
|
|
case 0:
|
|
|
|
ptr = str(LANG_CHANNEL_STEREO);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
ptr = str(LANG_CHANNEL_MONO);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-11-10 23:18:33 +00:00
|
|
|
lcd_getstringsize(str(LANG_RECORDING_CHANNELS), &w, &h);
|
2002-11-10 16:42:31 +00:00
|
|
|
lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2,
|
2002-11-10 23:18:33 +00:00
|
|
|
str(LANG_RECORDING_CHANNELS));
|
2002-11-10 16:42:31 +00:00
|
|
|
lcd_getstringsize(str(LANG_F2_MODE), &w, &h);
|
|
|
|
lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F2_MODE));
|
|
|
|
lcd_getstringsize(ptr, &w, &h);
|
|
|
|
lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr);
|
2005-07-06 22:58:02 +00:00
|
|
|
lcd_mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
|
|
|
|
LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
lcd_update();
|
|
|
|
|
2004-07-26 16:06:59 +00:00
|
|
|
button = button_get(true);
|
|
|
|
switch (button) {
|
2002-11-10 16:42:31 +00:00
|
|
|
case BUTTON_LEFT:
|
|
|
|
case BUTTON_F2 | BUTTON_LEFT:
|
2002-11-10 23:18:33 +00:00
|
|
|
global_settings.rec_quality++;
|
|
|
|
if(global_settings.rec_quality > 7)
|
|
|
|
global_settings.rec_quality = 0;
|
2002-11-10 16:42:31 +00:00
|
|
|
used = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BUTTON_DOWN:
|
|
|
|
case BUTTON_F2 | BUTTON_DOWN:
|
2002-11-10 23:18:33 +00:00
|
|
|
global_settings.rec_frequency++;
|
|
|
|
if(global_settings.rec_frequency > 5)
|
|
|
|
global_settings.rec_frequency = 0;
|
2002-11-10 16:42:31 +00:00
|
|
|
used = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BUTTON_RIGHT:
|
|
|
|
case BUTTON_F2 | BUTTON_RIGHT:
|
2002-11-10 23:18:33 +00:00
|
|
|
global_settings.rec_channels++;
|
|
|
|
if(global_settings.rec_channels > 1)
|
|
|
|
global_settings.rec_channels = 0;
|
2002-11-10 16:42:31 +00:00
|
|
|
used = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BUTTON_F2 | BUTTON_REL:
|
|
|
|
if ( used )
|
|
|
|
exit = true;
|
|
|
|
used = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BUTTON_F2 | BUTTON_REPEAT:
|
|
|
|
used = true;
|
|
|
|
break;
|
|
|
|
|
2004-07-26 16:06:59 +00:00
|
|
|
default:
|
|
|
|
if(default_event_handler(button) == SYS_USB_CONNECTED)
|
|
|
|
return true;
|
|
|
|
break;
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-19 22:15:53 +00:00
|
|
|
if (global_settings.rec_prerecord_time)
|
|
|
|
talk_buffer_steal(); /* will use the mp3 buffer */
|
|
|
|
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_set_recording_options(global_settings.rec_frequency,
|
2002-11-10 23:18:33 +00:00
|
|
|
global_settings.rec_quality,
|
|
|
|
global_settings.rec_source,
|
2003-04-20 22:00:30 +00:00
|
|
|
global_settings.rec_channels,
|
2003-12-31 03:13:29 +00:00
|
|
|
global_settings.rec_editable,
|
2005-11-12 14:49:43 +00:00
|
|
|
global_settings.rec_prerecord_time);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2002-11-10 23:18:33 +00:00
|
|
|
set_gain();
|
|
|
|
|
|
|
|
settings_save();
|
2002-11-10 16:42:31 +00:00
|
|
|
lcd_setfont(FONT_UI);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2004-10-09 11:39:30 +00:00
|
|
|
#endif /* #ifdef REC_F2 */
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2004-10-09 11:39:30 +00:00
|
|
|
#ifdef REC_F3
|
2002-11-10 16:42:31 +00:00
|
|
|
bool f3_rec_screen(void)
|
|
|
|
{
|
|
|
|
bool exit = false;
|
|
|
|
bool used = false;
|
|
|
|
int w, h;
|
2004-07-26 16:06:59 +00:00
|
|
|
int button;
|
2002-11-10 23:18:33 +00:00
|
|
|
char *src_str[] =
|
|
|
|
{
|
|
|
|
str(LANG_RECORDING_SRC_MIC),
|
|
|
|
str(LANG_RECORDING_SRC_LINE),
|
|
|
|
str(LANG_RECORDING_SRC_DIGITAL)
|
|
|
|
};
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
|
|
|
lcd_getstringsize("A",&w,&h);
|
|
|
|
|
|
|
|
while (!exit) {
|
|
|
|
char* ptr=NULL;
|
|
|
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
|
|
|
/* Recording source */
|
|
|
|
lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_RECORDING_SOURCE));
|
2002-11-10 23:18:33 +00:00
|
|
|
ptr = src_str[global_settings.rec_source];
|
2002-11-10 16:42:31 +00:00
|
|
|
lcd_getstringsize(ptr, &w, &h);
|
|
|
|
lcd_putsxy(0, LCD_HEIGHT/2-h, ptr);
|
2005-07-06 22:58:02 +00:00
|
|
|
lcd_mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
|
|
|
|
LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2005-04-04 09:12:12 +00:00
|
|
|
/* trigger setup */
|
|
|
|
ptr = str(LANG_RECORD_TRIGGER);
|
|
|
|
lcd_getstringsize(ptr,&w,&h);
|
|
|
|
lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, ptr);
|
2005-07-06 22:58:02 +00:00
|
|
|
lcd_mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
|
|
|
|
LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
|
2005-04-04 09:12:12 +00:00
|
|
|
|
2002-11-10 16:42:31 +00:00
|
|
|
lcd_update();
|
|
|
|
|
2004-07-26 16:06:59 +00:00
|
|
|
button = button_get(true);
|
|
|
|
switch (button) {
|
2005-04-04 09:12:12 +00:00
|
|
|
case BUTTON_DOWN:
|
|
|
|
case BUTTON_F3 | BUTTON_DOWN:
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
rectrigger();
|
|
|
|
settings_apply_trigger();
|
|
|
|
#endif
|
|
|
|
exit = true;
|
|
|
|
break;
|
|
|
|
|
2002-11-10 16:42:31 +00:00
|
|
|
case BUTTON_LEFT:
|
|
|
|
case BUTTON_F3 | BUTTON_LEFT:
|
2002-11-10 23:18:33 +00:00
|
|
|
global_settings.rec_source++;
|
2005-09-06 20:48:28 +00:00
|
|
|
if(global_settings.rec_source > MAX_SOURCE)
|
2002-11-10 23:18:33 +00:00
|
|
|
global_settings.rec_source = 0;
|
2002-11-10 16:42:31 +00:00
|
|
|
used = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BUTTON_F3 | BUTTON_REL:
|
|
|
|
if ( used )
|
|
|
|
exit = true;
|
|
|
|
used = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BUTTON_F3 | BUTTON_REPEAT:
|
|
|
|
used = true;
|
|
|
|
break;
|
|
|
|
|
2004-07-26 16:06:59 +00:00
|
|
|
default:
|
|
|
|
if(default_event_handler(button) == SYS_USB_CONNECTED)
|
|
|
|
return true;
|
|
|
|
break;
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-19 22:15:53 +00:00
|
|
|
if (global_settings.rec_prerecord_time)
|
|
|
|
talk_buffer_steal(); /* will use the mp3 buffer */
|
|
|
|
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_set_recording_options(global_settings.rec_frequency,
|
2002-11-10 23:18:33 +00:00
|
|
|
global_settings.rec_quality,
|
|
|
|
global_settings.rec_source,
|
2003-04-20 22:00:30 +00:00
|
|
|
global_settings.rec_channels,
|
2003-12-31 03:13:29 +00:00
|
|
|
global_settings.rec_editable,
|
2005-11-12 14:49:43 +00:00
|
|
|
global_settings.rec_prerecord_time);
|
2005-11-12 04:00:56 +00:00
|
|
|
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2002-11-10 23:18:33 +00:00
|
|
|
set_gain();
|
2003-12-31 03:13:29 +00:00
|
|
|
|
2002-11-10 23:18:33 +00:00
|
|
|
settings_save();
|
2002-11-10 16:42:31 +00:00
|
|
|
lcd_setfont(FONT_UI);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2004-10-09 11:39:30 +00:00
|
|
|
#endif /* #ifdef REC_F3 */
|
|
|
|
|
2005-11-12 04:00:56 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
void audio_beep(int duration)
|
|
|
|
{
|
|
|
|
/* dummy */
|
|
|
|
(void)duration;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2004-09-29 19:51:41 +00:00
|
|
|
#endif /* HAVE_RECORDING */
|