diff options
| author | Andy <andy@rockbox.org> | 2005-11-12 04:00:56 +0000 |
|---|---|---|
| committer | Andy <andy@rockbox.org> | 2005-11-12 04:00:56 +0000 |
| commit | e6e5496535a6fa45ee5cb63fb80886514ae72231 (patch) | |
| tree | ebd73be009933c4c7eaf224ccec308aa56dd7b99 /apps | |
| parent | 663fba13996c32e13d4cca89ffda86de8d536c7f (diff) | |
| download | rockbox-e6e5496535a6fa45ee5cb63fb80886514ae72231.zip rockbox-e6e5496535a6fa45ee5cb63fb80886514ae72231.tar.gz rockbox-e6e5496535a6fa45ee5cb63fb80886514ae72231.tar.bz2 rockbox-e6e5496535a6fa45ee5cb63fb80886514ae72231.tar.xz | |
iRiver: Initial support for wav-recording in recording menu. Supports mic/line-in (and radio), monitor mode, time-splitting (and byte-splitting), pause/resume etc. Things todo: Prerecording, peakmeter (should be simple), frequency other than 44.1 kHz, etc..
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7818 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/SOURCES | 3 | ||||
| -rw-r--r-- | apps/debug_menu.c | 4 | ||||
| -rw-r--r-- | apps/lang/english.lang | 22 | ||||
| -rw-r--r-- | apps/main.c | 2 | ||||
| -rw-r--r-- | apps/recorder/radio.c | 32 | ||||
| -rw-r--r-- | apps/recorder/recording.c | 114 | ||||
| -rw-r--r-- | apps/settings.c | 23 | ||||
| -rw-r--r-- | apps/settings.h | 5 | ||||
| -rw-r--r-- | apps/sound_menu.c | 34 |
9 files changed, 183 insertions, 56 deletions
diff --git a/apps/SOURCES b/apps/SOURCES index 8b2184b..6b2b682 100644 --- a/apps/SOURCES +++ b/apps/SOURCES @@ -65,7 +65,4 @@ playback.c metadata.c codecs.c dsp.c -#ifndef SIMULATOR -pcm_recording.c -#endif #endif diff --git a/apps/debug_menu.c b/apps/debug_menu.c index cd395cc..dd6a2d7 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -58,9 +58,6 @@ #include "ata_mmc.h" #endif #include "logfdisp.h" -#if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR) -extern bool pcm_rec_screen(void); -#endif #if CONFIG_CODEC == SWCODEC #include "pcmbuf.h" #include "pcm_playback.h" @@ -1781,7 +1778,6 @@ bool debug_menu(void) { "CPU frequency", dbg_cpufreq }, #endif #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR) - { "PCM recording", pcm_rec_screen }, { "S/PDIF analyzer", dbg_spdif }, #endif #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 9d54717..9123066 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -939,13 +939,13 @@ new: id: LANG_RECORDING_LEFT desc: in the recording screen -eng: "Left" +eng: "Gain Left" voice: "" new: id: LANG_RECORDING_RIGHT desc: in the recording screen -eng: "Right" +eng: "Gain Right" voice: "" new: @@ -3352,3 +3352,21 @@ desc: in crossfade settings menu eng: "Fade out mode" voice: "Fade out mode" new: + +id: LANG_RECORDING_ADC_RIGHT +desc: in the recording settings +eng: "ADC Gain Right" +voice: "ADC Gain Right" +new: + +id: LANG_RECORDING_ADC_LEFT +desc: in the recording settings +eng: "ADC Gain Left" +voice: "ADC Gain Left" +new: + +id: LANG_RECORDING_MONITOR +desc: in the recording settings +eng: "Monitor Mode" +voice: "Monitor Mode" +new: diff --git a/apps/main.c b/apps/main.c index 296b3fc..ab802d5 100644 --- a/apps/main.c +++ b/apps/main.c @@ -323,7 +323,7 @@ void init(void) sound_settings_apply(); #endif #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR) - pcm_init_recording(); + pcm_rec_init(); #endif talk_init(); /* runtime database has to be initialized after audio_init() */ diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 443bb31..6be6d04 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c @@ -226,7 +226,7 @@ bool radio_screen(void) audio_stop(); #if CONFIG_CODEC != SWCODEC - mpeg_init_recording(); + audio_init_recording(); sound_settings_apply(); @@ -238,23 +238,24 @@ bool radio_screen(void) if (global_settings.rec_prerecord_time) talk_buffer_steal(); /* will use the mp3 buffer */ - mpeg_set_recording_options(global_settings.rec_frequency, + audio_set_recording_options(global_settings.rec_frequency, global_settings.rec_quality, 1, /* Line In */ global_settings.rec_channels, global_settings.rec_editable, - global_settings.rec_prerecord_time); + global_settings.rec_prerecord_time, + global_settings.rec_monitor); - mpeg_set_recording_gain(sound_default(SOUND_LEFT_GAIN), - sound_default(SOUND_RIGHT_GAIN), false); + audio_set_recording_gain(sound_default(SOUND_LEFT_GAIN), + sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN); #else uda1380_enable_recording(false); - uda1380_set_recvol(0, 0, 10); + uda1380_set_recvol(10, 10, AUDIO_GAIN_LINEIN); uda1380_set_monitor(true); /* Set the input multiplexer to FM */ - pcmrec_set_mux(1); + pcm_rec_mux(1); #endif #endif @@ -345,14 +346,14 @@ bool radio_screen(void) #ifndef SIMULATOR if(audio_status() == AUDIO_STATUS_RECORD) { - mpeg_new_file(rec_create_filename(buf)); + audio_new_file(rec_create_filename(buf)); update_screen = true; } else { have_recorded = true; talk_buffer_steal(); /* we use the mp3 buffer */ - mpeg_record(rec_create_filename(buf)); + audio_record(rec_create_filename(buf)); update_screen = true; } #endif @@ -517,7 +518,7 @@ bool radio_screen(void) #ifndef SIMULATOR #if CONFIG_CODEC != SWCODEC - seconds = mpeg_recorded_time() / HZ; + seconds = audio_recorded_time() / HZ; #endif #endif if(update_screen || seconds > last_seconds) @@ -609,8 +610,8 @@ bool radio_screen(void) { #if CONFIG_CODEC != SWCODEC /* Enable the Left and right A/D Converter */ - mpeg_set_recording_gain(sound_default(SOUND_LEFT_GAIN), - sound_default(SOUND_RIGHT_GAIN), false); + audio_set_recording_gain(sound_default(SOUND_LEFT_GAIN), + sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN); mas_codec_writereg(6, 0x4000); #endif radio_set_status(FMRADIO_POWERED); /* leave it powered */ @@ -619,7 +620,7 @@ bool radio_screen(void) { radio_stop(); #if CONFIG_CODEC == SWCODEC - pcmrec_set_mux(0); /* Line In */ + pcm_rec_mux(0); /* Line In */ #endif } @@ -913,12 +914,13 @@ static bool fm_recording_settings(void) if (global_settings.rec_prerecord_time) talk_buffer_steal(); /* will use the mp3 buffer */ - mpeg_set_recording_options(global_settings.rec_frequency, + audio_set_recording_options(global_settings.rec_frequency, global_settings.rec_quality, 1, /* Line In */ global_settings.rec_channels, global_settings.rec_editable, - global_settings.rec_prerecord_time); + global_settings.rec_prerecord_time, + global_settings.rec_monitor); } return ret; } diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index b70e7b6..ebd9217 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -28,6 +28,13 @@ #include "led.h" #include "mpeg.h" #include "audio.h" +#if CONFIG_CODEC == SWCODEC +#include "pcm_record.h" +#endif +#ifdef HAVE_UDA1380 +#include "uda1380.h" +#endif + #include "mp3_playback.h" #include "mas.h" #include "button.h" @@ -79,9 +86,12 @@ #elif CONFIG_KEYPAD == IRIVER_H100_PAD #define REC_STOPEXIT BUTTON_OFF -#define REC_RECPAUSE BUTTON_ON +#define REC_RECPAUSE BUTTON_REC #define REC_INC BUTTON_RIGHT #define REC_DEC BUTTON_LEFT +#define REC_NEXT BUTTON_DOWN +#define REC_PREV BUTTON_UP +#define REC_SETTINGS BUTTON_MODE #elif CONFIG_KEYPAD == GMINI100_PAD #define REC_STOPEXIT BUTTON_OFF @@ -102,6 +112,12 @@ bool f3_rec_screen(void); #define MAX_SOURCE SOURCE_LINE #endif +#if CONFIG_CODEC == SWCODEC +#define REC_FILE_ENDING ".wav" +#else +#define REC_FILE_ENDING ".mp3" +#endif + #define MAX_FILE_SIZE 0x7FF00000 /* 2 GB - 1 MB */ const char* const freq_str[6] = @@ -118,13 +134,18 @@ static void set_gain(void) { if(global_settings.rec_source == SOURCE_MIC) { - mpeg_set_recording_gain(global_settings.rec_mic_gain, 0, true); + audio_set_recording_gain(global_settings.rec_mic_gain, 0, AUDIO_GAIN_MIC); } else { - mpeg_set_recording_gain(global_settings.rec_left_gain, - global_settings.rec_right_gain, false); + audio_set_recording_gain(global_settings.rec_left_gain, + global_settings.rec_right_gain, AUDIO_GAIN_LINEIN); } +#ifdef HAVE_UDA1380 + audio_set_recording_gain(global_settings.rec_adc_left_gain, + global_settings.rec_adc_right_gain, + AUDIO_GAIN_ADC); +#endif } static const char* const fmtstr[] = @@ -176,9 +197,9 @@ char *rec_create_filename(char *buffer) strncpy(buffer, rec_base_directory, MAX_PATH); #ifdef HAVE_RTC - create_datetime_filename(buffer, buffer, "R", ".mp3"); + create_datetime_filename(buffer, buffer, "R", REC_FILE_ENDING); #else - create_numbered_filename(buffer, buffer, "rec_", ".mp3", 4); + create_numbered_filename(buffer, buffer, "rec_", REC_FILE_ENDING, 4); #endif return buffer; } @@ -227,7 +248,7 @@ static void trigger_listener(int trigger_status) if((audio_status() & AUDIO_STATUS_RECORD) != AUDIO_STATUS_RECORD) { talk_buffer_steal(); /* we use the mp3 buffer */ - mpeg_record(rec_create_filename(path_buffer)); + audio_record(rec_create_filename(path_buffer)); /* give control to mpeg thread so that it can start recording */ yield(); yield(); yield(); @@ -236,7 +257,7 @@ static void trigger_listener(int trigger_status) /* if we're already recording this is a retrigger */ else { - mpeg_new_file(rec_create_filename(path_buffer)); + audio_new_file(rec_create_filename(path_buffer)); /* tell recording_screen to reset the time */ last_seconds = 0; } @@ -273,6 +294,7 @@ bool recording_screen(void) char path_buffer[MAX_PATH]; bool been_in_usb_mode = false; int last_audio_stat = -1; + int audio_stat; #if CONFIG_LED == LED_REAL bool led_state = false; int led_countdown = 2; @@ -289,7 +311,7 @@ bool recording_screen(void) #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) ata_set_led_enabled(false); #endif - mpeg_init_recording(); + audio_init_recording(); sound_set_volume(global_settings.volume); @@ -298,15 +320,20 @@ bool recording_screen(void) peak_meter_enabled = true; +#if CONFIG_CODEC == SWCODEC + audio_stop(); +#endif + if (global_settings.rec_prerecord_time) talk_buffer_steal(); /* will use the mp3 buffer */ - mpeg_set_recording_options(global_settings.rec_frequency, + audio_set_recording_options(global_settings.rec_frequency, global_settings.rec_quality, global_settings.rec_source, global_settings.rec_channels, global_settings.rec_editable, - global_settings.rec_prerecord_time); + global_settings.rec_prerecord_time, + global_settings.rec_monitor); set_gain(); @@ -321,7 +348,12 @@ bool recording_screen(void) while(!done) { - int audio_stat = audio_status(); +#if CONFIG_CODEC == SWCODEC + audio_stat = pcm_rec_status(); +#else + audio_stat = audio_status(); +#endif + #if CONFIG_LED == LED_REAL /* @@ -390,7 +422,7 @@ bool recording_screen(void) if(audio_stat & AUDIO_STATUS_RECORD) { - audio_stop(); + audio_stop_recording(); } else { @@ -416,7 +448,7 @@ bool recording_screen(void) /* manual recording */ have_recorded = true; talk_buffer_steal(); /* we use the mp3 buffer */ - mpeg_record(rec_create_filename(path_buffer)); + audio_record(rec_create_filename(path_buffer)); last_seconds = 0; if (global_settings.talk_menu) { /* no voice possible here, but a beep */ @@ -438,7 +470,7 @@ bool recording_screen(void) { if(audio_stat & AUDIO_STATUS_PAUSE) { - mpeg_resume_recording(); + audio_resume_recording(); if (global_settings.talk_menu) { /* no voice possible here, but a beep */ audio_beep(HZ/4); /* short beep on resume */ @@ -446,7 +478,7 @@ bool recording_screen(void) } else { - mpeg_pause_recording(); + audio_pause_recording(); } } update_countdown = 1; /* Update immediately */ @@ -535,7 +567,7 @@ bool recording_screen(void) sound_min(SOUND_RIGHT_GAIN)) global_settings.rec_right_gain--; break; - } + } set_gain(); update_countdown = 1; /* Update immediately */ break; @@ -557,12 +589,13 @@ bool recording_screen(void) if (global_settings.rec_prerecord_time) talk_buffer_steal(); /* will use the mp3 buffer */ - mpeg_set_recording_options(global_settings.rec_frequency, + audio_set_recording_options(global_settings.rec_frequency, global_settings.rec_quality, global_settings.rec_source, global_settings.rec_channels, global_settings.rec_editable, - global_settings.rec_prerecord_time); + global_settings.rec_prerecord_time, + global_settings.rec_monitor); set_gain(); update_countdown = 1; /* Update immediately */ @@ -596,7 +629,7 @@ bool recording_screen(void) case REC_F3: if(audio_stat & AUDIO_STATUS_RECORD) { - mpeg_new_file(rec_create_filename(path_buffer)); + audio_new_file(rec_create_filename(path_buffer)); last_seconds = 0; } else @@ -638,8 +671,8 @@ bool recording_screen(void) lcd_setfont(FONT_SYSFIXED); - seconds = mpeg_recorded_time() / HZ; - + seconds = audio_recorded_time() / HZ; + update_countdown--; if(update_countdown == 0 || seconds > last_seconds) { @@ -660,7 +693,7 @@ bool recording_screen(void) lcd_puts(0, 0, buf); dseconds = rec_timesplit_seconds(); - num_recorded_bytes = mpeg_num_recorded_bytes(); + num_recorded_bytes = audio_num_recorded_bytes(); if(audio_stat & AUDIO_STATUS_PRERECORD) { @@ -699,7 +732,7 @@ bool recording_screen(void) ((global_settings.rec_timesplit && (seconds >= dseconds)) || (num_recorded_bytes >= MAX_FILE_SIZE))) { - mpeg_new_file(rec_create_filename(path_buffer)); + audio_new_file(rec_create_filename(path_buffer)); update_countdown = 1; last_seconds = 0; } @@ -784,7 +817,13 @@ bool recording_screen(void) } } - if(audio_status() & AUDIO_STATUS_ERROR) + +#if CONFIG_CODEC == SWCODEC + audio_stat = pcm_rec_status(); +#else + audio_stat = audio_status(); +#endif + if (audio_stat & AUDIO_STATUS_ERROR) { splash(0, true, str(LANG_DISK_FULL)); status_draw(true); @@ -799,7 +838,12 @@ bool recording_screen(void) } } +#if CONFIG_CODEC == SWCODEC + audio_stop_recording(); + audio_close_recording(); +#else audio_init_playback(); +#endif /* make sure the trigger is really turned off */ peak_meter_trigger(false); @@ -924,12 +968,13 @@ bool f2_rec_screen(void) if (global_settings.rec_prerecord_time) talk_buffer_steal(); /* will use the mp3 buffer */ - mpeg_set_recording_options(global_settings.rec_frequency, + audio_set_recording_options(global_settings.rec_frequency, global_settings.rec_quality, global_settings.rec_source, global_settings.rec_channels, global_settings.rec_editable, - global_settings.rec_prerecord_time); + global_settings.rec_prerecord_time, + global_settings.rec_monitor); set_gain(); @@ -1018,12 +1063,14 @@ bool f3_rec_screen(void) if (global_settings.rec_prerecord_time) talk_buffer_steal(); /* will use the mp3 buffer */ - mpeg_set_recording_options(global_settings.rec_frequency, + audio_set_recording_options(global_settings.rec_frequency, global_settings.rec_quality, global_settings.rec_source, global_settings.rec_channels, global_settings.rec_editable, - global_settings.rec_prerecord_time); + global_settings.rec_prerecord_time, + global_settings.rec_monitor); + set_gain(); @@ -1034,4 +1081,13 @@ bool f3_rec_screen(void) } #endif /* #ifdef REC_F3 */ +#if CONFIG_CODEC == SWCODEC +void audio_beep(int duration) +{ + /* dummy */ + (void)duration; +} +#endif + + #endif /* HAVE_RECORDING */ diff --git a/apps/settings.c b/apps/settings.c index b573d72..d44fec1 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -85,7 +85,7 @@ const char rec_base_directory[] = REC_BASE_DIR; #include "dsp.h" #endif -#define CONFIG_BLOCK_VERSION 29 +#define CONFIG_BLOCK_VERSION 30 #define CONFIG_BLOCK_SIZE 512 #define RTC_BLOCK_SIZE 44 @@ -407,6 +407,7 @@ static const struct bit_entry hd_bits[] = #ifdef HAVE_RECORDING {1, S_O(rec_startup), false, "rec screen on startup", off_on }, + {1, S_O(rec_monitor), true, "monitor recording", off_on }, /* values for the trigger */ {8 | SIGNED, S_O(rec_start_thres), -35, "trigger start threshold", NULL}, @@ -450,6 +451,26 @@ static const struct bit_entry hd_bits[] = {22, S_O(dircache_size), 0, NULL, NULL }, #endif +#if defined(HAVE_UDA1380) + /* recording settings for iriver */ + {4, S_O(rec_timesplit), 0, "rec timesplit", /* 0...15 */ + "off,00:05,00:10,00:15,00:30,01:00,01:14,01:20,02:00,04:00,06:00,08:00,10:00,12:00,18:00,24:00" }, + {1, S_O(rec_channels), 0, "rec channels", "stereo,mono" }, + {4, S_O(rec_mic_gain), 4, "rec mic gain", NULL }, + {1, S_O(rec_source), 0 /* 0=mic */, "rec source", "mic,line" }, + {3, S_O(rec_frequency), 0, /* 0=44.1kHz */ + "rec frequency", "44,48,32,22,24,16" }, + {4, S_O(rec_left_gain), 2, /* 0dB */ + "rec left gain", NULL }, /* 0...15 */ + {4, S_O(rec_right_gain), 2, /* 0dB */ + "rec right gain", NULL }, /* 0...15 */ + {5, S_O(rec_prerecord_time), 0, "prerecording time", NULL }, /* 0...30 */ + {1, S_O(rec_directory), 0, /* rec_base_directory */ + "rec directory", REC_BASE_DIR ",current" }, + {8|SIGNED, S_O(rec_adc_left_gain), 0, /* 0dB */ "adc left gain", NULL }, /* -128...48 */ + {8|SIGNED, S_O(rec_adc_right_gain), 0, /* 0dB */ "adc right gain", NULL }, /* -128...48 */ +#endif + /* If values are just added to the end, no need to bump the version. */ /* new stuff to be added at the end */ diff --git a/apps/settings.h b/apps/settings.h index 63349c6..18c566b 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -176,7 +176,12 @@ struct user_settings int rec_mic_gain; /* 0-15 */ int rec_left_gain; /* 0-15 */ int rec_right_gain; /* 0-15 */ +#ifdef HAVE_UDA1380 + int rec_adc_left_gain; /* -128 .. 48 */ + int rec_adc_right_gain; /* -128 .. 48 */ +#endif bool rec_editable; /* true means that the bit reservoir is off */ + bool rec_monitor; /* true means that one can listen to what is being recorded */ /* note: timesplit setting is not saved */ int rec_timesplit; /* 0 = off, diff --git a/apps/sound_menu.c b/apps/sound_menu.c index 7663724..c429920 100644 --- a/apps/sound_menu.c +++ b/apps/sound_menu.c @@ -228,6 +228,28 @@ static bool receditable(void) &global_settings.rec_editable); } +static bool recmonitor(void) +{ + return set_bool(str(LANG_RECORDING_MONITOR), + &global_settings.rec_monitor); +} + +#ifdef HAVE_UDA1380 +static bool recadcleft(void) +{ + return set_sound(str(LANG_RECORDING_ADC_LEFT), + &global_settings.rec_adc_left_gain, + SOUND_ADC_LEFT_GAIN); +} + +static bool recadcright(void) +{ + return set_sound(str(LANG_RECORDING_ADC_RIGHT), + &global_settings.rec_adc_right_gain, + SOUND_ADC_RIGHT_GAIN); +} +#endif + static bool rectimesplit(void) { static const struct opt_items names[] = { @@ -740,7 +762,7 @@ bool recording_menu(bool no_source) { int m; int i = 0; - struct menu_item items[10]; + struct menu_item items[13]; bool result; items[i].desc = ID2P(LANG_RECORDING_QUALITY); @@ -753,6 +775,16 @@ bool recording_menu(bool no_source) } items[i].desc = ID2P(LANG_RECORDING_CHANNELS); items[i++].function = recchannels; + +#ifdef HAVE_UDA1380 + items[i].desc = ID2P(LANG_RECORDING_ADC_LEFT); + items[i++].function = recadcleft; + items[i].desc = ID2P(LANG_RECORDING_ADC_RIGHT); + items[i++].function = recadcright; +#endif + + items[i].desc = ID2P(LANG_RECORDING_MONITOR); + items[i++].function = recmonitor; items[i].desc = ID2P(LANG_RECORDING_EDITABLE); items[i++].function = receditable; items[i].desc = ID2P(LANG_RECORD_TIMESPLIT); |