2002-11-10 16:42:31 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-11-10 16:42:31 +00:00
|
|
|
*
|
|
|
|
* 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"
|
2006-08-28 22:38:41 +00:00
|
|
|
#include "power.h"
|
2008-05-15 22:47:07 +00:00
|
|
|
#include "powermgmt.h"
|
2002-11-10 16:42:31 +00:00
|
|
|
#include "lcd.h"
|
2004-06-22 10:52:39 +00:00
|
|
|
#include "led.h"
|
2005-04-04 12:06:29 +00:00
|
|
|
#include "audio.h"
|
2005-11-12 04:00:56 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2006-11-06 18:07:30 +00:00
|
|
|
#include "thread.h"
|
|
|
|
#include "enc_config.h"
|
2010-05-26 04:59:39 +00:00
|
|
|
#include "playback.h"
|
2006-11-13 23:21:54 +00:00
|
|
|
#if defined(HAVE_SPDIF_IN) || defined(HAVE_SPDIF_OUT)
|
|
|
|
#include "spdif.h"
|
2005-11-12 04:00:56 +00:00
|
|
|
#endif
|
2006-11-13 23:21:54 +00:00
|
|
|
#endif /* CONFIG_CODEC == SWCODEC */
|
2008-10-14 11:12:20 +00:00
|
|
|
#include "pcm_record.h"
|
2006-08-28 22:38:41 +00:00
|
|
|
#include "recording.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"
|
2006-03-25 13:35:31 +00:00
|
|
|
#include "icon.h"
|
2002-11-10 16:42:31 +00:00
|
|
|
#include "screens.h"
|
|
|
|
#include "peakmeter.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"
|
2005-04-01 13:41:03 +00:00
|
|
|
#include "sound.h"
|
2008-11-01 16:14:28 +00:00
|
|
|
#include "storage.h"
|
2008-11-04 19:57:36 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_ATA) && (CONFIG_LED == LED_REAL) \
|
|
|
|
&& !defined(SIMULATOR)
|
|
|
|
#include "ata.h"
|
|
|
|
#endif
|
2005-11-16 15:12:15 +00:00
|
|
|
#include "splash.h"
|
2006-03-25 13:35:31 +00:00
|
|
|
#include "screen_access.h"
|
2006-08-20 21:33:40 +00:00
|
|
|
#include "action.h"
|
2006-08-28 22:38:41 +00:00
|
|
|
#include "radio.h"
|
2008-06-23 13:20:35 +00:00
|
|
|
#include "viewport.h"
|
2008-08-06 20:12:44 +00:00
|
|
|
#include "list.h"
|
2009-02-10 23:43:37 +00:00
|
|
|
#include "general.h"
|
2009-08-16 22:20:11 +00:00
|
|
|
#include "appevents.h"
|
2008-05-03 08:35:14 +00:00
|
|
|
|
2004-09-29 19:51:41 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
2007-07-11 05:41:23 +00:00
|
|
|
/* This array holds the record timer interval lengths, in seconds */
|
|
|
|
static const unsigned long rec_timer_seconds[] =
|
|
|
|
{
|
|
|
|
0, /* 0 means OFF */
|
|
|
|
5*60, /* 00:05 */
|
|
|
|
10*60, /* 00:10 */
|
|
|
|
15*60, /* 00:15 */
|
|
|
|
30*60, /* 00:30 */
|
|
|
|
60*60, /* 01:00 */
|
2009-06-23 21:22:06 +00:00
|
|
|
74*60, /* 01:14 */
|
|
|
|
80*60, /* 01:20 */
|
2007-07-11 05:41:23 +00:00
|
|
|
2*60*60, /* 02:00 */
|
|
|
|
4*60*60, /* 04:00 */
|
|
|
|
6*60*60, /* 06:00 */
|
|
|
|
8*60*60, /* 08:00 */
|
|
|
|
10L*60*60, /* 10:00 */
|
|
|
|
12L*60*60, /* 12:00 */
|
|
|
|
18L*60*60, /* 18:00 */
|
|
|
|
24L*60*60 /* 24:00 */
|
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned int rec_timesplit_seconds(void)
|
|
|
|
{
|
|
|
|
return rec_timer_seconds[global_settings.rec_timesplit];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This array holds the record size interval lengths, in bytes */
|
|
|
|
static const unsigned long rec_size_bytes[] =
|
|
|
|
{
|
|
|
|
0, /* 0 means OFF */
|
|
|
|
5*1024*1024, /* 5MB */
|
|
|
|
10*1024*1024, /* 10MB */
|
|
|
|
15*1024*1024, /* 15MB */
|
|
|
|
32*1024*1024, /* 32MB */
|
|
|
|
64*1024*1024, /* 64MB */
|
|
|
|
75*1024*1024, /* 75MB */
|
|
|
|
100*1024*1024, /* 100MB */
|
|
|
|
128*1024*1024, /* 128MB */
|
|
|
|
256*1024*1024, /* 256MB */
|
|
|
|
512*1024*1024, /* 512MB */
|
|
|
|
650*1024*1024, /* 650MB */
|
|
|
|
700*1024*1024, /* 700MB */
|
|
|
|
1024*1024*1024, /* 1GB */
|
|
|
|
1536*1024*1024, /* 1.5GB */
|
|
|
|
1792*1024*1024, /* 1.75GB */
|
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned long rec_sizesplit_bytes(void)
|
|
|
|
{
|
|
|
|
return rec_size_bytes[global_settings.rec_sizesplit];
|
|
|
|
}
|
|
|
|
|
|
|
|
void settings_apply_trigger(void)
|
|
|
|
{
|
2008-05-28 10:55:39 +00:00
|
|
|
int start_thres, stop_thres;
|
|
|
|
if (global_settings.peak_meter_dbfs)
|
|
|
|
{
|
|
|
|
start_thres = global_settings.rec_start_thres_db - 1;
|
|
|
|
stop_thres = global_settings.rec_stop_thres_db - 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
start_thres = global_settings.rec_start_thres_linear;
|
|
|
|
stop_thres = global_settings.rec_stop_thres_linear;
|
|
|
|
}
|
2004-09-29 19:51:41 +00:00
|
|
|
|
2007-07-11 05:41:23 +00:00
|
|
|
peak_meter_define_trigger(
|
2008-05-28 10:55:39 +00:00
|
|
|
start_thres,
|
|
|
|
global_settings.rec_start_duration*HZ,
|
|
|
|
MIN(global_settings.rec_start_duration*HZ / 2, 2*HZ),
|
|
|
|
stop_thres,
|
|
|
|
global_settings.rec_stop_postrec*HZ,
|
|
|
|
global_settings.rec_stop_gap*HZ
|
2007-07-11 05:41:23 +00:00
|
|
|
);
|
|
|
|
}
|
2007-06-22 09:34:57 +00:00
|
|
|
/* recording screen status flags */
|
|
|
|
enum rec_status_flags
|
|
|
|
{
|
|
|
|
RCSTAT_IN_RECSCREEN = 0x00000001,
|
|
|
|
RCSTAT_BEEN_IN_USB_MODE = 0x00000002,
|
|
|
|
RCSTAT_CREATED_DIRECTORY = 0x00000004,
|
|
|
|
RCSTAT_HAVE_RECORDED = 0x00000008,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int rec_status = 0;
|
|
|
|
|
2007-09-22 09:05:06 +00:00
|
|
|
bool in_recording_screen(void)
|
2007-12-07 00:28:16 +00:00
|
|
|
{
|
2007-06-22 09:34:57 +00:00
|
|
|
return (rec_status & RCSTAT_IN_RECSCREEN) != 0;
|
2007-12-07 00:28:16 +00:00
|
|
|
}
|
2007-02-08 10:36:49 +00:00
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool f2_rec_screen(void);
|
|
|
|
static bool f3_rec_screen(void);
|
2006-11-06 18:07:30 +00:00
|
|
|
#endif
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2006-06-30 21:24:20 +00:00
|
|
|
#define MAX_FILE_SIZE 0x7F800000 /* 2 GB - 4 MB */
|
2005-06-04 12:14:46 +00:00
|
|
|
|
2007-11-25 21:47:16 +00:00
|
|
|
#ifndef HAVE_REMOTE_LCD
|
|
|
|
static const int screen_update = NB_SCREENS;
|
|
|
|
#else
|
2006-12-25 14:01:47 +00:00
|
|
|
static int screen_update = NB_SCREENS;
|
|
|
|
static bool remote_display_on = true;
|
2007-02-06 20:30:58 +00:00
|
|
|
#endif
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
/* as we have the ability to disable the remote, we need an alternative loop */
|
|
|
|
#define FOR_NB_ACTIVE_SCREENS(i) for(i = 0; i < screen_update; i++)
|
|
|
|
|
|
|
|
static bool update_list = false; /* (GIU) list needs updating */
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
/** File name creation **/
|
2007-06-22 09:34:57 +00:00
|
|
|
#if CONFIG_RTC == 0
|
2006-11-06 18:07:30 +00:00
|
|
|
/* current file number to assist in creating unique numbered filenames
|
|
|
|
without actually having to create the file on disk */
|
|
|
|
static int file_number = -1;
|
2007-06-22 09:34:57 +00:00
|
|
|
#endif /* CONFIG_RTC */
|
|
|
|
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2006-11-06 18:07:30 +00:00
|
|
|
|
|
|
|
#define REC_FILE_ENDING(rec_format) \
|
|
|
|
(audio_formats[rec_format_afmt[rec_format]].ext_list)
|
|
|
|
|
|
|
|
#else /* CONFIG_CODEC != SWCODEC */
|
|
|
|
|
2006-08-28 22:38:41 +00:00
|
|
|
/* default record file extension for HWCODEC */
|
2006-11-06 18:07:30 +00:00
|
|
|
#define REC_FILE_ENDING(rec_format) \
|
|
|
|
(audio_formats[AFMT_MPA_L3].ext_list)
|
2006-08-28 22:38:41 +00:00
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
#endif /* CONFIG_CODEC == SWCODEC */
|
|
|
|
|
|
|
|
/* path for current file */
|
|
|
|
static char path_buffer[MAX_PATH];
|
|
|
|
|
|
|
|
/** Automatic Gain Control (AGC) **/
|
2006-08-16 23:26:55 +00:00
|
|
|
#ifdef HAVE_AGC
|
|
|
|
/* Timing counters:
|
|
|
|
* peak_time is incremented every 0.2s, every 2nd run of record screen loop.
|
|
|
|
* hist_time is incremented every 0.5s, display update.
|
|
|
|
* peak_time is the counter of the peak hold read and agc process,
|
|
|
|
* overflow every 13 years 8-)
|
|
|
|
*/
|
|
|
|
static long peak_time = 0;
|
|
|
|
|
|
|
|
static short peak_valid_mem[4];
|
|
|
|
#define BAL_MEM_SIZE 24
|
|
|
|
static short balance_mem[BAL_MEM_SIZE];
|
|
|
|
|
|
|
|
/* Automatic Gain Control */
|
|
|
|
#define AGC_MODE_SIZE 5
|
2006-10-01 10:04:40 +00:00
|
|
|
#define AGC_SAFETY_MODE 0
|
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static const char* agc_preset_str[] =
|
2006-08-16 23:26:55 +00:00
|
|
|
{ "Off", "S", "L", "D", "M", "V" };
|
|
|
|
/* "Off",
|
|
|
|
"Safety (clip)",
|
|
|
|
"Live (slow)",
|
|
|
|
"DJ-Set (slow)",
|
|
|
|
"Medium",
|
|
|
|
"Voice (fast)" */
|
|
|
|
#define AGC_CLIP 32766
|
|
|
|
#define AGC_PEAK 29883 /* fast gain reduction threshold -0.8dB */
|
|
|
|
#define AGC_HIGH 27254 /* accelerated gain reduction threshold -1.6dB */
|
|
|
|
#define AGC_IMG 823 /* threshold for balance control -32dB */
|
|
|
|
/* autogain high level thresholds (-3dB, -7dB, -4dB, -5dB, -5dB) */
|
2006-12-25 14:01:47 +00:00
|
|
|
static const short agc_th_hi[AGC_MODE_SIZE] =
|
2006-08-16 23:26:55 +00:00
|
|
|
{ 23197, 14637, 21156, 18428, 18426 };
|
|
|
|
/* autogain low level thresholds (-14dB, -11dB, -6dB, -7dB, -8dB) */
|
2006-12-25 14:01:47 +00:00
|
|
|
static const short agc_th_lo[AGC_MODE_SIZE] =
|
2006-08-16 23:26:55 +00:00
|
|
|
{ 6538, 9235, 16422, 14636, 13045 };
|
|
|
|
/* autogain threshold times [1/5s] or [200ms] */
|
2006-12-25 14:01:47 +00:00
|
|
|
static const short agc_tdrop[AGC_MODE_SIZE] =
|
2006-08-16 23:26:55 +00:00
|
|
|
{ 900, 225, 150, 60, 8 };
|
2006-12-25 14:01:47 +00:00
|
|
|
static const short agc_trise[AGC_MODE_SIZE] =
|
2006-08-16 23:26:55 +00:00
|
|
|
{ 9000, 750, 400, 150, 20 };
|
2006-12-25 14:01:47 +00:00
|
|
|
static const short agc_tbal[AGC_MODE_SIZE] =
|
2006-08-16 23:26:55 +00:00
|
|
|
{ 4500, 500, 300, 100, 15 };
|
|
|
|
/* AGC operation */
|
|
|
|
static bool agc_enable = true;
|
|
|
|
static short agc_preset;
|
|
|
|
/* AGC levels */
|
|
|
|
static int agc_left = 0;
|
|
|
|
static int agc_right = 0;
|
|
|
|
/* AGC time since high target volume was exceeded */
|
|
|
|
static short agc_droptime = 0;
|
|
|
|
/* AGC time since volume fallen below low target */
|
|
|
|
static short agc_risetime = 0;
|
|
|
|
/* AGC balance time exceeding +/- 0.7dB */
|
|
|
|
static short agc_baltime = 0;
|
|
|
|
/* AGC maximum gain */
|
|
|
|
static short agc_maxgain;
|
|
|
|
#endif /* HAVE_AGC */
|
2010-03-03 22:16:08 +00:00
|
|
|
#if defined(HAVE_AGC) || defined(HAVE_RECORDING_HISTOGRAM)
|
|
|
|
static long hist_time = 0;
|
|
|
|
#endif /* HAVE_AGC or HAVE_RECORDING_HISTOGRAM */
|
|
|
|
/* Histogram data */
|
|
|
|
/* TO DO: move some of this stuff inside the recording function? */
|
|
|
|
#ifdef HAVE_RECORDING_HISTOGRAM
|
|
|
|
static int hist_l = 0;
|
|
|
|
static int hist_r = 0;
|
2010-03-08 22:30:11 +00:00
|
|
|
#define HIST_BUF_SIZE (LCD_WIDTH)
|
2010-03-03 22:16:08 +00:00
|
|
|
#define HIST_Y (hist_pos_y+hist_size_h-1)
|
|
|
|
#define HIST_W (LCD_WIDTH / 2 - 4)
|
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
#define LCD_BAL_L LCD_RGBPACK(0, 0, 255)
|
|
|
|
#define LCD_BAL_R LCD_RGBPACK(204, 0, 0)
|
|
|
|
#define LCD_HIST_OVER LCD_RGBPACK(204, 0, 0)
|
|
|
|
#define LCD_HIST_HI LCD_RGBPACK(255, 204, 0)
|
|
|
|
#define LCD_HIST_OK LCD_RGBPACK(51, 153, 0)
|
|
|
|
#else /* HAVE_LCD_COLOR */
|
|
|
|
#define LCD_BATT_OK LCD_BLACK
|
|
|
|
#define LCD_BATT_LO LCD_DARKGRAY
|
|
|
|
#define LCD_DISK_OK LCD_BLACK
|
|
|
|
#define LCD_DISK_LO LCD_DARKGRAY
|
|
|
|
#define LCD_HIST_OVER LCD_BLACK
|
|
|
|
#define LCD_HIST_OK LCD_DARKGRAY
|
|
|
|
#define LCD_BAL LCD_DARKGRAY
|
|
|
|
#endif /* HAVE_LCD_COLOR */
|
|
|
|
#else /* LCD_DEPTH > 1 */
|
|
|
|
#define LCD_HIST_OVER LCD_DEFAULT_FG
|
|
|
|
#define LCD_HIST_OK LCD_DEFAULT_FG
|
|
|
|
#define LCD_BAL LCD_DEFAULT_FG
|
|
|
|
#endif /* LCD_DEPTH > 1 */
|
|
|
|
#endif /* HAVE_RECORDING_HISTOGRAM */
|
2006-08-16 23:26:55 +00:00
|
|
|
|
2002-11-10 16:42:31 +00:00
|
|
|
static void set_gain(void)
|
|
|
|
{
|
2008-12-31 01:38:44 +00:00
|
|
|
#ifdef HAVE_MIC_REC
|
2006-08-28 22:38:41 +00:00
|
|
|
if(global_settings.rec_source == AUDIO_SRC_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);
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
else
|
2008-12-31 01:38:44 +00:00
|
|
|
#endif /* MIC */
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
2007-05-20 20:26:36 +00:00
|
|
|
/* AUDIO_SRC_LINEIN, AUDIO_SRC_FMRADIO, AUDIO_SRC_SPDIF */
|
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);
|
|
|
|
}
|
2008-03-08 20:32:37 +00:00
|
|
|
/* reset the clipping indicators */
|
2008-03-08 17:43:04 +00:00
|
|
|
peak_meter_set_clip_hold(global_settings.peak_meter_clip_hold);
|
2008-08-06 20:12:44 +00:00
|
|
|
update_list = true;
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
|
2006-08-16 23:26:55 +00:00
|
|
|
#ifdef HAVE_AGC
|
|
|
|
/* Read peak meter values & calculate balance.
|
|
|
|
* Returns validity of peak values.
|
|
|
|
* Used for automatic gain control and history diagram.
|
|
|
|
*/
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool read_peak_levels(int *peak_l, int *peak_r, int *balance)
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
|
|
|
peak_meter_get_peakhold(peak_l, peak_r);
|
|
|
|
peak_valid_mem[peak_time % 3] = *peak_l;
|
|
|
|
if (((peak_valid_mem[0] == peak_valid_mem[1]) &&
|
|
|
|
(peak_valid_mem[1] == peak_valid_mem[2])) &&
|
2008-11-01 16:14:28 +00:00
|
|
|
((*peak_l < 32767) || storage_disk_is_active()))
|
2006-08-16 23:26:55 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (*peak_r > *peak_l)
|
2006-09-13 18:21:03 +00:00
|
|
|
balance_mem[peak_time % BAL_MEM_SIZE] = (*peak_l ?
|
|
|
|
MIN((10000 * *peak_r) / *peak_l - 10000, 15118) : 15118);
|
2006-08-16 23:26:55 +00:00
|
|
|
else
|
2006-09-13 18:21:03 +00:00
|
|
|
balance_mem[peak_time % BAL_MEM_SIZE] = (*peak_r ?
|
|
|
|
MAX(10000 - (10000 * *peak_l) / *peak_r, -15118) : -15118);
|
2006-08-16 23:26:55 +00:00
|
|
|
*balance = 0;
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < BAL_MEM_SIZE; i++)
|
|
|
|
*balance += balance_mem[i];
|
|
|
|
*balance = *balance / BAL_MEM_SIZE;
|
|
|
|
|
2010-03-03 22:16:08 +00:00
|
|
|
#ifdef HAVE_RECORDING_HISTOGRAM
|
|
|
|
if (*peak_l > hist_l)
|
|
|
|
hist_l = *peak_l;
|
|
|
|
if (*peak_r > hist_r)
|
|
|
|
hist_r = *peak_r;
|
|
|
|
#endif
|
|
|
|
|
2006-08-16 23:26:55 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* AGC helper function to check if maximum gain is reached */
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool agc_gain_is_max(bool left, bool right)
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
|
|
|
/* range -128...+108 [0.5dB] */
|
|
|
|
short gain_current_l;
|
|
|
|
short gain_current_r;
|
|
|
|
|
|
|
|
if (agc_preset == 0)
|
|
|
|
return false;
|
|
|
|
|
2006-08-28 22:38:41 +00:00
|
|
|
switch (global_settings.rec_source)
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
2008-12-31 01:38:44 +00:00
|
|
|
#if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
|
2007-05-20 20:26:36 +00:00
|
|
|
HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
|
|
|
|
HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
|
2006-08-16 23:26:55 +00:00
|
|
|
gain_current_l = global_settings.rec_left_gain;
|
|
|
|
gain_current_r = global_settings.rec_right_gain;
|
2006-08-28 22:38:41 +00:00
|
|
|
break;
|
2008-12-31 01:38:44 +00:00
|
|
|
#endif /* LINE, FMRADIO */
|
|
|
|
#if defined(HAVE_MIC_REC)
|
2007-05-20 20:26:36 +00:00
|
|
|
case AUDIO_SRC_MIC:
|
2006-08-28 22:38:41 +00:00
|
|
|
default:
|
2006-08-16 23:26:55 +00:00
|
|
|
gain_current_l = global_settings.rec_mic_gain;
|
|
|
|
gain_current_r = global_settings.rec_mic_gain;
|
2008-12-31 01:38:44 +00:00
|
|
|
#endif /* MIC */
|
2006-08-16 23:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ((left && (gain_current_l >= agc_maxgain)) ||
|
|
|
|
(right && (gain_current_r >= agc_maxgain)));
|
|
|
|
}
|
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static void change_recording_gain(bool increment, bool left, bool right)
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
|
|
|
int factor = (increment ? 1 : -1);
|
|
|
|
|
2006-08-28 22:38:41 +00:00
|
|
|
switch (global_settings.rec_source)
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
2008-12-31 01:38:44 +00:00
|
|
|
#if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
|
2007-05-20 20:26:36 +00:00
|
|
|
HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
|
|
|
|
HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
|
|
|
|
if (left) global_settings.rec_left_gain += factor;
|
2006-08-16 23:26:55 +00:00
|
|
|
if (right) global_settings.rec_right_gain += factor;
|
2006-08-28 22:38:41 +00:00
|
|
|
break;
|
2008-12-31 01:38:44 +00:00
|
|
|
#endif /* LINE, FMRADIO */
|
|
|
|
#if defined(HAVE_MIC_REC)
|
2007-05-20 20:26:36 +00:00
|
|
|
case AUDIO_SRC_MIC:
|
2006-08-16 23:26:55 +00:00
|
|
|
global_settings.rec_mic_gain += factor;
|
2008-12-31 01:38:44 +00:00
|
|
|
#endif
|
2006-08-16 23:26:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle automatic gain control (AGC).
|
|
|
|
* Change recording gain if peak_x levels are above or below
|
|
|
|
* target volume for specified timeouts.
|
|
|
|
*/
|
2006-12-25 14:01:47 +00:00
|
|
|
static void auto_gain_control(int *peak_l, int *peak_r, int *balance)
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
|
|
|
int agc_mono;
|
|
|
|
short agc_mode;
|
|
|
|
bool increment;
|
|
|
|
|
|
|
|
if (*peak_l > agc_left)
|
|
|
|
agc_left = *peak_l;
|
|
|
|
else
|
|
|
|
agc_left -= (agc_left - *peak_l + 3) >> 2;
|
|
|
|
if (*peak_r > agc_right)
|
|
|
|
agc_right = *peak_r;
|
|
|
|
else
|
|
|
|
agc_right -= (agc_right - *peak_r + 3) >> 2;
|
|
|
|
agc_mono = (agc_left + agc_right) / 2;
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2006-08-16 23:26:55 +00:00
|
|
|
agc_mode = abs(agc_preset) - 1;
|
|
|
|
if (agc_mode < 0) {
|
|
|
|
agc_enable = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-01 10:04:40 +00:00
|
|
|
if (agc_mode != AGC_SAFETY_MODE) {
|
|
|
|
/* Automatic balance control - only if not in safety mode */
|
|
|
|
if ((agc_left > AGC_IMG) && (agc_right > AGC_IMG))
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
2006-10-01 10:04:40 +00:00
|
|
|
if (*balance < -556)
|
|
|
|
{
|
|
|
|
if (*balance > -900)
|
|
|
|
agc_baltime -= !(peak_time % 4); /* 0.47 - 0.75dB */
|
|
|
|
else if (*balance > -4125)
|
|
|
|
agc_baltime--; /* 0.75 - 3.00dB */
|
|
|
|
else if (*balance > -7579)
|
|
|
|
agc_baltime -= 2; /* 3.00 - 4.90dB */
|
|
|
|
else
|
|
|
|
agc_baltime -= !(peak_time % 8); /* 4.90 - inf dB */
|
|
|
|
if (agc_baltime > 0)
|
|
|
|
agc_baltime -= (peak_time % 2);
|
|
|
|
}
|
|
|
|
else if (*balance > 556)
|
|
|
|
{
|
|
|
|
if (*balance < 900)
|
|
|
|
agc_baltime += !(peak_time % 4);
|
|
|
|
else if (*balance < 4125)
|
|
|
|
agc_baltime++;
|
|
|
|
else if (*balance < 7579)
|
|
|
|
agc_baltime += 2;
|
|
|
|
else
|
|
|
|
agc_baltime += !(peak_time % 8);
|
|
|
|
if (agc_baltime < 0)
|
|
|
|
agc_baltime += (peak_time % 2);
|
|
|
|
}
|
2006-08-16 23:26:55 +00:00
|
|
|
|
2006-10-01 10:04:40 +00:00
|
|
|
if ((*balance * agc_baltime) < 0)
|
|
|
|
{
|
|
|
|
if (*balance < 0)
|
|
|
|
agc_baltime -= peak_time % 2;
|
|
|
|
else
|
|
|
|
agc_baltime += peak_time % 2;
|
|
|
|
}
|
2006-08-16 23:26:55 +00:00
|
|
|
|
2006-10-01 10:04:40 +00:00
|
|
|
increment = ((agc_risetime / 2) > agc_droptime);
|
|
|
|
|
|
|
|
if (agc_baltime < -agc_tbal[agc_mode])
|
|
|
|
{
|
|
|
|
if (!increment || !agc_gain_is_max(!increment, increment)) {
|
|
|
|
change_recording_gain(increment, !increment, increment);
|
|
|
|
set_gain();
|
|
|
|
}
|
|
|
|
agc_baltime = 0;
|
|
|
|
}
|
|
|
|
else if (agc_baltime > +agc_tbal[agc_mode])
|
|
|
|
{
|
|
|
|
if (!increment || !agc_gain_is_max(increment, !increment)) {
|
|
|
|
change_recording_gain(increment, increment, !increment);
|
|
|
|
set_gain();
|
|
|
|
}
|
|
|
|
agc_baltime = 0;
|
2006-08-16 23:26:55 +00:00
|
|
|
}
|
|
|
|
}
|
2006-10-01 10:04:40 +00:00
|
|
|
else if (!(hist_time % 4))
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
2006-10-01 10:04:40 +00:00
|
|
|
if (agc_baltime < 0)
|
|
|
|
agc_baltime++;
|
|
|
|
else
|
|
|
|
agc_baltime--;
|
2006-08-16 23:26:55 +00:00
|
|
|
}
|
|
|
|
}
|
2006-10-01 10:04:40 +00:00
|
|
|
|
2006-08-16 23:26:55 +00:00
|
|
|
/* Automatic gain control */
|
|
|
|
if ((agc_left > agc_th_hi[agc_mode]) || (agc_right > agc_th_hi[agc_mode]))
|
|
|
|
{
|
|
|
|
if ((agc_left > AGC_CLIP) || (agc_right > AGC_CLIP))
|
|
|
|
agc_droptime += agc_tdrop[agc_mode] /
|
|
|
|
(global_settings.rec_agc_cliptime + 1);
|
|
|
|
if (agc_left > AGC_HIGH) {
|
|
|
|
agc_droptime++;
|
|
|
|
agc_risetime=0;
|
|
|
|
if (agc_left > AGC_PEAK)
|
|
|
|
agc_droptime += 2;
|
|
|
|
}
|
|
|
|
if (agc_right > AGC_HIGH) {
|
|
|
|
agc_droptime++;
|
|
|
|
agc_risetime=0;
|
|
|
|
if (agc_right > AGC_PEAK)
|
|
|
|
agc_droptime += 2;
|
|
|
|
}
|
|
|
|
if (agc_mono > agc_th_hi[agc_mode])
|
|
|
|
agc_droptime++;
|
|
|
|
else
|
|
|
|
agc_droptime += !(peak_time % 2);
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2006-08-16 23:26:55 +00:00
|
|
|
if (agc_droptime >= agc_tdrop[agc_mode])
|
|
|
|
{
|
|
|
|
change_recording_gain(false, true, true);
|
|
|
|
agc_droptime = 0;
|
|
|
|
agc_risetime = 0;
|
|
|
|
set_gain();
|
|
|
|
}
|
|
|
|
agc_risetime = MAX(agc_risetime - 1, 0);
|
|
|
|
}
|
|
|
|
else if (agc_mono < agc_th_lo[agc_mode])
|
|
|
|
{
|
|
|
|
if (agc_mono < (agc_th_lo[agc_mode] / 8))
|
|
|
|
agc_risetime += !(peak_time % 5);
|
|
|
|
else if (agc_mono < (agc_th_lo[agc_mode] / 2))
|
|
|
|
agc_risetime += 2;
|
|
|
|
else
|
|
|
|
agc_risetime++;
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2006-08-16 23:26:55 +00:00
|
|
|
if (agc_risetime >= agc_trise[agc_mode]) {
|
2006-10-01 10:04:40 +00:00
|
|
|
if ((agc_mode != AGC_SAFETY_MODE) &&
|
|
|
|
(!agc_gain_is_max(true, true))) {
|
2006-08-16 23:26:55 +00:00
|
|
|
change_recording_gain(true, true, true);
|
|
|
|
set_gain();
|
|
|
|
}
|
|
|
|
agc_risetime = 0;
|
|
|
|
agc_droptime = 0;
|
|
|
|
}
|
|
|
|
agc_droptime = MAX(agc_droptime - 1, 0);
|
|
|
|
}
|
|
|
|
else if (!(peak_time % 6)) /* on target level every 1.2 sec */
|
|
|
|
{
|
|
|
|
agc_risetime = MAX(agc_risetime - 1, 0);
|
|
|
|
agc_droptime = MAX(agc_droptime - 1, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* HAVE_AGC */
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static char *fmt_gain(int snd, int val, char *str, int len)
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
2006-02-08 13:08:55 +00:00
|
|
|
int i, d, numdec;
|
2004-07-20 22:13:24 +00:00
|
|
|
const char *unit;
|
2006-05-14 23:34:24 +00:00
|
|
|
char sign = ' ';
|
2006-02-08 13:08:55 +00:00
|
|
|
|
|
|
|
val = sound_val2phys(snd, val);
|
|
|
|
if(val < 0)
|
|
|
|
{
|
|
|
|
sign = '-';
|
2006-05-14 23:34:24 +00:00
|
|
|
val = -val;
|
2006-02-08 13:08:55 +00:00
|
|
|
}
|
2005-04-01 13:41:03 +00:00
|
|
|
numdec = sound_numdecimals(snd);
|
|
|
|
unit = sound_unit(snd);
|
2007-12-07 00:28:16 +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);
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2006-02-08 13:08:55 +00:00
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2007-08-02 18:45:38 +00:00
|
|
|
/* the list below must match enum audio_sources in audio.h */
|
|
|
|
static const char* const prestr[] =
|
|
|
|
{
|
2007-08-03 18:55:00 +00:00
|
|
|
HAVE_MIC_IN_([AUDIO_SRC_MIC] = "R_MIC_",)
|
|
|
|
HAVE_LINE_REC_([AUDIO_SRC_LINEIN] = "R_LINE_",)
|
|
|
|
HAVE_SPDIF_IN_([AUDIO_SRC_SPDIF] = "R_SPDIF_",)
|
|
|
|
HAVE_FMRADIO_REC_([AUDIO_SRC_FMRADIO] = "R_FM_",)
|
2007-08-02 18:45:38 +00:00
|
|
|
};
|
|
|
|
|
2004-01-21 14:58:40 +00:00
|
|
|
char *rec_create_filename(char *buffer)
|
2002-11-20 00:02:52 +00:00
|
|
|
{
|
2006-11-06 18:07:30 +00:00
|
|
|
char ext[16];
|
2007-08-02 18:45:38 +00:00
|
|
|
const char *pref = "R_";
|
2007-08-02 10:40:47 +00:00
|
|
|
|
2007-11-30 05:14:57 +00:00
|
|
|
/* Directory existence and writeablility should have already been
|
|
|
|
* verified - do not pass NULL pointers to pcmrec */
|
2007-08-01 22:04:28 +00:00
|
|
|
|
2007-11-30 05:14:57 +00:00
|
|
|
if((unsigned)global_settings.rec_source < AUDIO_NUM_SOURCES)
|
2007-08-01 22:04:28 +00:00
|
|
|
{
|
2007-08-02 18:45:38 +00:00
|
|
|
pref = prestr[global_settings.rec_source];
|
2007-08-01 22:04:28 +00:00
|
|
|
}
|
2007-11-30 05:14:57 +00:00
|
|
|
|
|
|
|
strcpy(buffer, global_settings.rec_directory);
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
snprintf(ext, sizeof(ext), ".%s",
|
|
|
|
REC_FILE_ENDING(global_settings.rec_format));
|
2006-09-27 21:36:50 +00:00
|
|
|
|
2007-06-22 09:34:57 +00:00
|
|
|
#if CONFIG_RTC == 0
|
2007-08-01 22:04:28 +00:00
|
|
|
return create_numbered_filename(buffer, buffer, pref, ext, 4,
|
2007-06-22 09:34:57 +00:00
|
|
|
&file_number);
|
|
|
|
#else
|
2006-11-06 18:07:30 +00:00
|
|
|
/* We'll wait at least up to the start of the next second so no duplicate
|
|
|
|
names are created */
|
2007-08-01 22:04:28 +00:00
|
|
|
return create_datetime_filename(buffer, buffer, pref, ext, true);
|
2004-10-17 10:00:46 +00:00
|
|
|
#endif
|
2002-11-20 00:02:52 +00:00
|
|
|
}
|
|
|
|
|
2007-06-22 09:34:57 +00:00
|
|
|
#if CONFIG_RTC == 0
|
|
|
|
/* Hit disk to get a starting filename for the type */
|
2007-09-22 09:05:06 +00:00
|
|
|
static void rec_init_filename(void)
|
2007-06-22 09:34:57 +00:00
|
|
|
{
|
|
|
|
file_number = -1;
|
|
|
|
rec_create_filename(path_buffer);
|
|
|
|
file_number--;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-06-04 12:34:29 +00:00
|
|
|
int rec_create_directory(void)
|
|
|
|
{
|
2007-11-30 05:14:57 +00:00
|
|
|
int rc = 0;
|
|
|
|
const char * const folder = global_settings.rec_directory;
|
|
|
|
|
|
|
|
if (strcmp(folder, "/") && !dir_exists(folder))
|
|
|
|
{
|
|
|
|
rc = mkdir(folder);
|
|
|
|
|
|
|
|
if(rc < 0)
|
|
|
|
{
|
|
|
|
while (action_userabort(HZ) == false)
|
|
|
|
{
|
2008-08-15 08:27:39 +00:00
|
|
|
splashf(0, "%s %s",
|
|
|
|
str(LANG_REC_DIR_NOT_WRITABLE),
|
|
|
|
str(LANG_OFF_ABORT));
|
2007-11-30 05:14:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rec_status |= RCSTAT_CREATED_DIRECTORY;
|
|
|
|
rc = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
2004-06-04 12:34:29 +00:00
|
|
|
}
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
void rec_init_recording_options(struct audio_recording_options *options)
|
|
|
|
{
|
|
|
|
options->rec_source = global_settings.rec_source;
|
|
|
|
options->rec_frequency = global_settings.rec_frequency;
|
|
|
|
options->rec_channels = global_settings.rec_channels;
|
|
|
|
options->rec_prerecord_time = global_settings.rec_prerecord_time;
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2008-10-08 22:18:16 +00:00
|
|
|
options->rec_mono_mode = global_settings.rec_mono_mode;
|
2006-11-06 18:07:30 +00:00
|
|
|
options->rec_source_flags = 0;
|
|
|
|
options->enc_config.rec_format = global_settings.rec_format;
|
|
|
|
global_to_encoder_config(&options->enc_config);
|
|
|
|
#else
|
|
|
|
options->rec_quality = global_settings.rec_quality;
|
|
|
|
options->rec_editable = global_settings.rec_editable;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-06-08 23:42:04 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC && !defined (SIMULATOR)
|
|
|
|
void rec_set_source(int source, unsigned flags)
|
|
|
|
{
|
|
|
|
/* Set audio input source, power up/down devices */
|
|
|
|
audio_set_input_source(source, flags);
|
|
|
|
|
|
|
|
/* Set peakmeters for recording or reset to playback */
|
|
|
|
peak_meter_playback((flags & SRCF_RECORDING) == 0);
|
2010-05-09 13:01:59 +00:00
|
|
|
peak_meter_enable(true);
|
2007-06-08 23:42:04 +00:00
|
|
|
}
|
|
|
|
#endif /* CONFIG_CODEC == SWCODEC && !defined (SIMULATOR) */
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
void rec_set_recording_options(struct audio_recording_options *options)
|
2006-08-28 22:38:41 +00:00
|
|
|
{
|
|
|
|
#if CONFIG_CODEC != SWCODEC
|
|
|
|
if (global_settings.rec_prerecord_time)
|
2007-10-19 15:43:43 +00:00
|
|
|
{
|
2006-08-28 22:38:41 +00:00
|
|
|
talk_buffer_steal(); /* will use the mp3 buffer */
|
2007-10-19 15:43:43 +00:00
|
|
|
}
|
|
|
|
#else /* == SWCODEC */
|
2006-11-06 18:07:30 +00:00
|
|
|
rec_set_source(options->rec_source,
|
|
|
|
options->rec_source_flags | SRCF_RECORDING);
|
2006-11-13 23:21:54 +00:00
|
|
|
#endif /* CONFIG_CODEC != SWCODEC */
|
2006-08-28 22:38:41 +00:00
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
audio_set_recording_options(options);
|
2006-08-28 22:38:41 +00:00
|
|
|
}
|
|
|
|
|
2007-08-25 15:53:54 +00:00
|
|
|
void rec_command(enum recording_command cmd)
|
2006-08-28 22:38:41 +00:00
|
|
|
{
|
2007-08-25 15:53:54 +00:00
|
|
|
switch(cmd)
|
|
|
|
{
|
2008-05-15 22:47:07 +00:00
|
|
|
case RECORDING_CMD_STOP_SHUTDOWN:
|
|
|
|
pm_activate_clipcount(false);
|
|
|
|
audio_stop_recording();
|
2008-05-15 23:00:33 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2008-05-15 22:47:07 +00:00
|
|
|
audio_close_recording();
|
2008-05-15 23:00:33 +00:00
|
|
|
#endif
|
2008-05-15 22:47:07 +00:00
|
|
|
sys_poweroff();
|
2008-05-15 23:00:33 +00:00
|
|
|
break;
|
2007-08-25 15:53:54 +00:00
|
|
|
case RECORDING_CMD_STOP:
|
|
|
|
pm_activate_clipcount(false);
|
|
|
|
audio_stop_recording();
|
|
|
|
break;
|
|
|
|
case RECORDING_CMD_START:
|
|
|
|
/* steal mp3 buffer, create unique filename and start recording */
|
|
|
|
pm_reset_clipcount();
|
|
|
|
pm_activate_clipcount(true);
|
2006-11-06 18:07:30 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2007-08-25 15:53:54 +00:00
|
|
|
talk_buffer_steal(); /* we use the mp3 buffer */
|
2006-11-06 18:07:30 +00:00
|
|
|
#endif
|
2007-08-25 15:53:54 +00:00
|
|
|
audio_record(rec_create_filename(path_buffer));
|
|
|
|
break;
|
|
|
|
case RECORDING_CMD_START_NEWFILE:
|
|
|
|
/* create unique filename and start recording*/
|
|
|
|
pm_reset_clipcount();
|
|
|
|
pm_activate_clipcount(true); /* just to be sure */
|
|
|
|
audio_new_file(rec_create_filename(path_buffer));
|
|
|
|
break;
|
|
|
|
case RECORDING_CMD_PAUSE:
|
|
|
|
pm_activate_clipcount(false);
|
|
|
|
audio_pause_recording();
|
|
|
|
break;
|
|
|
|
case RECORDING_CMD_RESUME:
|
|
|
|
pm_activate_clipcount(true);
|
|
|
|
audio_resume_recording();
|
|
|
|
break;
|
|
|
|
}
|
2008-08-06 20:12:44 +00:00
|
|
|
update_list = true;
|
2006-08-28 22:38:41 +00:00
|
|
|
}
|
|
|
|
|
2005-04-04 09:12:12 +00:00
|
|
|
/* 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:
|
2007-06-22 09:34:57 +00:00
|
|
|
if(!(audio_status() & AUDIO_STATUS_RECORD))
|
2005-04-04 09:12:12 +00:00
|
|
|
{
|
2007-06-22 09:34:57 +00:00
|
|
|
rec_status |= RCSTAT_HAVE_RECORDED;
|
2007-08-25 15:53:54 +00:00
|
|
|
rec_command(RECORDING_CMD_START);
|
2007-06-22 09:34:57 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2006-08-28 22:38:41 +00:00
|
|
|
/* give control to mpeg thread so that it can start
|
|
|
|
recording */
|
2006-04-30 22:28:45 +00:00
|
|
|
yield(); yield(); yield();
|
2007-06-22 09:34:57 +00:00
|
|
|
#endif
|
2005-04-04 09:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if we're already recording this is a retrigger */
|
|
|
|
else
|
|
|
|
{
|
2006-11-09 12:27:56 +00:00
|
|
|
if((audio_status() & AUDIO_STATUS_PAUSE) &&
|
2008-05-28 10:55:39 +00:00
|
|
|
(global_settings.rec_trigger_type == TRIG_TYPE_PAUSE))
|
2007-08-25 15:53:54 +00:00
|
|
|
{
|
|
|
|
rec_command(RECORDING_CMD_RESUME);
|
|
|
|
}
|
2006-11-09 12:27:56 +00:00
|
|
|
/* New file on trig start*/
|
2008-05-28 10:55:39 +00:00
|
|
|
else if (global_settings.rec_trigger_type != TRIG_TYPE_NEW_FILE)
|
2006-11-09 12:27:56 +00:00
|
|
|
{
|
2007-08-25 15:53:54 +00:00
|
|
|
rec_command(RECORDING_CMD_START_NEWFILE);
|
2006-11-09 12:27:56 +00:00
|
|
|
/* tell recording_screen to reset the time */
|
|
|
|
last_seconds = 0;
|
|
|
|
}
|
2005-04-04 09:12:12 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
{
|
2006-11-09 12:27:56 +00:00
|
|
|
switch(global_settings.rec_trigger_type)
|
|
|
|
{
|
2008-05-28 10:55:39 +00:00
|
|
|
case TRIG_TYPE_STOP: /* Stop */
|
2007-08-25 15:53:54 +00:00
|
|
|
rec_command(RECORDING_CMD_STOP);
|
2006-11-09 12:27:56 +00:00
|
|
|
break;
|
|
|
|
|
2008-05-28 10:55:39 +00:00
|
|
|
case TRIG_TYPE_PAUSE: /* Pause */
|
2007-08-25 15:53:54 +00:00
|
|
|
rec_command(RECORDING_CMD_PAUSE);
|
2006-11-09 12:27:56 +00:00
|
|
|
break;
|
|
|
|
|
2008-05-28 10:55:39 +00:00
|
|
|
case TRIG_TYPE_NEW_FILE: /* New file on trig stop*/
|
2007-08-25 15:53:54 +00:00
|
|
|
rec_command(RECORDING_CMD_START_NEWFILE);
|
2006-11-09 12:27:56 +00:00
|
|
|
/* tell recording_screen to reset the time */
|
|
|
|
last_seconds = 0;
|
|
|
|
break;
|
2008-08-06 20:12:44 +00:00
|
|
|
|
2008-05-15 22:47:07 +00:00
|
|
|
case 3: /* Stop and shutdown */
|
|
|
|
rec_command(RECORDING_CMD_STOP_SHUTDOWN);
|
|
|
|
break;
|
2006-11-09 12:27:56 +00:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
/* Stuff for drawing the screen */
|
|
|
|
|
|
|
|
enum rec_list_items_stereo {
|
|
|
|
ITEM_VOLUME = 0,
|
|
|
|
ITEM_GAIN = 1,
|
|
|
|
ITEM_GAIN_L = 2,
|
|
|
|
ITEM_GAIN_R = 3,
|
|
|
|
#ifdef HAVE_AGC
|
|
|
|
ITEM_AGC_MODE = 4,
|
|
|
|
ITEM_AGC_MAXDB = 5,
|
2008-08-20 22:33:38 +00:00
|
|
|
ITEM_FILENAME = 7,
|
2008-08-06 20:12:44 +00:00
|
|
|
ITEM_COUNT = 7,
|
|
|
|
#else
|
2008-08-20 22:33:38 +00:00
|
|
|
ITEM_FILENAME = 7,
|
2008-08-06 20:12:44 +00:00
|
|
|
ITEM_COUNT = 5,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
enum rec_list_items_mono {
|
|
|
|
ITEM_VOLUME_M = 0,
|
|
|
|
ITEM_GAIN_M = 1,
|
|
|
|
#ifdef HAVE_AGC
|
|
|
|
ITEM_AGC_MODE_M = 4,
|
|
|
|
ITEM_AGC_MAXDB_M = 5,
|
2008-08-20 22:33:38 +00:00
|
|
|
ITEM_FILENAME_M = 7,
|
2008-08-06 20:12:44 +00:00
|
|
|
ITEM_COUNT_M = 5,
|
|
|
|
#else
|
2008-08-20 22:33:38 +00:00
|
|
|
ITEM_FILENAME_M = 7,
|
2008-08-06 20:12:44 +00:00
|
|
|
ITEM_COUNT_M = 3,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2008-08-20 21:38:47 +00:00
|
|
|
#ifdef HAVE_SPDIF_REC
|
|
|
|
enum rec_list_items_spdif {
|
|
|
|
ITEM_VOLUME_D = 0,
|
2008-08-20 22:33:38 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
ITEM_SAMPLERATE_D = 6,
|
|
|
|
ITEM_FILENAME_D = 7,
|
|
|
|
ITEM_COUNT_D = 3,
|
|
|
|
#else
|
|
|
|
ITEM_FILENAME_D = 7,
|
2008-08-20 21:38:47 +00:00
|
|
|
ITEM_COUNT_D = 2,
|
2008-08-20 22:33:38 +00:00
|
|
|
#endif
|
2008-08-20 21:38:47 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
static int listid_to_enum[ITEM_COUNT];
|
|
|
|
|
2009-08-20 16:47:44 +00:00
|
|
|
static const char* reclist_get_name(int selected_item, void * data,
|
|
|
|
char * buffer, size_t buffer_len)
|
2008-08-06 20:12:44 +00:00
|
|
|
{
|
|
|
|
char buf2[32];
|
|
|
|
#ifdef HAVE_AGC
|
|
|
|
char buf3[32];
|
|
|
|
#endif
|
|
|
|
data = data; /* not used */
|
|
|
|
if(selected_item >= ITEM_COUNT)
|
|
|
|
return "";
|
|
|
|
|
|
|
|
switch (listid_to_enum[selected_item])
|
|
|
|
{
|
|
|
|
case ITEM_VOLUME:
|
|
|
|
snprintf(buffer, buffer_len, "%s: %s", str(LANG_VOLUME),
|
|
|
|
fmt_gain(SOUND_VOLUME,
|
|
|
|
global_settings.volume,
|
|
|
|
buf2, sizeof(buf2)));
|
|
|
|
break;
|
|
|
|
case ITEM_GAIN:
|
2008-12-31 01:38:44 +00:00
|
|
|
#ifdef HAVE_MIC_REC
|
2008-08-06 20:12:44 +00:00
|
|
|
if(global_settings.rec_source == AUDIO_SRC_MIC)
|
|
|
|
{
|
|
|
|
/* Draw MIC recording gain */
|
|
|
|
snprintf(buffer, buffer_len, "%s: %s", str(LANG_GAIN),
|
|
|
|
fmt_gain(SOUND_MIC_GAIN,
|
|
|
|
global_settings.rec_mic_gain,
|
|
|
|
buf2, sizeof(buf2)));
|
|
|
|
}
|
|
|
|
else
|
2008-12-31 01:38:44 +00:00
|
|
|
#endif /* MIC */
|
2008-08-06 20:12:44 +00:00
|
|
|
{
|
|
|
|
int avg_gain = (global_settings.rec_left_gain +
|
|
|
|
global_settings.rec_right_gain) / 2;
|
|
|
|
snprintf(buffer, buffer_len, "%s: %s", str(LANG_GAIN),
|
|
|
|
fmt_gain(SOUND_LEFT_GAIN,
|
|
|
|
avg_gain,
|
|
|
|
buf2, sizeof(buf2)));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ITEM_GAIN_L:
|
|
|
|
snprintf(buffer, buffer_len, "%s: %s",
|
|
|
|
str(LANG_GAIN_LEFT),
|
|
|
|
fmt_gain(SOUND_LEFT_GAIN,
|
|
|
|
global_settings.rec_left_gain,
|
|
|
|
buf2, sizeof(buf2)));
|
|
|
|
break;
|
|
|
|
case ITEM_GAIN_R:
|
|
|
|
snprintf(buffer, buffer_len, "%s: %s",
|
|
|
|
str(LANG_GAIN_RIGHT),
|
|
|
|
fmt_gain(SOUND_RIGHT_GAIN,
|
|
|
|
global_settings.rec_right_gain,
|
|
|
|
buf2, sizeof(buf2)));
|
|
|
|
break;
|
|
|
|
#ifdef HAVE_AGC
|
|
|
|
case ITEM_AGC_MODE:
|
|
|
|
snprintf(buffer, buffer_len, "%s: %s",
|
|
|
|
str(LANG_RECORDING_AGC_PRESET),
|
|
|
|
agc_preset_str[agc_preset]);
|
|
|
|
break;
|
|
|
|
case ITEM_AGC_MAXDB:
|
|
|
|
if (agc_preset == 0)
|
|
|
|
snprintf(buffer, buffer_len, "%s: %s",
|
|
|
|
str(LANG_RECORDING_AGC_MAXGAIN),
|
|
|
|
fmt_gain(SOUND_LEFT_GAIN,
|
|
|
|
agc_maxgain, buf2, sizeof(buf2)));
|
2008-12-31 01:38:44 +00:00
|
|
|
#ifdef HAVE_MIC_REC
|
2008-08-06 20:12:44 +00:00
|
|
|
else if (global_settings.rec_source == AUDIO_SRC_MIC)
|
|
|
|
snprintf(buffer, buffer_len, "%s: %s (%s)",
|
|
|
|
str(LANG_RECORDING_AGC_MAXGAIN),
|
|
|
|
fmt_gain(SOUND_MIC_GAIN,
|
|
|
|
agc_maxgain, buf2, sizeof(buf2)),
|
|
|
|
fmt_gain(SOUND_MIC_GAIN,
|
|
|
|
agc_maxgain - global_settings.rec_mic_gain,
|
|
|
|
buf3, sizeof(buf3)));
|
|
|
|
else
|
2008-12-31 01:38:44 +00:00
|
|
|
#endif /* MIC */
|
2008-08-06 20:12:44 +00:00
|
|
|
snprintf(buffer, buffer_len, "%s: %s (%s)",
|
|
|
|
str(LANG_RECORDING_AGC_MAXGAIN),
|
|
|
|
fmt_gain(SOUND_LEFT_GAIN,
|
|
|
|
agc_maxgain, buf2, sizeof(buf2)),
|
|
|
|
fmt_gain(SOUND_LEFT_GAIN,
|
|
|
|
agc_maxgain -
|
|
|
|
(global_settings.rec_left_gain +
|
|
|
|
global_settings.rec_right_gain)/2,
|
|
|
|
buf3, sizeof(buf3)));
|
|
|
|
break;
|
2008-08-20 22:33:38 +00:00
|
|
|
#endif
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
#ifdef HAVE_SPDIF_REC
|
|
|
|
case ITEM_SAMPLERATE_D:
|
2010-05-06 21:37:03 +00:00
|
|
|
snprintf(buffer, buffer_len, "%s: %lu",
|
2008-08-20 22:33:38 +00:00
|
|
|
str(LANG_RECORDING_FREQUENCY),
|
|
|
|
pcm_rec_sample_rate());
|
|
|
|
break;
|
|
|
|
#endif
|
2008-08-06 20:12:44 +00:00
|
|
|
#endif
|
|
|
|
case ITEM_FILENAME:
|
|
|
|
{
|
|
|
|
if(audio_status() & AUDIO_STATUS_RECORD)
|
|
|
|
{
|
|
|
|
size_t tot_len = strlen(path_buffer) +
|
|
|
|
strlen(str(LANG_RECORDING_FILENAME)) + 1;
|
|
|
|
if(tot_len > buffer_len)
|
|
|
|
{
|
|
|
|
snprintf(buffer, buffer_len, "%s %s",
|
|
|
|
str(LANG_RECORDING_FILENAME),
|
|
|
|
path_buffer + tot_len - buffer_len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
snprintf(buffer, buffer_len, "%s %s",
|
|
|
|
str(LANG_RECORDING_FILENAME), path_buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-11 08:45:47 +00:00
|
|
|
return str(LANG_RECORDING_FILENAME);
|
2008-08-06 20:12:44 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-07 01:59:29 +00:00
|
|
|
bool recording_start_automatic = false;
|
|
|
|
|
2006-08-28 22:38:41 +00:00
|
|
|
bool recording_screen(bool no_source)
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
2008-08-06 20:12:44 +00:00
|
|
|
int button;
|
|
|
|
int done = -1; /* negative to re-init, positive to quit, zero to run */
|
|
|
|
char buf[32]; /* for preparing strings */
|
|
|
|
char buf2[32]; /* for preparing strings */
|
|
|
|
int w, h; /* character width/height */
|
2008-08-13 21:09:10 +00:00
|
|
|
int update_countdown = 0; /* refresh counter */
|
2007-04-15 22:16:28 +00:00
|
|
|
unsigned int seconds;
|
2002-11-19 21:07:44 +00:00
|
|
|
int hours, minutes;
|
2008-08-06 20:12:44 +00:00
|
|
|
int audio_stat = 0; /* status of the audio system */
|
|
|
|
int last_audio_stat = -1; /* previous status so we can act on changes */
|
|
|
|
struct viewport vp_list[NB_SCREENS], vp_top[NB_SCREENS]; /* the viewports */
|
|
|
|
|
2006-12-10 14:21:31 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
int warning_counter = 0;
|
|
|
|
#define WARNING_PERIOD 7
|
|
|
|
#endif
|
2008-08-06 20:12:44 +00:00
|
|
|
|
2008-08-20 22:33:38 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
#ifdef HAVE_SPDIF_REC
|
|
|
|
unsigned long prev_sample_rate = 0;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2007-05-20 20:26:36 +00:00
|
|
|
#ifdef HAVE_FMRADIO_REC
|
2006-08-28 22:38:41 +00:00
|
|
|
/* Radio is left on if:
|
|
|
|
* 1) Is was on at the start and the initial source is FM Radio
|
|
|
|
* 2) 1) and the source was never changed to something else
|
|
|
|
*/
|
|
|
|
int radio_status = (global_settings.rec_source != AUDIO_SRC_FMRADIO) ?
|
|
|
|
FMRADIO_OFF : get_radio_status();
|
|
|
|
#endif
|
2007-02-18 05:07:19 +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
|
2006-08-16 23:26:55 +00:00
|
|
|
#ifdef HAVE_AGC
|
|
|
|
bool peak_read = false;
|
|
|
|
int peak_l, peak_r;
|
|
|
|
int balance = 0;
|
|
|
|
#endif
|
2010-03-08 22:42:15 +00:00
|
|
|
int i;
|
2008-08-06 20:12:44 +00:00
|
|
|
int pm_x[NB_SCREENS]; /* peakmeter (and trigger bar) x pos */
|
|
|
|
int pm_y[NB_SCREENS]; /* peakmeter y pos */
|
|
|
|
int pm_h[NB_SCREENS]; /* peakmeter height */
|
|
|
|
int trig_ypos[NB_SCREENS]; /* trigger bar y pos */
|
|
|
|
int trig_width[NB_SCREENS]; /* trigger bar width */
|
2010-03-03 22:16:08 +00:00
|
|
|
int top_height_req[NB_SCREENS]; /* required height for top half */
|
2010-03-08 23:56:54 +00:00
|
|
|
/* tweak layout tiny screens / big fonts */
|
|
|
|
bool compact_view[NB_SCREENS] = { false };
|
2008-08-06 20:12:44 +00:00
|
|
|
struct gui_synclist lists; /* the list in the bottom vp */
|
2010-03-03 22:16:08 +00:00
|
|
|
#if defined(HAVE_AGC) || defined(HAVE_RECORDING_HISTOGRAM)
|
|
|
|
bool peak_valid = false;
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_RECORDING_HISTOGRAM)
|
2010-03-08 22:42:15 +00:00
|
|
|
int j;
|
2010-03-03 22:16:08 +00:00
|
|
|
unsigned short hist_pos_y = 0;
|
|
|
|
unsigned short hist_size_h = 0;
|
|
|
|
int history_pos = 0;
|
|
|
|
short hist_time_interval = 1; /* 1, 2, 4, 8 */
|
2010-03-08 22:30:11 +00:00
|
|
|
unsigned char history_l[HIST_BUF_SIZE];
|
|
|
|
unsigned char history_r[HIST_BUF_SIZE];
|
2010-03-03 22:16:08 +00:00
|
|
|
const char hist_level_marks[6] = { 29, 26, 23, 17, 9, 2};
|
|
|
|
#endif
|
2008-08-06 20:12:44 +00:00
|
|
|
#ifdef HAVE_FMRADIO_REC
|
|
|
|
int prev_rec_source = global_settings.rec_source; /* detect source change */
|
|
|
|
#endif
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
struct audio_recording_options rec_options;
|
2007-11-30 05:14:57 +00:00
|
|
|
rec_status = RCSTAT_IN_RECSCREEN;
|
|
|
|
|
2008-11-04 19:57:36 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_ATA) && (CONFIG_LED == LED_REAL) \
|
|
|
|
&& !defined(SIMULATOR)
|
|
|
|
ata_set_led_enabled(false);
|
2005-04-04 09:12:12 +00:00
|
|
|
#endif
|
2006-04-30 23:51:24 +00:00
|
|
|
|
2006-08-28 22:38:41 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2010-05-26 04:51:24 +00:00
|
|
|
/* This should be done before touching audio settings */
|
|
|
|
while (!audio_is_thread_ready())
|
|
|
|
sleep(0);
|
|
|
|
|
2007-06-11 08:28:38 +00:00
|
|
|
/* recording_menu gets messed up: so prevent manus talking */
|
2007-10-19 15:31:42 +00:00
|
|
|
talk_disable(true);
|
2006-11-06 18:07:30 +00:00
|
|
|
/* audio_init_recording stops anything playing when it takes the audio
|
|
|
|
buffer */
|
2006-08-28 22:38:41 +00:00
|
|
|
#else
|
|
|
|
/* Yes, we use the D/A for monitoring */
|
2010-05-09 13:01:59 +00:00
|
|
|
peak_meter_enable(true);
|
2006-08-28 22:38:41 +00:00
|
|
|
peak_meter_playback(true);
|
|
|
|
#endif
|
|
|
|
|
2006-08-16 23:26:55 +00:00
|
|
|
#ifdef HAVE_AGC
|
|
|
|
peak_meter_get_peakhold(&peak_l, &peak_r);
|
|
|
|
#endif
|
2005-11-12 04:00:56 +00:00
|
|
|
|
2007-08-25 15:53:54 +00:00
|
|
|
pm_reset_clipcount();
|
|
|
|
pm_activate_clipcount(false);
|
2005-04-04 09:12:12 +00:00
|
|
|
settings_apply_trigger();
|
|
|
|
|
2006-08-16 23:26:55 +00:00
|
|
|
#ifdef HAVE_AGC
|
2008-08-06 20:12:44 +00:00
|
|
|
agc_preset_str[0] = str(LANG_OFF);
|
|
|
|
agc_preset_str[1] = str(LANG_AGC_SAFETY);
|
|
|
|
agc_preset_str[2] = str(LANG_AGC_LIVE);
|
|
|
|
agc_preset_str[3] = str(LANG_AGC_DJSET);
|
|
|
|
agc_preset_str[4] = str(LANG_AGC_MEDIUM);
|
|
|
|
agc_preset_str[5] = str(LANG_AGC_VOICE);
|
2007-05-20 20:26:36 +00:00
|
|
|
#endif /* HAVE_AGC */
|
2006-08-16 23:26:55 +00:00
|
|
|
|
2010-01-03 13:32:16 +00:00
|
|
|
#ifdef HAVE_SPEAKER
|
|
|
|
/* Disable speaker to prevent feedback */
|
|
|
|
audiohw_enable_speaker(false);
|
|
|
|
#endif
|
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
audio_close_recording();
|
|
|
|
#endif
|
|
|
|
audio_init_recording(0);
|
|
|
|
sound_set_volume(global_settings.volume);
|
|
|
|
|
|
|
|
#if CONFIG_RTC == 0
|
|
|
|
/* Create new filename for recording start */
|
|
|
|
rec_init_filename();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* start of the loop: we stay in this loop until user quits recscreen */
|
|
|
|
while(done <= 0)
|
2006-07-31 12:55:27 +00:00
|
|
|
{
|
2008-08-06 20:12:44 +00:00
|
|
|
if(done < 0)
|
|
|
|
{
|
|
|
|
/* request to re-init stuff, done after settings screen */
|
|
|
|
done = 0;
|
|
|
|
#ifdef HAVE_FMRADIO_REC
|
|
|
|
/* If input changes away from FM Radio,
|
|
|
|
radio will remain off when recording screen closes. */
|
|
|
|
if (global_settings.rec_source != prev_rec_source
|
|
|
|
&& prev_rec_source == AUDIO_SRC_FMRADIO)
|
|
|
|
radio_status = FMRADIO_OFF;
|
|
|
|
prev_rec_source = global_settings.rec_source;
|
2007-02-06 20:30:58 +00:00
|
|
|
#endif
|
2004-06-22 10:52:39 +00:00
|
|
|
|
2010-03-03 22:16:08 +00:00
|
|
|
/* viewport init and calculations that only needs to be done once */
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
struct viewport *v;
|
|
|
|
/* top vp, 4 lines, force sys font if total screen < 6 lines
|
|
|
|
NOTE: one could limit the list to 1 line and get away with 5 lines */
|
|
|
|
top_height_req[i] = 4;
|
|
|
|
#if defined(HAVE_RECORDING_HISTOGRAM)
|
|
|
|
if((global_settings.rec_histogram_interval) && (!i))
|
|
|
|
top_height_req[i] += 1; /* use one line for histogram */
|
|
|
|
hist_time_interval = 1 << global_settings.rec_histogram_interval;
|
|
|
|
#endif
|
|
|
|
v = &vp_top[i];
|
|
|
|
viewport_set_defaults(v, i);
|
|
|
|
if (viewport_get_nb_lines(v) < top_height_req[i])
|
|
|
|
{
|
|
|
|
/* compact needs 4 lines total */
|
|
|
|
v->font = FONT_SYSFIXED;
|
|
|
|
compact_view[i] = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*top=4,list=2*/
|
|
|
|
if (viewport_get_nb_lines(v) < (top_height_req[i]+2))
|
|
|
|
compact_view[i] = true;
|
|
|
|
else
|
|
|
|
compact_view[i] = false;
|
|
|
|
}
|
|
|
|
vp_list[i] = *v; /* get a copy now so it can be sized more easily */
|
|
|
|
v->height = (font_get(v->font)->height)*(compact_view[i] ? 3 :
|
|
|
|
top_height_req[i]);
|
|
|
|
|
|
|
|
/* list section, rest of the screen */
|
|
|
|
vp_list[i].y += vp_top[i].height;
|
|
|
|
vp_list[i].height -= vp_top[i].height;
|
|
|
|
screens[i].set_viewport(&vp_top[i]); /* req for next calls */
|
|
|
|
|
|
|
|
screens[i].getstringsize("W", &w, &h);
|
|
|
|
pm_y[i] = font_get(vp_top[i].font)->height * 2;
|
|
|
|
trig_ypos[i] = font_get(vp_top[i].font)->height * 3;
|
|
|
|
if(compact_view[i])
|
|
|
|
trig_ypos[i] -= (font_get(vp_top[i].font)->height)/2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* init the bottom list */
|
|
|
|
gui_synclist_init(&lists, reclist_get_name, NULL, false, 1, vp_list);
|
|
|
|
gui_synclist_set_title(&lists, NULL, Icon_NOICON);
|
|
|
|
|
|
|
|
send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */
|
|
|
|
|
|
|
|
#if defined(HAVE_RECORDING_HISTOGRAM)
|
|
|
|
history_pos = 0;
|
|
|
|
hist_pos_y = (compact_view[0] ? 3 : 4) * (font_get(vp_top[0].font)->height)
|
|
|
|
+ 1;
|
|
|
|
hist_size_h = font_get(vp_top[0].font)->height - 2;
|
2010-03-08 22:30:11 +00:00
|
|
|
memset(history_l, 0, sizeof(unsigned char)*HIST_BUF_SIZE);
|
|
|
|
memset(history_r, 0, sizeof(unsigned char)*HIST_BUF_SIZE);
|
2010-03-03 22:16:08 +00:00
|
|
|
#endif
|
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
pm_x[i] = 0;
|
|
|
|
if(global_settings.peak_meter_clipcounter)
|
|
|
|
{
|
|
|
|
int clipwidth = 0;
|
|
|
|
screens[i].getstringsize(str(LANG_PM_CLIPCOUNT),
|
|
|
|
&clipwidth, &h); /* h is same */
|
|
|
|
pm_x[i] = clipwidth+1;
|
|
|
|
}
|
|
|
|
if(global_settings.rec_trigger_mode == TRIG_MODE_OFF)
|
|
|
|
pm_h[i] = font_get(vp_top[i].font)->height * 2;
|
|
|
|
else
|
|
|
|
pm_h[i] = font_get(vp_top[i].font)->height;
|
2008-08-10 21:03:07 +00:00
|
|
|
if(compact_view[i])
|
|
|
|
pm_h[i] /= 2;
|
2008-08-06 20:12:44 +00:00
|
|
|
trig_width[i] = vp_top[i].width - pm_x[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
audio_close_recording();
|
|
|
|
audio_init_recording(0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rec_init_recording_options(&rec_options);
|
|
|
|
rec_set_recording_options(&rec_options);
|
|
|
|
|
|
|
|
if(rec_create_directory() < 0)
|
|
|
|
{
|
|
|
|
rec_status = 0;
|
|
|
|
goto rec_abort;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if CONFIG_CODEC == SWCODEC && CONFIG_RTC == 0
|
|
|
|
/* If format changed, a new number is required */
|
|
|
|
rec_init_filename();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_AGC
|
2008-12-31 01:38:44 +00:00
|
|
|
#ifdef HAVE_MIC_REC
|
2008-08-06 20:12:44 +00:00
|
|
|
if (global_settings.rec_source == AUDIO_SRC_MIC) {
|
|
|
|
agc_preset = global_settings.rec_agc_preset_mic;
|
|
|
|
agc_maxgain = global_settings.rec_agc_maxgain_mic;
|
|
|
|
}
|
2008-12-31 01:38:44 +00:00
|
|
|
else
|
|
|
|
#endif /* MIC */
|
|
|
|
{
|
2008-08-06 20:12:44 +00:00
|
|
|
agc_preset = global_settings.rec_agc_preset_line;
|
|
|
|
agc_maxgain = global_settings.rec_agc_maxgain_line;
|
|
|
|
}
|
2008-12-31 01:38:44 +00:00
|
|
|
#endif /* HAVE_AGC */
|
2008-08-06 20:12:44 +00:00
|
|
|
|
|
|
|
set_gain();
|
2008-08-13 21:09:10 +00:00
|
|
|
update_countdown = 0; /* Update immediately */
|
2008-08-06 20:12:44 +00:00
|
|
|
|
|
|
|
/* populate translation table for list id -> enum */
|
2008-08-20 21:38:47 +00:00
|
|
|
#ifdef HAVE_SPDIF_REC
|
|
|
|
if(global_settings.rec_source == AUDIO_SRC_SPDIF)
|
|
|
|
{
|
|
|
|
listid_to_enum[0] = ITEM_VOLUME_D;
|
2008-08-20 22:33:38 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
listid_to_enum[1] = ITEM_SAMPLERATE_D;
|
|
|
|
listid_to_enum[2] = ITEM_FILENAME_D;
|
|
|
|
#else
|
2008-08-20 21:38:47 +00:00
|
|
|
listid_to_enum[1] = ITEM_FILENAME_D;
|
2008-08-20 22:33:38 +00:00
|
|
|
#endif
|
|
|
|
|
2008-08-20 21:38:47 +00:00
|
|
|
gui_synclist_set_nb_items(&lists, ITEM_COUNT_D); /* spdif */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2008-12-31 01:38:44 +00:00
|
|
|
if(HAVE_MIC_REC_((global_settings.rec_source == AUDIO_SRC_MIC) || )
|
2008-08-20 21:38:47 +00:00
|
|
|
(global_settings.rec_channels == 1))
|
2008-08-06 20:12:44 +00:00
|
|
|
{
|
|
|
|
listid_to_enum[0] = ITEM_VOLUME_M;
|
|
|
|
listid_to_enum[1] = ITEM_GAIN_M;
|
|
|
|
#ifdef HAVE_AGC
|
|
|
|
listid_to_enum[2] = ITEM_AGC_MODE_M;
|
|
|
|
listid_to_enum[3] = ITEM_AGC_MAXDB_M;
|
|
|
|
listid_to_enum[4] = ITEM_FILENAME_M;
|
|
|
|
#else
|
|
|
|
listid_to_enum[2] = ITEM_FILENAME_M;
|
|
|
|
#endif
|
2008-08-20 21:38:47 +00:00
|
|
|
gui_synclist_set_nb_items(&lists, ITEM_COUNT_M); /* mono */
|
2008-08-06 20:12:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
listid_to_enum[0] = ITEM_VOLUME;
|
|
|
|
listid_to_enum[1] = ITEM_GAIN;
|
|
|
|
listid_to_enum[2] = ITEM_GAIN_L;
|
|
|
|
listid_to_enum[3] = ITEM_GAIN_R;
|
|
|
|
#ifdef HAVE_AGC
|
|
|
|
listid_to_enum[4] = ITEM_AGC_MODE;
|
|
|
|
listid_to_enum[5] = ITEM_AGC_MAXDB;
|
|
|
|
listid_to_enum[6] = ITEM_FILENAME;
|
|
|
|
#else
|
|
|
|
listid_to_enum[4] = ITEM_FILENAME;
|
|
|
|
#endif
|
2008-08-20 21:38:47 +00:00
|
|
|
gui_synclist_set_nb_items(&lists, ITEM_COUNT); /* stereo */
|
2008-08-06 20:12:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gui_synclist_draw(&lists);
|
|
|
|
} /* if(done < 0) */
|
|
|
|
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_stat = audio_status();
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2007-02-18 05:07:19 +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
|
|
|
|
{
|
2008-08-07 11:48:56 +00:00
|
|
|
int trig_stat = 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.
|
|
|
|
*/
|
2008-08-07 11:48:56 +00:00
|
|
|
if (trig_stat == 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 */
|
2008-05-28 10:55:39 +00:00
|
|
|
button = peak_meter_draw_get_btn(CONTEXT_RECSCREEN,
|
2008-08-06 20:12:44 +00:00
|
|
|
pm_x, pm_y, pm_h,
|
2009-02-02 03:14:51 +00:00
|
|
|
screen_update, vp_top);
|
2005-04-04 12:06:29 +00:00
|
|
|
if (last_audio_stat != audio_stat)
|
2005-04-04 09:12:12 +00:00
|
|
|
{
|
2007-06-22 09:34:57 +00:00
|
|
|
if (audio_stat & AUDIO_STATUS_RECORD)
|
2005-04-04 09:12:12 +00:00
|
|
|
{
|
2007-06-22 09:34:57 +00:00
|
|
|
rec_status |= RCSTAT_HAVE_RECORDED;
|
2005-04-04 09:12:12 +00:00
|
|
|
}
|
2005-04-04 12:06:29 +00:00
|
|
|
last_audio_stat = audio_stat;
|
2008-08-06 20:12:44 +00:00
|
|
|
update_list = true;
|
2005-04-04 09:12:12 +00:00
|
|
|
}
|
|
|
|
|
2007-03-07 01:59:29 +00:00
|
|
|
if (recording_start_automatic)
|
|
|
|
{
|
|
|
|
/* simulate a button press */
|
|
|
|
button = ACTION_REC_PAUSE;
|
|
|
|
recording_start_automatic = false;
|
|
|
|
}
|
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
/* let list handle the button */
|
|
|
|
gui_synclist_do_button(&lists, &button, LIST_WRAP_UNLESS_HELD);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
switch(button)
|
|
|
|
{
|
2006-08-20 21:33:40 +00:00
|
|
|
case ACTION_SETTINGS_INC:
|
2007-11-26 11:51:39 +00:00
|
|
|
case ACTION_SETTINGS_INCREPEAT:
|
2008-08-06 20:12:44 +00:00
|
|
|
switch (listid_to_enum[gui_synclist_get_sel_pos(&lists)])
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
2008-08-06 20:12:44 +00:00
|
|
|
case ITEM_VOLUME:
|
2007-05-30 17:57:32 +00:00
|
|
|
global_settings.volume++;
|
|
|
|
setvol();
|
2005-11-13 15:16:27 +00:00
|
|
|
break;
|
2008-08-06 20:12:44 +00:00
|
|
|
case ITEM_GAIN:
|
2008-12-31 01:38:44 +00:00
|
|
|
#ifdef HAVE_MIC_REC
|
2006-08-28 22:38:41 +00:00
|
|
|
if(global_settings.rec_source == AUDIO_SRC_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))
|
2008-08-06 20:12:44 +00:00
|
|
|
global_settings.rec_mic_gain++;
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
else
|
2008-12-31 01:38:44 +00:00
|
|
|
#endif /* MIC */
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
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;
|
2008-08-06 20:12:44 +00:00
|
|
|
case ITEM_GAIN_L:
|
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;
|
2008-08-06 20:12:44 +00:00
|
|
|
case ITEM_GAIN_R:
|
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-08-16 23:26:55 +00:00
|
|
|
#ifdef HAVE_AGC
|
2008-08-06 20:12:44 +00:00
|
|
|
case ITEM_AGC_MODE:
|
2006-08-16 23:26:55 +00:00
|
|
|
agc_preset = MIN(agc_preset + 1, AGC_MODE_SIZE);
|
|
|
|
agc_enable = (agc_preset != 0);
|
2008-12-31 01:38:44 +00:00
|
|
|
#ifdef HAVE_MIC_REC
|
2006-08-28 22:38:41 +00:00
|
|
|
if (global_settings.rec_source == AUDIO_SRC_MIC) {
|
2006-08-16 23:26:55 +00:00
|
|
|
global_settings.rec_agc_preset_mic = agc_preset;
|
|
|
|
agc_maxgain = global_settings.rec_agc_maxgain_mic;
|
2008-12-31 01:38:44 +00:00
|
|
|
} else
|
|
|
|
#endif /* MIC */
|
|
|
|
{
|
2006-08-16 23:26:55 +00:00
|
|
|
global_settings.rec_agc_preset_line = agc_preset;
|
|
|
|
agc_maxgain = global_settings.rec_agc_maxgain_line;
|
|
|
|
}
|
|
|
|
break;
|
2008-08-06 20:12:44 +00:00
|
|
|
case ITEM_AGC_MAXDB:
|
2008-12-31 01:38:44 +00:00
|
|
|
#ifdef HAVE_MIC_REC
|
2006-08-28 22:38:41 +00:00
|
|
|
if (global_settings.rec_source == AUDIO_SRC_MIC)
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
|
|
|
agc_maxgain = MIN(agc_maxgain + 1,
|
|
|
|
sound_max(SOUND_MIC_GAIN));
|
|
|
|
global_settings.rec_agc_maxgain_mic = agc_maxgain;
|
|
|
|
}
|
|
|
|
else
|
2008-12-31 01:38:44 +00:00
|
|
|
#endif /* MIC */
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
|
|
|
agc_maxgain = MIN(agc_maxgain + 1,
|
|
|
|
sound_max(SOUND_LEFT_GAIN));
|
|
|
|
global_settings.rec_agc_maxgain_line = agc_maxgain;
|
|
|
|
}
|
|
|
|
break;
|
2007-05-20 20:26:36 +00:00
|
|
|
#endif /* HAVE_AGC */
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
|
|
|
set_gain();
|
2008-08-13 21:09:10 +00:00
|
|
|
update_countdown = 0; /* Update immediately */
|
2002-11-10 16:42:31 +00:00
|
|
|
break;
|
2006-08-20 21:33:40 +00:00
|
|
|
case ACTION_SETTINGS_DEC:
|
2007-11-26 11:51:39 +00:00
|
|
|
case ACTION_SETTINGS_DECREPEAT:
|
2008-08-06 20:12:44 +00:00
|
|
|
switch (listid_to_enum[gui_synclist_get_sel_pos(&lists)])
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
2008-08-06 20:12:44 +00:00
|
|
|
case ITEM_VOLUME:
|
2007-05-30 17:57:32 +00:00
|
|
|
global_settings.volume--;
|
|
|
|
setvol();
|
2005-11-13 15:16:27 +00:00
|
|
|
break;
|
2008-08-06 20:12:44 +00:00
|
|
|
case ITEM_GAIN:
|
2008-12-31 01:38:44 +00:00
|
|
|
#ifdef HAVE_MIC_REC
|
2006-08-28 22:38:41 +00:00
|
|
|
if(global_settings.rec_source == AUDIO_SRC_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
|
2008-12-31 01:38:44 +00:00
|
|
|
#endif /* MIC */
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
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;
|
2008-08-06 20:12:44 +00:00
|
|
|
case ITEM_GAIN_L:
|
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;
|
2008-08-06 20:12:44 +00:00
|
|
|
case ITEM_GAIN_R:
|
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-08-16 23:26:55 +00:00
|
|
|
#ifdef HAVE_AGC
|
2008-08-06 20:12:44 +00:00
|
|
|
case ITEM_AGC_MODE:
|
2006-08-16 23:26:55 +00:00
|
|
|
agc_preset = MAX(agc_preset - 1, 0);
|
|
|
|
agc_enable = (agc_preset != 0);
|
2008-12-31 01:38:44 +00:00
|
|
|
#ifdef HAVE_MIC_REC
|
2006-08-28 22:38:41 +00:00
|
|
|
if (global_settings.rec_source == AUDIO_SRC_MIC) {
|
2006-08-16 23:26:55 +00:00
|
|
|
global_settings.rec_agc_preset_mic = agc_preset;
|
|
|
|
agc_maxgain = global_settings.rec_agc_maxgain_mic;
|
2008-12-31 01:38:44 +00:00
|
|
|
} else
|
|
|
|
#endif /* MIC */
|
|
|
|
{
|
2006-08-16 23:26:55 +00:00
|
|
|
global_settings.rec_agc_preset_line = agc_preset;
|
|
|
|
agc_maxgain = global_settings.rec_agc_maxgain_line;
|
|
|
|
}
|
|
|
|
break;
|
2008-08-06 20:12:44 +00:00
|
|
|
case ITEM_AGC_MAXDB:
|
2008-12-31 01:38:44 +00:00
|
|
|
#ifdef HAVE_MIC_REC
|
2006-08-28 22:38:41 +00:00
|
|
|
if (global_settings.rec_source == AUDIO_SRC_MIC)
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
|
|
|
agc_maxgain = MAX(agc_maxgain - 1,
|
|
|
|
sound_min(SOUND_MIC_GAIN));
|
|
|
|
global_settings.rec_agc_maxgain_mic = agc_maxgain;
|
2008-12-31 01:38:44 +00:00
|
|
|
} else
|
|
|
|
#endif /* MIC */
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
|
|
|
agc_maxgain = MAX(agc_maxgain - 1,
|
|
|
|
sound_min(SOUND_LEFT_GAIN));
|
|
|
|
global_settings.rec_agc_maxgain_line = agc_maxgain;
|
|
|
|
}
|
|
|
|
break;
|
2007-05-20 20:26:36 +00:00
|
|
|
#endif /* HAVE_AGC */
|
2005-11-13 15:16:27 +00:00
|
|
|
}
|
2002-11-10 16:42:31 +00:00
|
|
|
set_gain();
|
2008-08-13 21:09:10 +00:00
|
|
|
update_countdown = 0; /* Update immediately */
|
2002-11-10 16:42:31 +00:00
|
|
|
break;
|
2008-08-06 20:12:44 +00:00
|
|
|
case ACTION_STD_CANCEL:
|
|
|
|
/* turn off the trigger */
|
|
|
|
peak_meter_trigger(false);
|
|
|
|
peak_meter_set_trigger_listener(NULL);
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
if(audio_stat & AUDIO_STATUS_RECORD)
|
|
|
|
{
|
|
|
|
rec_command(RECORDING_CMD_STOP);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#if CONFIG_CODEC != SWCODEC
|
|
|
|
peak_meter_playback(true);
|
2010-05-09 13:01:59 +00:00
|
|
|
peak_meter_enable(false);
|
2008-08-06 20:12:44 +00:00
|
|
|
#endif
|
|
|
|
done = 1;
|
|
|
|
}
|
2008-08-13 21:09:10 +00:00
|
|
|
update_countdown = 0; /* Update immediately */
|
2008-08-06 20:12:44 +00:00
|
|
|
break;
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
case ACTION_REC_LCD:
|
|
|
|
/* this feature exists for some h1x0/h3x0 targets that suffer
|
|
|
|
from noise caused by remote LCD updates
|
|
|
|
NOTE 1: this will leave the list on the remote
|
|
|
|
NOTE 2: to be replaced by a global LCD_off() routine */
|
|
|
|
if(remote_display_on)
|
|
|
|
{
|
2008-08-15 08:40:34 +00:00
|
|
|
/* switch to single screen, leave message on remote */
|
2008-08-06 20:12:44 +00:00
|
|
|
screen_update = 1;
|
|
|
|
screens[1].clear_viewport();
|
|
|
|
screens[1].puts(0, 0, str(LANG_REMOTE_LCD_OFF));
|
|
|
|
screens[1].puts(0, 1, str(LANG_REMOTE_LCD_ON));
|
|
|
|
screens[1].update_viewport();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* remote switched on again */
|
|
|
|
update_list = true;
|
|
|
|
screen_update = NB_SCREENS;
|
|
|
|
}
|
|
|
|
remote_display_on = !remote_display_on; /* toggle */
|
2008-08-13 21:09:10 +00:00
|
|
|
update_countdown = 0; /* Update immediately */
|
2008-08-06 20:12:44 +00:00
|
|
|
break;
|
|
|
|
#endif
|
2009-10-29 23:07:26 +00:00
|
|
|
case ACTION_REC_PAUSE:
|
2008-08-06 20:12:44 +00:00
|
|
|
case ACTION_REC_NEWFILE:
|
2009-10-29 23:07:26 +00:00
|
|
|
/* Only act if the mpeg is stopped */
|
|
|
|
if(!(audio_stat & AUDIO_STATUS_RECORD))
|
2008-08-06 20:12:44 +00:00
|
|
|
{
|
|
|
|
/* is this manual or triggered recording? */
|
|
|
|
if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
|
|
|
|
(peak_meter_trigger_status() != TRIG_OFF))
|
|
|
|
{
|
|
|
|
/* manual recording */
|
|
|
|
rec_status |= RCSTAT_HAVE_RECORDED;
|
|
|
|
rec_command(RECORDING_CMD_START);
|
|
|
|
last_seconds = 0;
|
|
|
|
if (global_settings.talk_menu)
|
|
|
|
{
|
|
|
|
/* no voice possible here, but a beep */
|
|
|
|
audio_beep(HZ/2); /* longer beep on start */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* this is triggered recording */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
}
|
2009-10-29 23:07:26 +00:00
|
|
|
else
|
2008-08-06 20:12:44 +00:00
|
|
|
{
|
2009-10-29 23:07:26 +00:00
|
|
|
/*if new file button pressed, start new file */
|
|
|
|
if (button == ACTION_REC_NEWFILE)
|
2008-08-06 20:12:44 +00:00
|
|
|
{
|
2009-10-29 23:07:26 +00:00
|
|
|
rec_command(RECORDING_CMD_START_NEWFILE);
|
|
|
|
last_seconds = 0;
|
2008-08-06 20:12:44 +00:00
|
|
|
}
|
|
|
|
else
|
2009-10-29 23:07:26 +00:00
|
|
|
/* if pause button pressed, pause or resume */
|
2008-08-06 20:12:44 +00:00
|
|
|
{
|
2009-10-29 23:07:26 +00:00
|
|
|
if(audio_stat & AUDIO_STATUS_PAUSE)
|
|
|
|
{
|
|
|
|
rec_command(RECORDING_CMD_RESUME);
|
|
|
|
if (global_settings.talk_menu)
|
|
|
|
{
|
|
|
|
/* no voice possible here, but a beep */
|
|
|
|
audio_beep(HZ/4); /* short beep on resume */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rec_command(RECORDING_CMD_PAUSE);
|
|
|
|
}
|
2008-08-06 20:12:44 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-13 21:09:10 +00:00
|
|
|
update_countdown = 0; /* Update immediately */
|
2008-08-06 20:12:44 +00:00
|
|
|
break;
|
2006-08-20 21:33:40 +00:00
|
|
|
case ACTION_STD_MENU:
|
2007-06-22 09:34:57 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
if(!(audio_stat & AUDIO_STATUS_RECORD))
|
|
|
|
#else
|
2008-08-06 20:12:44 +00:00
|
|
|
if(audio_stat != AUDIO_STATUS_RECORD)
|
2007-06-22 09:34:57 +00:00
|
|
|
#endif
|
2004-10-24 22:30:55 +00:00
|
|
|
{
|
2007-02-18 05:07:19 +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
|
2006-08-28 22:38:41 +00:00
|
|
|
if (recording_menu(no_source))
|
2005-04-04 09:12:12 +00:00
|
|
|
{
|
2008-08-06 20:12:44 +00:00
|
|
|
done = 1;
|
2007-06-22 09:34:57 +00:00
|
|
|
rec_status |= RCSTAT_BEEN_IN_USB_MODE;
|
2007-05-20 20:26:36 +00:00
|
|
|
#ifdef HAVE_FMRADIO_REC
|
2006-08-28 22:38:41 +00:00
|
|
|
radio_status = FMRADIO_OFF;
|
|
|
|
#endif
|
2005-04-04 09:12:12 +00:00
|
|
|
}
|
2006-08-28 22:38:41 +00:00
|
|
|
else
|
|
|
|
{
|
2008-08-06 20:12:44 +00:00
|
|
|
done = -1;
|
|
|
|
/* the init is now done at the beginning of the loop */
|
2006-03-25 13:35:31 +00:00
|
|
|
}
|
2004-10-24 22:30:55 +00:00
|
|
|
}
|
2002-11-10 23:18:33 +00:00
|
|
|
break;
|
2006-08-28 22:38:41 +00:00
|
|
|
|
2006-08-20 21:33:40 +00:00
|
|
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
|
|
|
case ACTION_REC_F2:
|
2005-04-04 12:06:29 +00:00
|
|
|
if(audio_stat != AUDIO_STATUS_RECORD)
|
2003-04-20 22:00:30 +00:00
|
|
|
{
|
2007-02-18 05:07:19 +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
|
|
|
{
|
2007-06-22 09:34:57 +00:00
|
|
|
rec_status |= RCSTAT_HAVE_RECORDED;
|
2003-11-20 00:33:43 +00:00
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
else
|
2008-08-13 21:09:10 +00:00
|
|
|
update_countdown = 0; /* Update immediately */
|
2003-04-20 22:00:30 +00:00
|
|
|
}
|
2002-11-10 16:42:31 +00:00
|
|
|
break;
|
|
|
|
|
2006-08-20 21:33:40 +00:00
|
|
|
case ACTION_REC_F3:
|
2005-04-04 12:06:29 +00:00
|
|
|
if(audio_stat & AUDIO_STATUS_RECORD)
|
2003-04-20 22:00:30 +00:00
|
|
|
{
|
2007-08-25 15:53:54 +00:00
|
|
|
rec_command(RECORDING_CMD_START_NEWFILE);
|
2004-06-03 12:10:40 +00:00
|
|
|
last_seconds = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-02-18 05:07:19 +00:00
|
|
|
#if (CONFIG_LED == LED_REAL)
|
2007-06-22 09:34:57 +00:00
|
|
|
/* led is restored at begin of loop / end of function */
|
|
|
|
led(false);
|
2005-05-01 20:10:39 +00:00
|
|
|
#endif
|
2007-06-22 09:34:57 +00:00
|
|
|
if (f3_rec_screen())
|
|
|
|
{
|
|
|
|
rec_status |= RCSTAT_HAVE_RECORDED;
|
|
|
|
done = true;
|
2003-11-20 00:33:43 +00:00
|
|
|
}
|
2007-06-22 09:34:57 +00:00
|
|
|
else
|
2008-08-13 21:09:10 +00:00
|
|
|
update_countdown = 0; /* Update immediately */
|
2003-04-20 22:00:30 +00:00
|
|
|
}
|
2002-11-10 16:42:31 +00:00
|
|
|
break;
|
2006-08-28 22:38:41 +00:00
|
|
|
#endif /* CONFIG_KEYPAD == RECORDER_PAD */
|
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 */
|
2007-06-22 09:34:57 +00:00
|
|
|
if(!(audio_stat & AUDIO_STATUS_RECORD))
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
2008-08-06 20:12:44 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
screens[i].set_viewport(NULL);
|
2004-07-26 16:06:59 +00:00
|
|
|
default_event_handler(SYS_USB_CONNECTED);
|
2003-11-20 00:33:43 +00:00
|
|
|
done = true;
|
2007-06-22 09:34:57 +00:00
|
|
|
rec_status |= RCSTAT_BEEN_IN_USB_MODE;
|
2007-05-20 20:26:36 +00:00
|
|
|
#ifdef HAVE_FMRADIO_REC
|
2006-08-28 22:38:41 +00:00
|
|
|
radio_status = FMRADIO_OFF;
|
|
|
|
#endif
|
2003-11-20 00:33:43 +00:00
|
|
|
}
|
|
|
|
break;
|
2008-08-06 20:12:44 +00:00
|
|
|
} /*switch(button)*/
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2006-08-16 23:26:55 +00:00
|
|
|
#ifdef HAVE_AGC
|
|
|
|
peak_read = !peak_read;
|
|
|
|
if (peak_read) { /* every 2nd run of loop */
|
|
|
|
peak_time++;
|
|
|
|
peak_valid = read_peak_levels(&peak_l, &peak_r, &balance);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle AGC every 200ms when enabled and peak data is valid */
|
|
|
|
if (peak_read && agc_enable && peak_valid)
|
|
|
|
auto_gain_control(&peak_l, &peak_r, &balance);
|
|
|
|
#endif
|
|
|
|
|
2005-11-12 04:00:56 +00:00
|
|
|
seconds = audio_recorded_time() / HZ;
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
/* start of vp_top drawing */
|
|
|
|
if(update_countdown-- == 0 || seconds > last_seconds)
|
2005-06-04 10:19:45 +00:00
|
|
|
{
|
|
|
|
unsigned int dseconds, dhours, dminutes;
|
2006-07-22 17:23:05 +00:00
|
|
|
unsigned long num_recorded_bytes, dsize, dmb;
|
2008-08-06 20:12:44 +00:00
|
|
|
|
2009-02-02 03:14:51 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
screens[i].set_viewport(&vp_top[i]);
|
2008-08-06 20:12:44 +00:00
|
|
|
screens[i].clear_viewport();
|
2010-03-03 22:16:08 +00:00
|
|
|
}
|
2005-06-04 10:19:45 +00:00
|
|
|
update_countdown = 5;
|
|
|
|
last_seconds = seconds;
|
2002-11-19 21:07:44 +00:00
|
|
|
|
2006-07-22 17:23:05 +00:00
|
|
|
dseconds = rec_timesplit_seconds();
|
|
|
|
dsize = rec_sizesplit_bytes();
|
|
|
|
num_recorded_bytes = audio_num_recorded_bytes();
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2006-12-10 14:21:31 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
if ((audio_stat & AUDIO_STATUS_WARNING)
|
|
|
|
&& (warning_counter++ % WARNING_PERIOD) < WARNING_PERIOD/2)
|
|
|
|
{
|
|
|
|
/* Switch back and forth displaying warning on first available
|
|
|
|
line to ensure visibility - the motion should also help
|
|
|
|
draw attention */
|
|
|
|
/* Don't use language string unless agreed upon to make this
|
|
|
|
method permanent - could do something in the statusbar */
|
2010-05-06 21:04:40 +00:00
|
|
|
snprintf(buf, sizeof(buf), "Warning: %08lX",
|
2006-12-10 14:21:31 +00:00
|
|
|
pcm_rec_get_warnings());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif /* CONFIG_CODEC == SWCODEC */
|
2007-12-07 00:28:16 +00:00
|
|
|
if ((global_settings.rec_sizesplit) &&
|
|
|
|
(global_settings.rec_split_method))
|
2006-07-22 17:23:05 +00:00
|
|
|
{
|
|
|
|
dmb = dsize/1024/1024;
|
2010-05-06 21:04:40 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%s %luMB",
|
2008-08-06 20:12:44 +00:00
|
|
|
str(LANG_SPLIT_SIZE), dmb);
|
2006-07-22 17:23:05 +00:00
|
|
|
}
|
2007-04-15 22:16:28 +00:00
|
|
|
else
|
2006-07-22 17:23:05 +00:00
|
|
|
{
|
|
|
|
hours = seconds / 3600;
|
|
|
|
minutes = (seconds - (hours * 3600)) / 60;
|
2006-09-09 14:53:30 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%s %02d:%02d:%02d",
|
2008-08-06 20:12:44 +00:00
|
|
|
str(LANG_RECORDING_TIME),
|
|
|
|
hours, minutes, seconds%60);
|
2006-07-22 17:23:05 +00:00
|
|
|
}
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
FOR_NB_ACTIVE_SCREENS(i)
|
2007-12-07 00:28:16 +00:00
|
|
|
screens[i].puts(0, 0, buf);
|
2003-06-04 13:48:50 +00:00
|
|
|
|
2005-06-04 10:19:45 +00:00
|
|
|
if(audio_stat & AUDIO_STATUS_PRERECORD)
|
|
|
|
{
|
2007-12-07 00:28:16 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%s...",
|
2008-08-06 20:12:44 +00:00
|
|
|
str(LANG_RECORD_PRERECORD));
|
2005-06-04 10:19:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Display the split interval if the record timesplit
|
|
|
|
is active */
|
2007-12-07 00:28:16 +00:00
|
|
|
if ((global_settings.rec_timesplit) &&
|
2008-08-06 20:12:44 +00:00
|
|
|
!(global_settings.rec_split_method))
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
2005-06-04 10:19:45 +00:00
|
|
|
/* Display the record timesplit interval rather
|
2008-08-06 20:12:44 +00:00
|
|
|
than the file size if the record timer is active */
|
2005-06-04 10:19:45 +00:00
|
|
|
dhours = dseconds / 3600;
|
|
|
|
dminutes = (dseconds - (dhours * 3600)) / 60;
|
2006-09-09 14:53:30 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%s %02d:%02d",
|
2008-08-06 20:12:44 +00:00
|
|
|
str(LANG_RECORDING_TIMESPLIT_REC),
|
|
|
|
dhours, dminutes);
|
2003-06-04 13:48:50 +00:00
|
|
|
}
|
2007-04-15 22:16:28 +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);
|
2006-09-09 14:53:30 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%s %s",
|
2008-08-06 20:12:44 +00:00
|
|
|
str(LANG_RECORDING_SIZE), buf2);
|
2003-12-31 03:13:29 +00:00
|
|
|
}
|
2005-06-04 10:19:45 +00:00
|
|
|
}
|
2006-07-20 22:44:10 +00:00
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
FOR_NB_ACTIVE_SCREENS(i)
|
|
|
|
screens[i].puts(0, 1, buf);
|
2006-07-20 22:44:10 +00:00
|
|
|
|
2005-09-11 17:57:31 +00:00
|
|
|
/* We will do file splitting regardless, either at the end of
|
2008-08-06 20:12:44 +00:00
|
|
|
a split interval, or when the filesize approaches the 2GB
|
|
|
|
FAT file size (compatibility) limit. */
|
2007-12-07 00:28:16 +00:00
|
|
|
if ((audio_stat && !(global_settings.rec_split_method)
|
2006-07-22 17:23:05 +00:00
|
|
|
&& global_settings.rec_timesplit && (seconds >= dseconds))
|
2008-08-06 20:12:44 +00:00
|
|
|
|| (audio_stat && global_settings.rec_split_method
|
2007-12-07 00:28:16 +00:00
|
|
|
&& global_settings.rec_sizesplit
|
|
|
|
&& (num_recorded_bytes >= dsize))
|
2008-08-06 20:12:44 +00:00
|
|
|
|| (num_recorded_bytes >= MAX_FILE_SIZE))
|
2005-06-04 10:19:45 +00:00
|
|
|
{
|
2006-07-22 17:23:05 +00:00
|
|
|
if (!(global_settings.rec_split_type)
|
2008-08-06 20:12:44 +00:00
|
|
|
|| (num_recorded_bytes >= MAX_FILE_SIZE))
|
2006-07-22 17:23:05 +00:00
|
|
|
{
|
2007-08-25 15:53:54 +00:00
|
|
|
rec_command(RECORDING_CMD_START_NEWFILE);
|
2006-07-22 17:23:05 +00:00
|
|
|
last_seconds = 0;
|
|
|
|
}
|
2007-04-15 22:16:28 +00:00
|
|
|
else
|
2006-07-22 17:23:05 +00:00
|
|
|
{
|
|
|
|
peak_meter_trigger(false);
|
|
|
|
peak_meter_set_trigger_listener(NULL);
|
2008-05-15 22:47:07 +00:00
|
|
|
if( global_settings.rec_split_type == 1)
|
|
|
|
rec_command(RECORDING_CMD_STOP);
|
|
|
|
else
|
|
|
|
rec_command(RECORDING_CMD_STOP_SHUTDOWN);
|
2006-07-22 17:23:05 +00:00
|
|
|
}
|
2008-08-13 21:09:10 +00:00
|
|
|
update_countdown = 0;
|
2005-06-04 10:19:45 +00:00
|
|
|
}
|
2003-11-20 00:33:43 +00:00
|
|
|
|
2007-08-25 15:53:54 +00:00
|
|
|
/* draw the clipcounter just in front of the peakmeter */
|
|
|
|
if(global_settings.peak_meter_clipcounter)
|
|
|
|
{
|
2009-10-17 18:02:48 +00:00
|
|
|
int clipcount = pm_get_clipcount();
|
2008-08-06 20:12:44 +00:00
|
|
|
FOR_NB_ACTIVE_SCREENS(i)
|
2007-08-25 15:53:54 +00:00
|
|
|
{
|
2008-08-11 18:32:10 +00:00
|
|
|
if(!compact_view[i])
|
2009-10-17 18:02:48 +00:00
|
|
|
{
|
|
|
|
screens[i].puts(0, 2, str(LANG_PM_CLIPCOUNT));
|
|
|
|
screens[i].putsf(0, 3, "%4d", clipcount);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
screens[i].putsf(0, 2, "%4d", clipcount);
|
2007-08-25 15:53:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-03 22:16:08 +00:00
|
|
|
#ifdef HAVE_RECORDING_HISTOGRAM
|
|
|
|
if(global_settings.rec_histogram_interval)
|
|
|
|
{
|
|
|
|
if (peak_valid && !(hist_time % hist_time_interval) && hist_l)
|
|
|
|
{
|
2010-03-08 22:30:11 +00:00
|
|
|
/* fill history buffer */
|
2010-03-03 22:16:08 +00:00
|
|
|
history_l[history_pos] = hist_l * hist_size_h / 32767;
|
|
|
|
history_r[history_pos] = hist_r * hist_size_h / 32767;
|
2010-03-08 22:30:11 +00:00
|
|
|
history_pos = (history_pos + 1) % HIST_BUF_SIZE;
|
2010-03-03 22:16:08 +00:00
|
|
|
history_l[history_pos] = history_r[history_pos] = 0;
|
2010-03-08 22:30:11 +00:00
|
|
|
history_l[(history_pos + 1) % HIST_BUF_SIZE] = 0;
|
|
|
|
history_r[(history_pos + 1) % HIST_BUF_SIZE] = 0;
|
2010-03-03 22:16:08 +00:00
|
|
|
hist_l = 0;
|
|
|
|
hist_r = 0;
|
|
|
|
}
|
|
|
|
lcd_set_drawmode(DRMODE_SOLID);
|
|
|
|
lcd_drawrect(0, hist_pos_y - 1,
|
|
|
|
HIST_W + 2, hist_size_h + 1);
|
|
|
|
lcd_drawrect(HIST_W + 6, hist_pos_y - 1,
|
|
|
|
HIST_W + 2, hist_size_h + 1);
|
|
|
|
lcd_set_drawmode(DRMODE_FG);
|
2010-03-08 22:30:11 +00:00
|
|
|
|
|
|
|
j = history_pos;
|
|
|
|
for (i = HIST_W-1; i >= 0; i--)
|
2010-03-03 22:16:08 +00:00
|
|
|
{
|
2010-03-08 22:30:11 +00:00
|
|
|
j--;
|
|
|
|
if(j<0)
|
|
|
|
j = HIST_BUF_SIZE-1;
|
|
|
|
if (history_l[j])
|
2010-03-03 22:16:08 +00:00
|
|
|
{
|
2010-03-08 22:30:11 +00:00
|
|
|
if (history_l[j] == hist_size_h)
|
2010-03-03 22:16:08 +00:00
|
|
|
lcd_set_foreground(LCD_HIST_OVER);
|
2010-03-08 22:30:11 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
else if (history_l[j] > hist_level_marks[1])
|
2010-03-03 22:16:08 +00:00
|
|
|
lcd_set_foreground(LCD_HIST_HI);
|
2010-03-08 22:30:11 +00:00
|
|
|
#endif
|
2010-03-03 22:16:08 +00:00
|
|
|
else
|
|
|
|
lcd_set_foreground(LCD_HIST_OK);
|
2010-03-08 22:30:11 +00:00
|
|
|
lcd_vline(1 + i, HIST_Y-1, HIST_Y - history_l[j]);
|
2010-03-03 22:16:08 +00:00
|
|
|
}
|
2010-03-08 22:30:11 +00:00
|
|
|
if (history_r[j])
|
2010-03-03 22:16:08 +00:00
|
|
|
{
|
2010-03-08 22:30:11 +00:00
|
|
|
if (history_r[j] == hist_size_h)
|
2010-03-03 22:16:08 +00:00
|
|
|
lcd_set_foreground(LCD_HIST_OVER);
|
2010-03-08 22:30:11 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
else if (history_r[j] > hist_level_marks[1])
|
2010-03-03 22:16:08 +00:00
|
|
|
lcd_set_foreground(LCD_HIST_HI);
|
2010-03-08 22:30:11 +00:00
|
|
|
#endif
|
2010-03-03 22:16:08 +00:00
|
|
|
else
|
|
|
|
lcd_set_foreground(LCD_HIST_OK);
|
2010-03-08 22:30:11 +00:00
|
|
|
lcd_vline(HIST_W+7 + i, HIST_Y-1, HIST_Y - history_r[j]);
|
2010-03-03 22:16:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
lcd_set_foreground(
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
global_settings.fg_color);
|
|
|
|
#else
|
|
|
|
LCD_DEFAULT_FG);
|
|
|
|
#endif
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
lcd_hline(HIST_W + 3, HIST_W + 4,
|
|
|
|
HIST_Y - hist_level_marks[i]);
|
|
|
|
}
|
|
|
|
#endif /* HAVE_RECORDING_HISTOGRAM */
|
|
|
|
|
2006-08-16 23:26:55 +00:00
|
|
|
#ifdef HAVE_AGC
|
2008-08-06 20:12:44 +00:00
|
|
|
hist_time++;
|
|
|
|
#endif
|
2006-07-20 22:44:10 +00:00
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
/* draw the trigger status */
|
|
|
|
if (peak_meter_trigger_status() != TRIG_OFF)
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
2008-08-06 20:12:44 +00:00
|
|
|
peak_meter_draw_trig(pm_x, trig_ypos, trig_width,
|
|
|
|
screen_update);
|
|
|
|
FOR_NB_ACTIVE_SCREENS(i)
|
|
|
|
screens[i].update_viewport_rect(pm_x[i], trig_ypos[i],
|
|
|
|
trig_width[i] + 2, TRIG_HEIGHT);
|
2006-08-16 23:26:55 +00:00
|
|
|
}
|
2007-05-20 20:26:36 +00:00
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
#ifdef HAVE_AGC
|
2008-12-31 01:38:44 +00:00
|
|
|
#ifdef HAVE_MIC_REC
|
2006-08-28 22:38:41 +00:00
|
|
|
if (global_settings.rec_source == AUDIO_SRC_MIC)
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
|
|
|
if(agc_maxgain < (global_settings.rec_mic_gain))
|
|
|
|
change_recording_gain(false, true, true);
|
|
|
|
}
|
|
|
|
else
|
2008-12-31 01:38:44 +00:00
|
|
|
#endif /* MIC */
|
2006-08-16 23:26:55 +00:00
|
|
|
{
|
|
|
|
if(agc_maxgain < (global_settings.rec_left_gain))
|
|
|
|
change_recording_gain(false, true, false);
|
|
|
|
if(agc_maxgain < (global_settings.rec_right_gain))
|
|
|
|
change_recording_gain(false, false, true);
|
|
|
|
}
|
|
|
|
#endif /* HAVE_AGC */
|
2005-04-04 09:12:12 +00:00
|
|
|
|
2008-08-20 22:33:38 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
#ifdef HAVE_SPDIF_REC
|
|
|
|
if((global_settings.rec_source == AUDIO_SRC_SPDIF) &&
|
|
|
|
(prev_sample_rate != pcm_rec_sample_rate()))
|
|
|
|
{
|
|
|
|
/* spdif samplerate changed */
|
|
|
|
prev_sample_rate = pcm_rec_sample_rate();
|
|
|
|
update_list = true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
if(update_list)
|
|
|
|
{
|
|
|
|
/* update_list is set whenever content changes */
|
|
|
|
update_list = false;
|
|
|
|
gui_synclist_draw(&lists);
|
2006-03-25 13:35:31 +00:00
|
|
|
}
|
2006-08-16 23:26:55 +00:00
|
|
|
|
2008-08-06 20:12:44 +00:00
|
|
|
/* draw peakmeter again (check if this can be removed) */
|
|
|
|
FOR_NB_ACTIVE_SCREENS(i)
|
2006-03-25 13:35:31 +00:00
|
|
|
{
|
2008-08-06 20:12:44 +00:00
|
|
|
screens[i].set_viewport(&vp_top[i]);
|
|
|
|
peak_meter_screen(&screens[i], pm_x[i], pm_y[i], pm_h[i]);
|
2007-12-07 00:28:16 +00:00
|
|
|
screens[i].update();
|
2006-03-25 13:35:31 +00:00
|
|
|
}
|
2008-08-06 20:12:44 +00:00
|
|
|
} /* display update every second */
|
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;
|
|
|
|
}
|
2006-08-28 22:38:41 +00:00
|
|
|
} /* end while(!done) */
|
2004-11-08 13:20:43 +00:00
|
|
|
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_stat = audio_status();
|
|
|
|
if (audio_stat & AUDIO_STATUS_ERROR)
|
2003-06-19 12:08:22 +00:00
|
|
|
{
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, str(LANG_DISK_FULL));
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2006-07-19 15:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
screens[i].update();
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2007-12-15 23:51:13 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
/* stop recording - some players like H10 freeze otherwise
|
|
|
|
TO DO: find out why it freezes and fix properly */
|
|
|
|
rec_command(RECORDING_CMD_STOP);
|
|
|
|
audio_close_recording();
|
|
|
|
#endif
|
|
|
|
|
2005-04-04 12:06:29 +00:00
|
|
|
audio_error_clear();
|
2003-06-19 12:08:22 +00:00
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
2006-08-20 21:33:40 +00:00
|
|
|
if (action_userabort(TIMEOUT_NOBLOCK))
|
2003-06-19 12:08:22 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-11-10 16:42:31 +00:00
|
|
|
}
|
2007-06-22 09:34:57 +00:00
|
|
|
|
2007-11-30 05:14:57 +00:00
|
|
|
rec_abort:
|
|
|
|
|
2006-08-28 22:38:41 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2007-08-25 15:53:54 +00:00
|
|
|
rec_command(RECORDING_CMD_STOP);
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_close_recording();
|
2006-06-30 21:24:20 +00:00
|
|
|
|
2007-05-20 20:26:36 +00:00
|
|
|
#ifdef HAVE_FMRADIO_REC
|
2006-08-28 22:38:41 +00:00
|
|
|
if (radio_status != FMRADIO_OFF)
|
|
|
|
/* Restore radio playback - radio_status should be unchanged if started
|
|
|
|
through fm radio screen (barring usb connect) */
|
|
|
|
rec_set_source(AUDIO_SRC_FMRADIO, (radio_status & FMRADIO_PAUSED) ?
|
|
|
|
SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING);
|
|
|
|
else
|
2006-06-30 21:48:01 +00:00
|
|
|
#endif
|
2006-08-28 22:38:41 +00:00
|
|
|
/* Go back to playback mode */
|
|
|
|
rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
|
2006-06-30 21:24:20 +00:00
|
|
|
|
2007-10-19 15:31:42 +00:00
|
|
|
/* restore talking */
|
|
|
|
talk_disable(false);
|
2006-08-28 22:38:41 +00:00
|
|
|
#else /* !SWCODEC */
|
2005-04-04 12:06:29 +00:00
|
|
|
audio_init_playback();
|
2006-08-28 22:38:41 +00:00
|
|
|
#endif /* CONFIG_CODEC == SWCODEC */
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2010-01-03 13:32:16 +00:00
|
|
|
#ifdef HAVE_SPEAKER
|
|
|
|
/* Re-enable speaker */
|
|
|
|
audiohw_enable_speaker(global_settings.speaker_enabled);
|
|
|
|
#endif
|
|
|
|
|
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);
|
|
|
|
|
2007-06-22 09:34:57 +00:00
|
|
|
rec_status &= ~RCSTAT_IN_RECSCREEN;
|
2004-07-06 12:17:14 +00:00
|
|
|
sound_settings_apply();
|
2003-11-20 00:33:43 +00:00
|
|
|
|
2006-07-19 15:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
screens[i].setfont(FONT_UI);
|
2004-01-21 14:58:40 +00:00
|
|
|
|
2007-06-22 09:34:57 +00:00
|
|
|
/* if the directory was created or recording happened, make sure the
|
|
|
|
browser is updated */
|
|
|
|
if (rec_status & (RCSTAT_CREATED_DIRECTORY | RCSTAT_HAVE_RECORDED))
|
2004-01-21 14:58:40 +00:00
|
|
|
reload_directory();
|
|
|
|
|
2008-11-04 19:57:36 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_ATA) && (CONFIG_LED == LED_REAL) \
|
|
|
|
&& !defined(SIMULATOR)
|
|
|
|
ata_set_led_enabled(true);
|
2005-04-04 09:12:12 +00:00
|
|
|
#endif
|
2007-05-19 00:27:24 +00:00
|
|
|
|
2007-12-07 00:28:16 +00:00
|
|
|
settings_save();
|
2007-05-19 00:27:24 +00:00
|
|
|
|
2007-06-22 09:34:57 +00:00
|
|
|
return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0;
|
2006-08-28 22:38:41 +00:00
|
|
|
} /* recording_screen */
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2006-08-20 21:33:40 +00:00
|
|
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool f2_rec_screen(void)
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
2006-11-06 18:07:30 +00:00
|
|
|
static const char* const freq_str[6] =
|
|
|
|
{
|
|
|
|
"44.1kHz",
|
|
|
|
"48kHz",
|
|
|
|
"32kHz",
|
|
|
|
"22.05kHz",
|
|
|
|
"24kHz",
|
|
|
|
"16kHz"
|
|
|
|
};
|
|
|
|
|
2002-11-10 16:42:31 +00:00
|
|
|
bool exit = false;
|
|
|
|
bool used = false;
|
2006-07-19 15:30:40 +00:00
|
|
|
int w, h, i;
|
2002-11-10 16:42:31 +00:00
|
|
|
char buf[32];
|
2004-07-26 16:06:59 +00:00
|
|
|
int button;
|
2006-11-06 18:07:30 +00:00
|
|
|
struct audio_recording_options rec_options;
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2006-07-19 15:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
2010-03-06 15:02:22 +00:00
|
|
|
screens[i].set_viewport(NULL);
|
2006-07-19 15:30:40 +00:00
|
|
|
screens[i].setfont(FONT_SYSFIXED);
|
|
|
|
screens[i].getstringsize("A",&w,&h);
|
|
|
|
}
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
while (!exit) {
|
2009-10-11 08:45:47 +00:00
|
|
|
const char* ptr;
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2006-07-19 15:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
screens[i].clear_display();
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2006-07-19 15:30:40 +00:00
|
|
|
/* Recording quality */
|
2006-08-07 21:24:22 +00:00
|
|
|
screens[i].putsxy(0, LCD_HEIGHT/2 - h*2,
|
|
|
|
str(LANG_SYSFONT_RECORDING_QUALITY));
|
2006-07-19 15:30:40 +00:00
|
|
|
}
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2006-09-09 14:53:30 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%d", global_settings.rec_quality);
|
2006-07-19 15:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
screens[i].putsxy(0, LCD_HEIGHT/2-h, buf);
|
2007-12-07 00:31:31 +00:00
|
|
|
screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
|
2005-07-06 22:58:02 +00:00
|
|
|
LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
|
2006-07-19 15:30:40 +00:00
|
|
|
}
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
/* Frequency */
|
2006-08-07 21:24:22 +00:00
|
|
|
snprintf(buf, sizeof buf, "%s:", str(LANG_SYSFONT_RECORDING_FREQUENCY));
|
2002-11-10 23:18:33 +00:00
|
|
|
ptr = freq_str[global_settings.rec_frequency];
|
2006-07-19 15:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
screens[i].getstringsize(buf,&w,&h);
|
|
|
|
screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf);
|
|
|
|
screens[i].getstringsize(ptr, &w, &h);
|
|
|
|
screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr);
|
|
|
|
screens[i].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:
|
2006-08-07 21:24:22 +00:00
|
|
|
ptr = str(LANG_SYSFONT_CHANNEL_STEREO);
|
2002-11-10 16:42:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2006-08-07 21:24:22 +00:00
|
|
|
ptr = str(LANG_SYSFONT_CHANNEL_MONO);
|
2002-11-10 16:42:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-07-19 15:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
2007-08-05 19:19:39 +00:00
|
|
|
screens[i].getstringsize(str(LANG_SYSFONT_CHANNELS), &w, &h);
|
2006-07-19 15:30:40 +00:00
|
|
|
screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2,
|
2008-08-06 20:12:44 +00:00
|
|
|
str(LANG_SYSFONT_CHANNELS));
|
2007-08-05 19:19:39 +00:00
|
|
|
screens[i].getstringsize(str(LANG_SYSFONT_MODE), &w, &h);
|
2006-08-07 21:40:11 +00:00
|
|
|
screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h,
|
2008-08-06 20:12:44 +00:00
|
|
|
str(LANG_SYSFONT_MODE));
|
2006-07-19 15:30:40 +00:00
|
|
|
screens[i].getstringsize(ptr, &w, &h);
|
|
|
|
screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr);
|
2007-12-07 00:28:16 +00:00
|
|
|
screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
|
2005-07-06 22:58:02 +00:00
|
|
|
LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2006-07-19 15:30:40 +00:00
|
|
|
screens[i].update();
|
|
|
|
}
|
2002-11-10 16:42:31 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
rec_init_recording_options(&rec_options);
|
|
|
|
rec_set_recording_options(&rec_options);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
2002-11-10 23:18:33 +00:00
|
|
|
set_gain();
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2002-11-10 23:18:33 +00:00
|
|
|
settings_save();
|
2006-07-19 15:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
screens[i].setfont(FONT_UI);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool f3_rec_screen(void)
|
2002-11-10 16:42:31 +00:00
|
|
|
{
|
|
|
|
bool exit = false;
|
|
|
|
bool used = false;
|
2006-07-19 15:30:40 +00:00
|
|
|
int w, h, i;
|
2004-07-26 16:06:59 +00:00
|
|
|
int button;
|
2009-10-11 08:45:47 +00:00
|
|
|
const char *src_str[] =
|
2002-11-10 23:18:33 +00:00
|
|
|
{
|
2006-08-07 21:24:22 +00:00
|
|
|
str(LANG_SYSFONT_RECORDING_SRC_MIC),
|
2007-08-05 19:19:39 +00:00
|
|
|
str(LANG_SYSFONT_LINE_IN),
|
2006-08-07 21:24:22 +00:00
|
|
|
str(LANG_SYSFONT_RECORDING_SRC_DIGITAL)
|
2002-11-10 23:18:33 +00:00
|
|
|
};
|
2006-11-06 18:07:30 +00:00
|
|
|
struct audio_recording_options rec_options;
|
|
|
|
|
2006-07-19 15:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
2010-03-06 15:02:22 +00:00
|
|
|
screens[i].set_viewport(NULL);
|
2006-07-19 15:30:40 +00:00
|
|
|
screens[i].setfont(FONT_SYSFIXED);
|
|
|
|
screens[i].getstringsize("A",&w,&h);
|
|
|
|
}
|
2007-12-07 00:28:16 +00:00
|
|
|
|
2002-11-10 16:42:31 +00:00
|
|
|
while (!exit) {
|
2009-10-11 08:45:47 +00:00
|
|
|
const char* ptr = src_str[global_settings.rec_source];
|
2006-07-19 15:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
screens[i].clear_display();
|
|
|
|
|
|
|
|
/* Recording source */
|
2006-08-07 21:24:22 +00:00
|
|
|
screens[i].putsxy(0, LCD_HEIGHT/2 - h*2,
|
|
|
|
str(LANG_SYSFONT_RECORDING_SOURCE));
|
2007-12-07 00:31:31 +00:00
|
|
|
|
2006-07-19 15:30:40 +00:00
|
|
|
screens[i].getstringsize(ptr, &w, &h);
|
|
|
|
screens[i].putsxy(0, LCD_HEIGHT/2-h, ptr);
|
2007-12-07 00:28:16 +00:00
|
|
|
screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
|
2006-07-19 15:30:40 +00:00
|
|
|
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 */
|
2006-08-07 21:24:22 +00:00
|
|
|
ptr = str(LANG_SYSFONT_RECORD_TRIGGER);
|
2006-07-19 15:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
screens[i].getstringsize(ptr,&w,&h);
|
|
|
|
screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, ptr);
|
|
|
|
screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
|
2005-07-06 22:58:02 +00:00
|
|
|
LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
|
2005-04-04 09:12:12 +00:00
|
|
|
|
2006-07-19 15:30:40 +00:00
|
|
|
screens[i].update();
|
|
|
|
}
|
2002-11-10 16:42:31 +00:00
|
|
|
|
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++;
|
2006-08-28 22:38:41 +00:00
|
|
|
if(global_settings.rec_source > AUDIO_SRC_MAX)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
rec_init_recording_options(&rec_options);
|
|
|
|
rec_set_recording_options(&rec_options);
|
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();
|
2006-07-19 15:30:40 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
screens[i].setfont(FONT_UI);
|
2002-11-10 16:42:31 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-08-28 22:38:41 +00:00
|
|
|
#endif /* CONFIG_KEYPAD == RECORDER_PAD */
|
2004-10-09 11:39:30 +00:00
|
|
|
|
2005-11-12 04:00:56 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
void audio_beep(int duration)
|
|
|
|
{
|
|
|
|
/* dummy */
|
|
|
|
(void)duration;
|
|
|
|
}
|
2006-04-01 15:52:06 +00:00
|
|
|
|
|
|
|
#ifdef SIMULATOR
|
|
|
|
/* stubs for recording sim */
|
2006-04-30 23:18:21 +00:00
|
|
|
void audio_init_recording(unsigned int buffer_offset)
|
2006-04-01 15:52:06 +00:00
|
|
|
{
|
2006-04-30 23:18:21 +00:00
|
|
|
buffer_offset = buffer_offset;
|
2006-04-01 15:52:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void audio_close_recording(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-12-10 14:32:38 +00:00
|
|
|
unsigned long pcm_rec_get_warnings(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-20 22:57:02 +00:00
|
|
|
unsigned long pcm_rec_sample_rate(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-01 15:52:06 +00:00
|
|
|
unsigned long audio_recorded_time(void)
|
|
|
|
{
|
|
|
|
return 123;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long audio_num_recorded_bytes(void)
|
|
|
|
{
|
|
|
|
return 5 * 1024 * 1024;
|
|
|
|
}
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
void rec_set_source(int source, unsigned flags)
|
2006-08-28 22:38:41 +00:00
|
|
|
{
|
|
|
|
source = source;
|
|
|
|
flags = flags;
|
|
|
|
}
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
void audio_set_recording_options(struct audio_recording_options *options)
|
|
|
|
{
|
|
|
|
options = options;
|
2006-04-01 15:52:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void audio_set_recording_gain(int left, int right, int type)
|
|
|
|
{
|
|
|
|
left = left;
|
|
|
|
right = right;
|
|
|
|
type = type;
|
|
|
|
}
|
|
|
|
|
2007-06-08 23:42:04 +00:00
|
|
|
void audio_record(const char *filename)
|
2007-05-04 15:14:56 +00:00
|
|
|
{
|
2007-06-08 23:42:04 +00:00
|
|
|
filename = filename;
|
2007-05-04 15:14:56 +00:00
|
|
|
}
|
|
|
|
|
2007-06-08 23:42:04 +00:00
|
|
|
void audio_new_file(const char *filename)
|
2006-12-17 11:25:42 +00:00
|
|
|
{
|
|
|
|
filename = filename;
|
|
|
|
}
|
|
|
|
|
2006-04-01 15:52:06 +00:00
|
|
|
void audio_stop_recording(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void audio_pause_recording(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void audio_resume_recording(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* #ifdef SIMULATOR */
|
|
|
|
#endif /* #ifdef CONFIG_CODEC == SWCODEC */
|
2005-11-12 04:00:56 +00:00
|
|
|
|
2004-09-29 19:51:41 +00:00
|
|
|
#endif /* HAVE_RECORDING */
|