@@ -137,6 +137,7 @@ struct FslcMix {
137
137
master : MixChannel ,
138
138
normalize : bool ,
139
139
ui_size : egui:: Vec2 ,
140
+ max_gain : f32 ,
140
141
}
141
142
142
143
impl FslcMix {
@@ -155,6 +156,7 @@ impl FslcMix {
155
156
normalize : false ,
156
157
ui_size : egui:: Vec2 :: new ( 400.0 , 330.0 ) , // This size doesn't matter since it's
157
158
// overritten
159
+ max_gain : 1.25 ,
158
160
}
159
161
}
160
162
@@ -213,7 +215,27 @@ impl FslcMix {
213
215
ui. vertical ( |ui| {
214
216
ui. horizontal ( |ui| {
215
217
// ui.label("Licensed under the GPLv3.");
218
+ ui. label ( "Max Gain:" ) ;
219
+ let slider = ui. add ( egui:: DragValue :: new ( & mut self . max_gain ) . range ( 1.1 ..=2.0 ) ) ;
220
+ if slider. changed ( ) {
221
+ self . update_max_gain ( ) ;
222
+ }
223
+ let btn = ui. button ( "Reset" ) ;
224
+ if btn. clicked ( ) {
225
+ self . max_gain = 1.2 ;
226
+ self . update_max_gain ( ) ;
227
+ }
216
228
ui. toggle_value ( & mut self . normalize , "Normalize" ) ;
229
+ if ui. add ( egui:: Button :: new ( "All Unmute" ) . frame ( false ) ) . clicked ( ) {
230
+ for channel in & mut self . channels {
231
+ channel. mute = false ;
232
+ }
233
+ }
234
+ if ui. add ( egui:: Button :: new ( "All Unsolo" ) . frame ( false ) ) . clicked ( ) {
235
+ for channel in & mut self . channels {
236
+ channel. solo = false ;
237
+ }
238
+ }
217
239
} ) ;
218
240
} ) ;
219
241
ui. horizontal ( |ui| {
@@ -232,6 +254,15 @@ impl FslcMix {
232
254
// frame.set_window_size(window_size);
233
255
// frame.request_repaint();
234
256
}
257
+
258
+ fn update_max_gain ( & mut self ) {
259
+ // update max gain for all channels
260
+ for channel in & mut self . channels {
261
+ channel. max_gain = self . max_gain ;
262
+ }
263
+ self . master . max_gain = self . max_gain ;
264
+
265
+ }
235
266
}
236
267
237
268
struct MixChannel {
@@ -247,6 +278,7 @@ struct MixChannel {
247
278
solo : bool ,
248
279
others_solo : bool ,
249
280
show_rms : bool ,
281
+ max_gain : f32 ,
250
282
}
251
283
252
284
impl MixChannel {
@@ -304,7 +336,7 @@ impl MixChannel {
304
336
} ) ;
305
337
ui. horizontal ( |ui| {
306
338
ui. spacing_mut ( ) . slider_width = 175.0 ;
307
- ui. add ( egui:: Slider :: new ( & mut self . gain , 0.0 ..=1.2 )
339
+ ui. add ( egui:: Slider :: new ( & mut self . gain , 0.0 ..=self . max_gain )
308
340
//.text("Gain")
309
341
. vertical ( )
310
342
. max_decimals ( 2 ) ) ;
@@ -342,7 +374,7 @@ impl MixChannel {
342
374
} ;
343
375
let ( rect, response) = ui. allocate_exact_size ( vec2 ( 10.0 , 190.0 ) , egui:: Sense :: hover ( ) ) ;
344
376
let painter = ui. painter ( ) ;
345
- let filled_height = ( rect. height ( ) * val / 1.2 ) . min ( rect. height ( ) ) ; // Show a bit over max amplitude
377
+ let filled_height = ( rect. height ( ) * val / self . max_gain ) . min ( rect. height ( ) ) ; // Show a bit over max amplitude
346
378
// let filled_rect = Rect::from_min_max(rect.min, rect.min + vec2(rect.width(), filled_height));
347
379
// let remaining_rect = Rect::from_min_max(filled_rect.max, rect.max);
348
380
let filled_rect = Rect :: from_min_max ( rect. max - vec2 ( rect. width ( ) , filled_height) , rect. max ) ;
@@ -351,15 +383,15 @@ impl MixChannel {
351
383
let color_saturation = if self . mute || ( !self . solo && self . others_solo ) { 50 } else { 200 } ;
352
384
let color = if val < 1.0 {
353
385
Color32 :: from_rgb ( 0 , color_saturation, 0 )
354
- } else if val < 1.2 {
386
+ } else if val < self . max_gain {
355
387
Color32 :: from_rgb ( color_saturation, color_saturation, 0 )
356
388
} else {
357
389
Color32 :: from_rgb ( color_saturation, 0 , 0 )
358
390
} ;
359
391
painter. rect_filled ( filled_rect, 0.0 , color) ;
360
392
painter. rect_stroke ( rect, 0.0 , ( 1.0 , Color32 :: DARK_GRAY ) ) ;
361
393
// Draw scale numbers
362
- let num_steps = 12 ;
394
+ let num_steps = ( self . max_gain * 10.0 ) as u16 ;
363
395
let step_size = rect. height ( ) / num_steps as f32 ;
364
396
for i in 0 ..=num_steps {
365
397
let y_pos = rect. top ( ) + i as f32 * step_size;
@@ -415,6 +447,7 @@ impl Default for MixChannel {
415
447
solo : false ,
416
448
others_solo : false ,
417
449
show_rms : false ,
450
+ max_gain : 1.25 ,
418
451
}
419
452
}
420
453
}
0 commit comments