summaryrefslogtreecommitdiff
path: root/apps/settings_menu.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-10-29 12:09:15 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-10-29 12:09:15 +0000
commitfd0cc3b2b1302d77f3404861509e75c64fd505af (patch)
treeacdb25b87a549908424e052c04cc323d02b681f4 /apps/settings_menu.c
parent8f11dc00ac1a0a5fe009d1d07d9a1378c3300ba8 (diff)
downloadrockbox-fd0cc3b2b1302d77f3404861509e75c64fd505af.tar.gz
rockbox-fd0cc3b2b1302d77f3404861509e75c64fd505af.zip
Phil Pertermann's dB peak meter patch
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2774 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/settings_menu.c')
-rw-r--r--apps/settings_menu.c194
1 files changed, 183 insertions, 11 deletions
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 6f527f5224..ed2f97e390 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -74,27 +74,44 @@ static bool volume_type(void)
74 names, 2, NULL); 74 names, 2, NULL);
75} 75}
76 76
77#ifdef PM_DEBUG
78static bool peak_meter_fps_menu(void) {
79 bool retval = false;
80 retval = set_int( "Refresh rate", "/s",
81 &peak_meter_fps,
82 NULL, 1, 5, 40);
83 return retval;
84}
85#endif /* PM_DEBUG */
86
77/** 87/**
78 * Menu to set the hold time of normal peaks. 88 * Menu to set the hold time of normal peaks.
79 */ 89 */
80static bool peak_meter_hold(void) 90static bool peak_meter_hold(void) {
81{ 91 bool retval = false;
82 char* names[] = { str(LANG_OFF), 92 char* names[] = { str(LANG_OFF),
83 "200 ms ", "300 ms ", "500 ms ", "1 s ", "2 s ", 93 "200 ms ", "300 ms ", "500 ms ", "1 s ", "2 s ",
84 "3 s ", "4 s ", "5 s ", "6 s ", "7 s", 94 "3 s ", "4 s ", "5 s ", "6 s ", "7 s",
85 "8 s", "9 s", "10 s", "15 s", "20 s", 95 "8 s", "9 s", "10 s", "15 s", "20 s",
86 "30 s", "1 min" 96 "30 s", "1 min"
87 }; 97 };
88 return set_option( str(LANG_PM_PEAK_HOLD), 98 retval = set_option( str(LANG_PM_PEAK_HOLD),
89 &global_settings.peak_meter_hold, names, 99 &global_settings.peak_meter_hold, names,
90 18, NULL); 100 18, NULL);
101
102 peak_meter_init_times(global_settings.peak_meter_release,
103 global_settings.peak_meter_hold,
104 global_settings.peak_meter_clip_hold);
105
106 return retval;
91} 107}
92 108
93/** 109/**
94 * Menu to set the hold time of clips. 110 * Menu to set the hold time of clips.
95 */ 111 */
96static bool peak_meter_clip_hold(void) 112static bool peak_meter_clip_hold(void) {
97{ 113 bool retval = false;
114
98 char* names[] = { str(LANG_PM_ETERNAL), 115 char* names[] = { str(LANG_PM_ETERNAL),
99 "1s ", "2s ", "3s ", "4s ", "5s ", 116 "1s ", "2s ", "3s ", "4s ", "5s ",
100 "6s ", "7s ", "8s ", "9s ", "10s", 117 "6s ", "7s ", "8s ", "9s ", "10s",
@@ -103,19 +120,167 @@ static bool peak_meter_clip_hold(void)
103 "10min", "20min", "45min", "90min" 120 "10min", "20min", "45min", "90min"
104 }; 121 };
105 122
106 return set_option( str(LANG_PM_CLIP_HOLD), 123 retval = set_option( str(LANG_PM_CLIP_HOLD),
107 &global_settings.peak_meter_clip_hold, names, 124 &global_settings.peak_meter_clip_hold, names,
108 25, peak_meter_set_clip_hold); 125 25, peak_meter_set_clip_hold);
126
127 peak_meter_init_times(global_settings.peak_meter_release,
128 global_settings.peak_meter_hold,
129 global_settings.peak_meter_clip_hold);
130
131 return retval;
109} 132}
110 133
111/** 134/**
112 * Menu to set the release time of the peak meter. 135 * Menu to set the release time of the peak meter.
113 */ 136 */
114static bool peak_meter_release(void) 137static bool peak_meter_release(void) {
115{ 138 bool retval = false;
116 return set_int( str(LANG_PM_RELEASE), str(LANG_PM_UNITS_PER_READ), 139
140 /* The range of peak_meter_release is restricted so that it
141 fits into a 7 bit number. The 8th bit is used for storing
142 something else in the rtc ram.
143 Also, the max value is 0x7e, since the RTC value 0xff is reserved */
144 retval = set_int( str(LANG_PM_RELEASE), str(LANG_PM_UNITS_PER_READ),
117 &global_settings.peak_meter_release, 145 &global_settings.peak_meter_release,
118 NULL, 1, 1, LCD_WIDTH); 146 NULL, 1, 1, 0x7e);
147
148 peak_meter_init_times(global_settings.peak_meter_release,
149 global_settings.peak_meter_hold,
150 global_settings.peak_meter_clip_hold);
151
152 return retval;
153}
154
155/**
156 * Menu to select wether the scale of the meter
157 * displays dBfs of linear values.
158 */
159static bool peak_meter_scale(void) {
160 bool retval = false;
161 bool use_dbfs = global_settings.peak_meter_dbfs;
162 retval = set_bool_options(str(LANG_PM_SCALE),
163 &use_dbfs,
164 str(LANG_PM_DBFS), str(LANG_PM_LINEAR));
165
166 /* has the user really changed the scale? */
167 if (use_dbfs != global_settings.peak_meter_dbfs) {
168
169 /* store the change */
170 global_settings.peak_meter_dbfs = use_dbfs;
171 peak_meter_set_use_dbfs(use_dbfs);
172
173 /* If the user changed the scale mode the meaning of
174 peak_meter_min (peak_meter_max) has changed. Thus we have
175 to convert the values stored in global_settings. */
176 if (use_dbfs) {
177
178 /* we only store -dBfs */
179 global_settings.peak_meter_min = -peak_meter_get_min() / 100;
180 global_settings.peak_meter_max = -peak_meter_get_max() / 100;
181 } else {
182 int max;
183
184 /* linear percent */
185 global_settings.peak_meter_min = peak_meter_get_min();
186
187 /* converting dBfs -> percent results in a precision loss.
188 I assume that the user doesn't bother that conversion
189 dBfs <-> percent isn't symmetrical for odd values but that
190 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
191 resulting from dBfs -> percent manually here */
192 max = peak_meter_get_max();
193 global_settings.peak_meter_max = max < 99 ? max : 100;
194 }
195 settings_apply_pm_range();
196 }
197 return retval;
198}
199
200/**
201 * Adjust the min value of the value range that
202 * the peak meter shall visualize.
203 */
204static bool peak_meter_min(void) {
205 bool retval = false;
206 if (global_settings.peak_meter_dbfs) {
207
208 /* for dBfs scale */
209 int range_max = -global_settings.peak_meter_max;
210 int min = -global_settings.peak_meter_min;
211
212 retval = set_int(str(LANG_PM_MIN), str(LANG_PM_DBFS),
213 &min, NULL, 1, -89, range_max);
214
215 global_settings.peak_meter_min = - min;
216 }
217
218 /* for linear scale */
219 else {
220 int min = global_settings.peak_meter_min;
221
222 retval = set_int(str(LANG_PM_MIN), "%",
223 &min, NULL,
224 1, 0, global_settings.peak_meter_max - 1);
225
226 global_settings.peak_meter_min = (unsigned char)min;
227 }
228
229 settings_apply_pm_range();
230 return retval;
231}
232
233
234/**
235 * Adjust the max value of the value range that
236 * the peak meter shall visualize.
237 */
238static bool peak_meter_max(void) {
239 bool retval = false;
240 if (global_settings.peak_meter_dbfs) {
241
242 /* for dBfs scale */
243 int range_min = -global_settings.peak_meter_min;
244 int max = -global_settings.peak_meter_max;;
245
246 retval = set_int(str(LANG_PM_MAX), str(LANG_PM_DBFS),
247 &max, NULL, 1, range_min, 0);
248
249 global_settings.peak_meter_max = - max;
250
251 }
252
253 /* for linear scale */
254 else {
255 int max = global_settings.peak_meter_max;
256
257 retval = set_int(str(LANG_PM_MAX), "%",
258 &max, NULL,
259 1, global_settings.peak_meter_min + 1, 100);
260
261 global_settings.peak_meter_max = (unsigned char)max;
262 }
263
264 settings_apply_pm_range();
265 return retval;
266}
267
268/**
269 * Menu to select wether the meter is in
270 * precision or in energy saver mode
271 */
272static bool peak_meter_performance(void) {
273 bool retval = false;
274 retval = set_bool_options(str(LANG_PM_PERFORMANCE),
275 &global_settings.peak_meter_performance,
276 str(LANG_PM_HIGH_PERFORMANCE), str(LANG_PM_ENERGY_SAVER));
277
278 if (global_settings.peak_meter_performance) {
279 peak_meter_fps = 25;
280 } else {
281 peak_meter_fps = 20;
282 }
283 return retval;
119} 284}
120 285
121/** 286/**
@@ -130,6 +295,13 @@ static bool peak_meter_menu(void)
130 { str(LANG_PM_RELEASE) , peak_meter_release }, 295 { str(LANG_PM_RELEASE) , peak_meter_release },
131 { str(LANG_PM_PEAK_HOLD), peak_meter_hold }, 296 { str(LANG_PM_PEAK_HOLD), peak_meter_hold },
132 { str(LANG_PM_CLIP_HOLD), peak_meter_clip_hold }, 297 { str(LANG_PM_CLIP_HOLD), peak_meter_clip_hold },
298 { str(LANG_PM_PERFORMANCE), peak_meter_performance },
299#ifdef PM_DEBUG
300 { "Refresh rate" , peak_meter_fps_menu },
301#endif
302 { str(LANG_PM_SCALE) , peak_meter_scale },
303 { str(LANG_PM_MIN) , peak_meter_min },
304 { str(LANG_PM_MAX) , peak_meter_max },
133 }; 305 };
134 306
135 m=menu_init( items, sizeof items / sizeof(struct menu_items) ); 307 m=menu_init( items, sizeof items / sizeof(struct menu_items) );
@@ -137,7 +309,7 @@ static bool peak_meter_menu(void)
137 menu_exit(m); 309 menu_exit(m);
138 return result; 310 return result;
139} 311}
140#endif 312#endif /* HAVE_LCD_BITMAP */
141 313
142static bool shuffle(void) 314static bool shuffle(void)
143{ 315{