diff --git a/apps/lang/deutsch.lang b/apps/lang/deutsch.lang index 8aa8425c47..1010493231 100644 --- a/apps/lang/deutsch.lang +++ b/apps/lang/deutsch.lang @@ -1261,22 +1261,22 @@ voice: "LCD-Modus" new: "LCD-Modus" id: LANG_CHANNEL_STEREO_NARROW_PLAYER -desc: in sound_settings -eng: "St. Narrow" -voice: "Stereo schmal" -new: "St. schmal" +desc: DEPRECATED +eng: "" +voice: "" +new: id: LANG_CHANNEL_STEREO_NARROW_RECORDER -desc: in sound_settings -eng: "Stereo Narrow" -voice: "Stereo schmal" -new: "Stereo schmal" +desc: DEPRECATED +eng: "" +voice: "" +new: id: LANG_CHANNEL_STEREO_WIDE -desc: in sound_settings -eng: "Stereo Wide" -voice: "Stereo breit" -new: "Stereo breit" +desc: DEPRECATED +eng: "" +voice: "" +new: id: LANG_CHANNEL_KARAOKE desc: in sound_settings @@ -2846,3 +2846,16 @@ eng: "" voice: " " new: +id: LANG_STEREO_WIDTH +desc: in sound_settings +eng: "Stereo width" +voice: "Stereobasisbreite" +new: "Stereobasisbreite" + +id: LANG_CHANNEL_CUSTOM +desc: in sound_settings +eng: "Custom" +voice: "Angepasst" +new: "Angepasst" + + diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 1f2dd4d9e3..4cc95b8383 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -1274,21 +1274,21 @@ voice: "LCD Mode" new: id: LANG_CHANNEL_STEREO_NARROW_PLAYER -desc: in sound_settings -eng: "St. Narrow" -voice: "Stereo Narrow" +desc: DEPRECATED +eng: "" +voice: "" new: id: LANG_CHANNEL_STEREO_NARROW_RECORDER -desc: in sound_settings -eng: "Stereo Narrow" -voice: "Stereo Narrow" +desc: DEPRECATED +eng: "" +voice: "" new: id: LANG_CHANNEL_STEREO_WIDE -desc: in sound_settings -eng: "Stereo Wide" -voice: "Stereo Wide" +desc: DEPRECATED +eng: "" +voice: "" new: id: LANG_CHANNEL_KARAOKE @@ -2860,3 +2860,16 @@ eng: "" voice: " " new: +id: LANG_STEREO_WIDTH +desc: in sound_settings +eng: "Stereo width" +voice: "Stereo width" +new: + +id: LANG_CHANNEL_CUSTOM +desc: in sound_settings +eng: "Custom" +voice: "Custom" +new: + + diff --git a/apps/main.c b/apps/main.c index 964a7c8b4f..cc270ba136 100644 --- a/apps/main.c +++ b/apps/main.c @@ -140,6 +140,7 @@ void init(void) global_settings.loudness, global_settings.avc, global_settings.channel_config, + global_settings.stereo_width, global_settings.mdb_strength, global_settings.mdb_harmonics, global_settings.mdb_center, @@ -272,6 +273,7 @@ void init(void) global_settings.loudness, global_settings.avc, global_settings.channel_config, + global_settings.stereo_width, global_settings.mdb_strength, global_settings.mdb_harmonics, global_settings.mdb_center, diff --git a/apps/settings.c b/apps/settings.c index d4945d4431..ca1b900ef4 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -71,7 +71,7 @@ const char rec_base_directory[] = REC_BASE_DIR; -#define CONFIG_BLOCK_VERSION 18 +#define CONFIG_BLOCK_VERSION 19 #define CONFIG_BLOCK_SIZE 512 #define RTC_BLOCK_SIZE 44 @@ -170,8 +170,9 @@ static const struct bit_entry rtc_bits[] = {3, S_O(avc), 0, "auto volume", "off,20ms,2,4,8" }, {1, S_O(superbass), false, "superbass", off_on }, #endif - {3, S_O(channel_config), 6, "channels", - "stereo,stereo narrow,mono,mono left,mono right,karaoke,stereo wide" }, + {3, S_O(channel_config), 0, "channels", + "stereo,mono,custom,mono left,mono right,karaoke" }, + {8, S_O(stereo_width), 100, "stereo width", NULL}, /* playback */ {2, S_O(resume), RESUME_ASK, "resume", "off,ask,ask once,on" }, {1, S_O(playlist_shuffle), false, "shuffle", off_on }, @@ -206,7 +207,7 @@ static const struct bit_entry rtc_bits[] = #endif {1, S_O(show_icons), true, "show icons", off_on }, /* system */ - {4, S_O(poweroff), 10, + {4, S_O(poweroff), 10, "idle poweroff", "off,1,2,3,4,5,6,7,8,9,10,15,30,45,60" }, {18, S_O(runtime), 0, NULL, NULL }, {18, S_O(topruntime), 0, NULL, NULL }, @@ -221,19 +222,20 @@ static const struct bit_entry rtc_bits[] = #endif {12, S_O(battery_capacity), BATTERY_CAPACITY_MIN, "battery capacity", NULL }, /* 1500...3200 for NiMH, 2200...3200 for LiIon, - 1000...2000 for Alkaline */ + 500...1500 for Alkaline */ #ifdef HAVE_CHARGING {1, S_O(car_adapter_mode), false, "car adapter mode", off_on }, #endif - - /* new stuff to be added here */ - /* If values are just added to the end, no need to bump the version. */ + /* tuner */ #ifdef CONFIG_TUNER {1, S_O(fm_force_mono), false, "force fm mono", off_on }, {8, S_O(last_frequency), 0, NULL, NULL }, /* Default: MIN_FREQ */ #endif - /* Current sum of bits: 286 (worst case) */ + /* new stuff to be added here */ + /* If values are just added to the end, no need to bump the version. */ + + /* Current sum of bits: 259 (worst case) */ /* Sum of all bit sizes must not grow beyond 288! */ }; @@ -716,6 +718,7 @@ void sound_settings_apply(void) mpeg_sound_set(SOUND_BALANCE, global_settings.balance); mpeg_sound_set(SOUND_VOLUME, global_settings.volume); mpeg_sound_set(SOUND_CHANNELS, global_settings.channel_config); + mpeg_sound_set(SOUND_STEREO_WIDTH, global_settings.stereo_width); #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) mpeg_sound_set(SOUND_LOUDNESS, global_settings.loudness); mpeg_sound_set(SOUND_AVC, global_settings.avc); @@ -1261,6 +1264,7 @@ void settings_reset(void) { global_settings.loudness = mpeg_sound_default(SOUND_LOUDNESS); global_settings.avc = mpeg_sound_default(SOUND_AVC); global_settings.channel_config = mpeg_sound_default(SOUND_CHANNELS); + global_settings.stereo_width = mpeg_sound_default(SOUND_STEREO_WIDTH); global_settings.mdb_strength = mpeg_sound_default(SOUND_MDB_STRENGTH); global_settings.mdb_harmonics = mpeg_sound_default(SOUND_MDB_HARMONICS); global_settings.mdb_center = mpeg_sound_default(SOUND_MDB_CENTER); diff --git a/apps/settings.h b/apps/settings.h index 8d92aa9ad1..88bc71804a 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -129,7 +129,8 @@ struct user_settings int treble; /* treble eq: 0-100 0=low 100=high */ int loudness; /* loudness eq: 0-100 0=off 100=max */ int avc; /* auto volume correct: 0=off, 1=20ms, 2=2s 3=4s 4=8s */ - int channel_config; /* Stereo, Mono, Mono left, Mono right */ + int channel_config; /* Stereo, Mono, Custom, Mono left, Mono right, Karaoke */ + int stereo_width; /* 0-255% */ int mdb_strength; /* 0-127dB */ int mdb_harmonics; /* 0-100% */ int mdb_center; /* 20-300Hz */ diff --git a/apps/sound_menu.c b/apps/sound_menu.c index de5b8c0a8c..6e5b74bfa3 100644 --- a/apps/sound_menu.c +++ b/apps/sound_menu.c @@ -385,19 +385,20 @@ static bool chanconf(void) { static const struct opt_items names[] = { { STR(LANG_CHANNEL_STEREO) }, -#ifdef HAVE_LCD_CHARCELLS - { STR(LANG_CHANNEL_STEREO_NARROW_PLAYER) }, -#else - { STR(LANG_CHANNEL_STEREO_NARROW_RECORDER) }, -#endif { STR(LANG_CHANNEL_MONO) }, + { STR(LANG_CHANNEL_CUSTOM) }, { STR(LANG_CHANNEL_LEFT) }, { STR(LANG_CHANNEL_RIGHT) }, - { STR(LANG_CHANNEL_KARAOKE) }, - { STR(LANG_CHANNEL_STEREO_WIDE) } + { STR(LANG_CHANNEL_KARAOKE) } }; return set_option(str(LANG_CHANNEL), &global_settings.channel_config, INT, - names, 7, set_chanconf ); + names, 6, set_chanconf ); +} + +static bool stereo_width(void) +{ + return set_sound(str(LANG_STEREO_WIDTH), &global_settings.stereo_width, + SOUND_STEREO_WIDTH); } bool sound_menu(void) @@ -410,6 +411,7 @@ bool sound_menu(void) { ID2P(LANG_TREBLE), treble }, { ID2P(LANG_BALANCE), balance }, { ID2P(LANG_CHANNEL_MENU), chanconf }, + { ID2P(LANG_STEREO_WIDTH), stereo_width }, #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) { ID2P(LANG_LOUDNESS), loudness }, { ID2P(LANG_AUTOVOL), avc }, diff --git a/firmware/export/mp3_playback.h b/firmware/export/mp3_playback.h index 456569342b..aced6ddc94 100644 --- a/firmware/export/mp3_playback.h +++ b/firmware/export/mp3_playback.h @@ -25,8 +25,8 @@ #include /* functions formerly in mpeg.c */ -void mp3_init(int volume, int bass, int treble, int balance, - int loudness, int avc, int channel_config, +void mp3_init(int volume, int bass, int treble, int balance, int loudness, + int avc, int channel_config, int stereo_width, int mdb_strength, int mdb_harmonics, int mdb_center, int mdb_shape, bool mdb_enable, bool superbass); @@ -70,23 +70,23 @@ void mp3_shutdown(void); #define SOUND_LOUDNESS 4 #define SOUND_AVC 5 #define SOUND_CHANNELS 6 -#define SOUND_LEFT_GAIN 7 -#define SOUND_RIGHT_GAIN 8 -#define SOUND_MIC_GAIN 9 -#define SOUND_MDB_STRENGTH 10 -#define SOUND_MDB_HARMONICS 11 -#define SOUND_MDB_CENTER 12 -#define SOUND_MDB_SHAPE 13 -#define SOUND_MDB_ENABLE 14 -#define SOUND_SUPERBASS 15 -#define SOUND_NUMSETTINGS 16 +#define SOUND_STEREO_WIDTH 7 +#define SOUND_LEFT_GAIN 8 +#define SOUND_RIGHT_GAIN 9 +#define SOUND_MIC_GAIN 10 +#define SOUND_MDB_STRENGTH 11 +#define SOUND_MDB_HARMONICS 12 +#define SOUND_MDB_CENTER 13 +#define SOUND_MDB_SHAPE 14 +#define SOUND_MDB_ENABLE 15 +#define SOUND_SUPERBASS 16 +#define SOUND_NUMSETTINGS 17 #define MPEG_SOUND_STEREO 0 -#define MPEG_SOUND_STEREO_NARROW 1 -#define MPEG_SOUND_MONO 2 +#define MPEG_SOUND_MONO 1 +#define MPEG_SOUND_CUSTOM 2 #define MPEG_SOUND_MONO_LEFT 3 #define MPEG_SOUND_MONO_RIGHT 4 #define MPEG_SOUND_KARAOKE 5 -#define MPEG_SOUND_STEREO_WIDE 6 #endif /* #ifndef _MP3_PLAYBACK_H_ */ diff --git a/firmware/mp3_playback.c b/firmware/mp3_playback.c index 140d1ff75b..f2c588c6b5 100644 --- a/firmware/mp3_playback.c +++ b/firmware/mp3_playback.c @@ -72,6 +72,7 @@ static const char* const units[] = "dB", /* Loudness */ "", /* AVC */ "", /* Channels */ + "%", /* Stereo width */ "dB", /* Left gain */ "dB", /* Right gain */ "dB", /* Mic gain */ @@ -92,6 +93,7 @@ static const int numdecimals[] = 0, /* Loudness */ 0, /* AVC */ 0, /* Channels */ + 0, /* Stereo width */ 1, /* Left gain */ 1, /* Right gain */ 1, /* Mic gain */ @@ -112,6 +114,7 @@ static const int steps[] = 1, /* Loudness */ 1, /* AVC */ 1, /* Channels */ + 1, /* Stereo width */ 1, /* Left gain */ 1, /* Right gain */ 1, /* Mic gain */ @@ -137,6 +140,7 @@ static const int minval[] = 0, /* Loudness */ -1, /* AVC */ 0, /* Channels */ + 0, /* Stereo width */ 0, /* Left gain */ 0, /* Right gain */ 0, /* Mic gain */ @@ -161,7 +165,8 @@ static const int maxval[] = 100, /* Balance */ 17, /* Loudness */ 4, /* AVC */ - 6, /* Channels */ + 5, /* Channels */ + 255, /* Stereo width */ 15, /* Left gain */ 15, /* Right gain */ 15, /* Mic gain */ @@ -187,6 +192,7 @@ static const int defaultval[] = 0, /* Loudness */ 0, /* AVC */ 0, /* Channels */ + 100, /* Stereo width */ 8, /* Left gain */ 8, /* Right gain */ 2, /* Mic gain */ @@ -566,8 +572,6 @@ static void init_playback(void) mas_readmem(MAS_BANK_D0, MAS_D0_APP_RUNNING, &val, 1); } while((val & 0x0c) != 0x0c); - mpeg_sound_channel_config(MPEG_SOUND_STEREO); - #if CONFIG_HWCODEC == MAS3587F mpeg_mode = MPEG_DECODER; #endif @@ -619,6 +623,89 @@ void set_prescaled_volume(void) #endif /* MAS3507D */ #endif /* !SIMULATOR */ +int channel_configuration = MPEG_SOUND_STEREO; +int stereo_width = 100; + +#ifndef SIMULATOR +static void set_channel_config(void) +{ + /* default values: stereo */ + unsigned long val_ll = 0x80000; + unsigned long val_lr = 0; + unsigned long val_rl = 0; + unsigned long val_rr = 0x80000; + + switch(channel_configuration) + { + /* case MPEG_SOUND_STEREO unnecessary */ + + case MPEG_SOUND_MONO: + val_ll = 0xc0000; + val_lr = 0xc0000; + val_rl = 0xc0000; + val_rr = 0xc0000; + break; + + case MPEG_SOUND_CUSTOM: + { + /* fixed point variables (matching MAS internal format) + integer part: upper 13 bits (inlcuding sign) + fractional part: lower 19 bits */ + long fp_width, fp_straight, fp_cross; + + fp_width = (stereo_width << 19) / 100; + if (stereo_width <= 100) + { + fp_straight = - ((1<<19) + fp_width) / 2; + fp_cross = fp_straight + fp_width; + } + else + { + fp_straight = - (1<<19); + fp_cross = ((2 * fp_width / (((1<<19) + fp_width) >> 10)) + << 9) - (1<<19); + } + val_ll = val_rr = fp_straight & 0xFFFFF; + val_lr = val_rl = fp_cross & 0xFFFFF; + } + break; + + case MPEG_SOUND_MONO_LEFT: + val_ll = 0x80000; + val_lr = 0x80000; + val_rl = 0; + val_rr = 0; + break; + + case MPEG_SOUND_MONO_RIGHT: + val_ll = 0; + val_lr = 0; + val_rl = 0x80000; + val_rr = 0x80000; + break; + + case MPEG_SOUND_KARAOKE: + val_ll = 0x80001; + val_lr = 0x7ffff; + val_rl = 0x7ffff; + val_rr = 0x80001; + break; + } + +#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) + mas_writemem(MAS_BANK_D0, MAS_D0_OUT_LL, &val_ll, 1); /* LL */ + mas_writemem(MAS_BANK_D0, MAS_D0_OUT_LR, &val_lr, 1); /* LR */ + mas_writemem(MAS_BANK_D0, MAS_D0_OUT_RL, &val_rl, 1); /* RL */ + mas_writemem(MAS_BANK_D0, MAS_D0_OUT_RR, &val_rr, 1); /* RR */ +#elif CONFIG_HWCODEC == MAS3507D + mas_writemem(MAS_BANK_D1, 0x7f8, &val_ll, 1); /* LL */ + mas_writemem(MAS_BANK_D1, 0x7f9, &val_lr, 1); /* LR */ + mas_writemem(MAS_BANK_D1, 0x7fa, &val_rl, 1); /* RL */ + mas_writemem(MAS_BANK_D1, 0x7fb, &val_rr, 1); /* RR */ +#endif +} +#endif /* !SIMULATOR */ + #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) unsigned long mdb_shape_shadow = 0; unsigned long loudness_shadow = 0; @@ -766,7 +853,14 @@ void mpeg_sound_set(int setting, int value) break; #endif case SOUND_CHANNELS: - mpeg_sound_channel_config(value); + channel_configuration = value; + set_channel_config(); + break; + + case SOUND_STEREO_WIDTH: + stereo_width = value; + if (channel_configuration == MPEG_SOUND_CUSTOM) + set_channel_config(); break; } #endif /* SIMULATOR */ @@ -799,82 +893,6 @@ int mpeg_val2phys(int setting, int value) #endif } -void mpeg_sound_channel_config(int configuration) -{ -#ifdef SIMULATOR - (void)configuration; -#else - unsigned long val_ll = 0x80000; - unsigned long val_lr = 0; - unsigned long val_rl = 0; - unsigned long val_rr = 0x80000; - - switch(configuration) - { - case MPEG_SOUND_STEREO: - val_ll = 0x80000; - val_lr = 0; - val_rl = 0; - val_rr = 0x80000; - break; - - case MPEG_SOUND_MONO: - val_ll = 0xc0000; - val_lr = 0xc0000; - val_rl = 0xc0000; - val_rr = 0xc0000; - break; - - case MPEG_SOUND_MONO_LEFT: - val_ll = 0x80000; - val_lr = 0x80000; - val_rl = 0; - val_rr = 0; - break; - - case MPEG_SOUND_MONO_RIGHT: - val_ll = 0; - val_lr = 0; - val_rl = 0x80000; - val_rr = 0x80000; - break; - - case MPEG_SOUND_STEREO_NARROW: - val_ll = 0xa0000; - val_lr = 0xe0000; - val_rl = 0xe0000; - val_rr = 0xa0000; - break; - - case MPEG_SOUND_STEREO_WIDE: - val_ll = 0x80000; - val_lr = 0x40000; - val_rl = 0x40000; - val_rr = 0x80000; - break; - - case MPEG_SOUND_KARAOKE: - val_ll = 0x80001; - val_lr = 0x7ffff; - val_rl = 0x7ffff; - val_rr = 0x80001; - break; - } - -#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) - mas_writemem(MAS_BANK_D0, MAS_D0_OUT_LL, &val_ll, 1); /* LL */ - mas_writemem(MAS_BANK_D0, MAS_D0_OUT_LR, &val_lr, 1); /* LR */ - mas_writemem(MAS_BANK_D0, MAS_D0_OUT_RL, &val_rl, 1); /* RL */ - mas_writemem(MAS_BANK_D0, MAS_D0_OUT_RR, &val_rr, 1); /* RR */ -#else - mas_writemem(MAS_BANK_D1, 0x7f8, &val_ll, 1); /* LL */ - mas_writemem(MAS_BANK_D1, 0x7f9, &val_lr, 1); /* LR */ - mas_writemem(MAS_BANK_D1, 0x7fa, &val_rl, 1); /* RL */ - mas_writemem(MAS_BANK_D1, 0x7fb, &val_rr, 1); /* RR */ -#endif -#endif -} - #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) /* This function works by telling the decoder that we have another crystal frequency than we actually have. It will adjust its internal @@ -901,7 +919,7 @@ void mpeg_set_pitch(int pitch) #endif void mp3_init(int volume, int bass, int treble, int balance, int loudness, - int avc, int channel_config, + int avc, int channel_config, int stereo_width, int mdb_strength, int mdb_harmonics, int mdb_center, int mdb_shape, bool mdb_enable, bool superbass) @@ -914,6 +932,7 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness, (void)loudness; (void)avc; (void)channel_config; + (void)stereo_width; (void)mdb_strength; (void)mdb_harmonics; (void)mdb_center; @@ -1015,8 +1034,6 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness, mas_writereg(MAS_REG_KPRESCALE, 0xe9400); dac_enable(true); - - mpeg_sound_channel_config(channel_config); #endif #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) @@ -1031,9 +1048,10 @@ void mp3_init(int volume, int bass, int treble, int balance, int loudness, mpeg_sound_set(SOUND_TREBLE, treble); mpeg_sound_set(SOUND_BALANCE, balance); mpeg_sound_set(SOUND_VOLUME, volume); + mpeg_sound_set(SOUND_CHANNELS, channel_config); + mpeg_sound_set(SOUND_STEREO_WIDTH, stereo_width); #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) - mpeg_sound_channel_config(channel_config); mpeg_sound_set(SOUND_LOUDNESS, loudness); mpeg_sound_set(SOUND_AVC, avc); mpeg_sound_set(SOUND_MDB_STRENGTH, mdb_strength);