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"
|
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"
|
|
|
|
#include "status.h"
|
|
|
|
#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"
|
2002-11-10 16:42:31 +00:00
|
|
|
|
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
|
|
|
|
#elif CONFIG_KEYPAD == ONDIO_PAD /* only limited features */
|
|
|
|
#define REC_STOPEXIT BUTTON_OFF
|
|
|
|
#define REC_RECPAUSE BUTTON_RIGHT
|
|
|
|
#define REC_INC BUTTON_UP
|
|
|
|
#define REC_DEC BUTTON_DOWN
|
|
|
|
#define REC_NEXT (BUTTON_MENU | BUTTON_REL)
|
|
|
|
#define REC_SETTINGS (BUTTON_MENU | BUTTON_REPEAT)
|
2005-02-02 21:48:47 +00:00
|
|
|
#elif CONFIG_KEYPAD == IRIVER_H100_PAD
|
|
|
|
#define REC_STOPEXIT BUTTON_OFF
|
|
|
|
#define REC_RECPAUSE BUTTON_ON
|
2005-02-08 15:38:01 +00:00
|
|
|
#define REC_INC BUTTON_RIGHT
|
|
|
|
#define REC_DEC BUTTON_LEFT
|
|
|
|
#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);
|
|
|
|
|
|
|
|
#define SOURCE_MIC 0
|
|
|
|
#define SOURCE_LINE 1
|
|
|
|
#define SOURCE_SPDIF 2
|
|
|
|
|
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
|
|
|
{
|
2003-07-22 18:34:23 +00:00
|
|
|
mpeg_set_recording_gain(global_settings.rec_mic_gain, 0, true);
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-11-10 23:18:33 +00:00
|
|
|
mpeg_set_recording_gain(global_settings.rec_left_gain,
|
2003-07-22 18:34:23 +00:00
|
|
|
global_settings.rec_right_gain, false);
|
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
|
|
|
{
|
|
|
|
"", /* no decimals */
|
|
|
|
"%d.%d %s ", /* 1 decimal */
|
|
|
|
"%d.%02d %s " /* 2 decimals */
|
|
|
|
};
|
|
|
|
|
|
|
|
char *fmt_gain(int snd, int val, char *str, int len)
|
|
|
|
{
|
|
|
|
int tmp, i, d, numdec;
|
2004-07-20 22:13:24 +00:00
|
|
|
const char *unit;
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2005-04-01 13:41:03 +00:00
|
|
|
tmp = sound_val2phys(snd, val);
|
|
|
|
numdec = sound_numdecimals(snd);
|
|
|
|
unit = sound_unit(snd);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
i = tmp / (10*numdec);
|
2003-09-19 23:46:57 +00:00
|
|
|
d = abs(tmp % (10*numdec));
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
snprintf(str, len, fmtstr[numdec], i, d, unit);
|
|
|
|
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)
|
|
|
|
{
|
2002-11-10 23:18:33 +00:00
|
|
|
if(global_settings.rec_source == SOURCE_LINE)
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
|
|
|
if(cursor < 0)
|
|
|
|
cursor = 0;
|
|
|
|
|
|
|
|
if(cursor > 2)
|
2004-10-09 12:00:53 +00:00
|
|
|
#ifdef REC_PREV /* normal case, stop at the end */
|
2002-11-10 16:42:31 +00:00
|
|
|
cursor = 2;
|
2004-10-09 12:00:53 +00:00
|
|
|
#else
|
|
|
|
cursor = 0; /* only 1 button, cycle through */
|
|
|
|
#endif
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cursor = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
int fpos;
|
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
|
|
|
|
2004-01-21 14:58:40 +00:00
|
|
|
fpos = strlen(buffer);
|
2004-10-17 10:00:46 +00:00
|
|
|
#ifdef HAVE_RTC
|
|
|
|
{
|
|
|
|
struct tm *tm = get_time();
|
|
|
|
|
|
|
|
/* Append filename to path: RYYMMDD-HH.MM.SS.mp3 */
|
|
|
|
snprintf(&buffer[fpos], MAX_PATH-fpos,
|
|
|
|
"/R%02d%02d%02d-%02d%02d%02d.mp3",
|
|
|
|
tm->tm_year%100, tm->tm_mon+1, tm->tm_mday,
|
|
|
|
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
{
|
|
|
|
DIR* dir;
|
|
|
|
int max_rec_file = 1; /* default to rec_0001.mp3 */
|
|
|
|
dir = opendir(buffer);
|
|
|
|
if (dir) /* found */
|
|
|
|
{
|
|
|
|
/* Search for the highest recording filename present,
|
|
|
|
increment behind that. So even with "holes"
|
|
|
|
(deleted recordings), the newest will always have the
|
|
|
|
highest number. */
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
struct dirent* entry;
|
|
|
|
int curr_rec_file;
|
|
|
|
/* walk through the directory content */
|
|
|
|
entry = readdir(dir);
|
|
|
|
if (!entry)
|
2005-01-13 23:40:00 +00:00
|
|
|
{
|
|
|
|
closedir(dir);
|
2004-10-17 10:00:46 +00:00
|
|
|
break; /* end of dir */
|
2005-01-13 23:40:00 +00:00
|
|
|
}
|
2004-10-17 10:00:46 +00:00
|
|
|
if (strncasecmp(entry->d_name, "rec_", 4))
|
|
|
|
continue; /* no recording file */
|
|
|
|
curr_rec_file = atoi(&entry->d_name[4]);
|
|
|
|
if (curr_rec_file >= max_rec_file)
|
|
|
|
max_rec_file = curr_rec_file + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
snprintf(&buffer[fpos], MAX_PATH-fpos,
|
|
|
|
"/rec_%04d.mp3", max_rec_file);
|
|
|
|
}
|
|
|
|
#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)
|
|
|
|
{
|
|
|
|
splash(HZ * 2, true,
|
|
|
|
"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 */
|
|
|
|
mpeg_record(rec_create_filename(path_buffer));
|
|
|
|
|
|
|
|
/* give control to mpeg thread so that it can start recording */
|
|
|
|
yield(); yield(); yield();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we're already recording this is a retrigger */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mpeg_new_file(rec_create_filename(path_buffer));
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-10 16:42:31 +00:00
|
|
|
bool recording_screen(void)
|
|
|
|
{
|
2005-02-16 11:04:35 +00:00
|
|
|
long button;
|
2002-11-10 16:42:31 +00:00
|
|
|
bool done = false;
|
|
|
|
char buf[32];
|
|
|
|
char buf2[32];
|
|
|
|
int gain;
|
|
|
|
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-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
|
|
|
|
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
|
2002-11-10 16:42:31 +00:00
|
|
|
mpeg_init_recording();
|
2002-11-24 00:23:49 +00:00
|
|
|
|
2005-04-01 13:41:03 +00:00
|
|
|
sound_set(SOUND_VOLUME, global_settings.volume);
|
2002-11-24 00:23:49 +00:00
|
|
|
|
2003-03-25 02:13:54 +00:00
|
|
|
/* Yes, we use the D/A for monitoring */
|
|
|
|
peak_meter_playback(true);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
peak_meter_enabled = true;
|
|
|
|
|
2004-03-19 22:15:53 +00:00
|
|
|
if (global_settings.rec_prerecord_time)
|
|
|
|
talk_buffer_steal(); /* will use the mp3 buffer */
|
|
|
|
|
2002-11-10 23:18:33 +00:00
|
|
|
mpeg_set_recording_options(global_settings.rec_frequency,
|
|
|
|
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,
|
|
|
|
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);
|
2003-04-24 12:57:15 +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-04-04 12:06:29 +00:00
|
|
|
int audio_stat = audio_status();
|
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-04-04 12:06:29 +00:00
|
|
|
audio_stop();
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
peak_meter_playback(true);
|
|
|
|
peak_meter_enabled = false;
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
update_countdown = 1; /* Update immediately */
|
|
|
|
break;
|
|
|
|
|
2004-10-09 11:39:30 +00:00
|
|
|
case REC_RECPAUSE:
|
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 */
|
|
|
|
mpeg_record(rec_create_filename(path_buffer));
|
|
|
|
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
|
|
|
{
|
2004-12-24 08:42:45 +00:00
|
|
|
mpeg_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
|
|
|
|
{
|
|
|
|
mpeg_pause_recording();
|
|
|
|
}
|
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
|
2002-11-10 16:42:31 +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:
|
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
|
|
|
|
{
|
2002-11-10 23:18:33 +00:00
|
|
|
gain = MAX(global_settings.rec_left_gain,
|
2005-06-04 10:19:45 +00:00
|
|
|
global_settings.rec_right_gain);
|
|
|
|
if(gain < sound_max(SOUND_LEFT_GAIN))
|
|
|
|
gain++;
|
2002-11-10 23:18:33 +00:00
|
|
|
global_settings.rec_left_gain = gain;
|
|
|
|
global_settings.rec_right_gain = gain;
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
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;
|
|
|
|
case 2:
|
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;
|
|
|
|
}
|
|
|
|
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:
|
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
|
|
|
|
{
|
2002-11-10 23:18:33 +00:00
|
|
|
gain = MAX(global_settings.rec_left_gain,
|
2005-06-04 10:19:45 +00:00
|
|
|
global_settings.rec_right_gain);
|
|
|
|
if(gain > sound_min(SOUND_LEFT_GAIN))
|
|
|
|
gain--;
|
2002-11-10 23:18:33 +00:00
|
|
|
global_settings.rec_left_gain = gain;
|
|
|
|
global_settings.rec_right_gain = gain;
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
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;
|
|
|
|
case 2:
|
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;
|
|
|
|
}
|
|
|
|
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 */
|
|
|
|
|
|
|
|
mpeg_set_recording_options(global_settings.rec_frequency,
|
|
|
|
global_settings.rec_quality,
|
|
|
|
global_settings.rec_source,
|
|
|
|
global_settings.rec_channels,
|
|
|
|
global_settings.rec_editable,
|
|
|
|
global_settings.rec_prerecord_time);
|
2002-11-11 08:16:18 +00:00
|
|
|
|
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);
|
|
|
|
lcd_setmargins(global_settings.invert_cursor ? 0 : w, 8);
|
|
|
|
}
|
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
|
|
|
{
|
2004-06-03 12:10:40 +00:00
|
|
|
mpeg_new_file(rec_create_filename(path_buffer));
|
|
|
|
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-06-04 10:19:45 +00:00
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
seconds = mpeg_recorded_time() / HZ;
|
|
|
|
|
|
|
|
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-06-04 12:14:46 +00:00
|
|
|
num_recorded_bytes = mpeg_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-06-04 10:19:45 +00:00
|
|
|
/* We will do file splitting regardless, since the OFF
|
|
|
|
setting really means 24 hours. This is to make sure
|
|
|
|
that the recorded files don't get too big. */
|
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
|
|
|
{
|
|
|
|
mpeg_new_file(rec_create_filename(path_buffer));
|
|
|
|
update_countdown = 1;
|
|
|
|
last_seconds = 0;
|
|
|
|
}
|
2003-11-20 00:33:43 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
/* Show mic gain if input source is Mic */
|
|
|
|
if(global_settings.rec_source == 0)
|
|
|
|
{
|
|
|
|
snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_GAIN),
|
|
|
|
fmt_gain(SOUND_MIC_GAIN,
|
|
|
|
global_settings.rec_mic_gain,
|
|
|
|
buf2, sizeof(buf2)));
|
|
|
|
if (global_settings.invert_cursor && (pos++ == cursor))
|
|
|
|
lcd_puts_style(0, 4, buf, STYLE_INVERT);
|
|
|
|
else
|
|
|
|
lcd_puts(0, 4, buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(global_settings.rec_source == SOURCE_LINE)
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
2005-06-04 10:19:45 +00:00
|
|
|
gain = MAX(global_settings.rec_left_gain,
|
|
|
|
global_settings.rec_right_gain);
|
|
|
|
|
2002-11-10 16:42:31 +00:00
|
|
|
snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_GAIN),
|
2005-06-04 10:19:45 +00:00
|
|
|
fmt_gain(SOUND_LEFT_GAIN, gain,
|
2002-11-10 16:42:31 +00:00
|
|
|
buf2, sizeof(buf2)));
|
2003-04-24 12:57:15 +00:00
|
|
|
if (global_settings.invert_cursor && (pos++ == cursor))
|
2005-04-04 09:12:12 +00:00
|
|
|
lcd_puts_style(0, 4, buf, STYLE_INVERT);
|
2003-04-24 12:57:15 +00:00
|
|
|
else
|
2005-04-04 09:12:12 +00:00
|
|
|
lcd_puts(0, 4, buf);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_LEFT),
|
|
|
|
fmt_gain(SOUND_LEFT_GAIN,
|
|
|
|
global_settings.rec_left_gain,
|
|
|
|
buf2, sizeof(buf2)));
|
|
|
|
if (global_settings.invert_cursor && (pos++ == cursor))
|
|
|
|
lcd_puts_style(0, 5, buf, STYLE_INVERT);
|
|
|
|
else
|
|
|
|
lcd_puts(0, 5, buf);
|
2005-04-04 09:12:12 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
snprintf(buf, 32, "%s: %s", str(LANG_RECORDING_RIGHT),
|
|
|
|
fmt_gain(SOUND_RIGHT_GAIN,
|
|
|
|
global_settings.rec_right_gain,
|
|
|
|
buf2, sizeof(buf2)));
|
|
|
|
if (global_settings.invert_cursor && (pos++ == cursor))
|
|
|
|
lcd_puts_style(0, 6, buf, STYLE_INVERT);
|
|
|
|
else
|
|
|
|
lcd_puts(0, 6, buf);
|
2005-04-04 09:12:12 +00:00
|
|
|
}
|
2005-06-04 10:19:45 +00:00
|
|
|
}
|
2003-02-14 03:31:45 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
if(global_settings.rec_source != SOURCE_SPDIF)
|
|
|
|
put_cursorxy(0, 4 + cursor, true);
|
2003-02-14 03:31:45 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
if (global_settings.rec_source != SOURCE_LINE) {
|
|
|
|
snprintf(buf, 32, "%s %s [%d]",
|
|
|
|
freq_str[global_settings.rec_frequency],
|
|
|
|
global_settings.rec_channels?
|
|
|
|
str(LANG_CHANNEL_MONO):str(LANG_CHANNEL_STEREO),
|
|
|
|
global_settings.rec_quality);
|
|
|
|
lcd_puts(0, 6, buf);
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
2005-04-04 09:12:12 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
status_draw(true);
|
|
|
|
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-04-04 12:06:29 +00:00
|
|
|
if(audio_status() & AUDIO_STATUS_ERROR)
|
2003-06-19 12:08:22 +00:00
|
|
|
{
|
2004-01-08 09:58:58 +00:00
|
|
|
splash(0, true, str(LANG_DISK_FULL));
|
2003-06-19 12:08:22 +00:00
|
|
|
status_draw(true);
|
|
|
|
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-04-04 12:06:29 +00:00
|
|
|
audio_init_playback();
|
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);
|
|
|
|
lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
|
|
|
|
LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
|
|
|
|
LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
lcd_bitmap(bitmap_icons_7x8[Icon_FastForward],
|
|
|
|
LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8, true);
|
|
|
|
|
|
|
|
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 */
|
|
|
|
|
2002-11-10 23:18:33 +00:00
|
|
|
mpeg_set_recording_options(global_settings.rec_frequency,
|
|
|
|
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,
|
|
|
|
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);
|
|
|
|
lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
|
|
|
|
LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
|
|
|
|
|
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);
|
|
|
|
lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
|
|
|
|
LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
|
|
|
|
|
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++;
|
|
|
|
if(global_settings.rec_source > 2)
|
|
|
|
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 */
|
|
|
|
|
2002-11-10 23:18:33 +00:00
|
|
|
mpeg_set_recording_options(global_settings.rec_frequency,
|
|
|
|
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,
|
|
|
|
global_settings.rec_prerecord_time);
|
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 */
|
|
|
|
|
2004-09-29 19:51:41 +00:00
|
|
|
#endif /* HAVE_RECORDING */
|