avans06 commited on
Commit
22c681c
·
1 Parent(s): 2a4c238

refine(synth): Improve arpeggio velocity control with exponential scaling

Browse files

Changes the `Arpeggio Velocity Scale` from a linear to an exponential curve (`scale ** 2.5`).

This provides much finer control at lower volume levels, making it easier for users to mix the arpeggiated layer subtly into the background. The new scaling better reflects the human perception of loudness.

Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -517,7 +517,14 @@ def arpeggiate_midi(midi_data: pretty_midi.PrettyMIDI, params: AppParameters):
517
  chord_start_time = min(n.start for n in chord_notes)
518
  chord_end_time = max(n.end for n in chord_notes)
519
  avg_velocity = int(np.mean([n.velocity for n in chord_notes]))
520
- final_velocity_base = int(avg_velocity * params.s8bit_arpeggio_velocity_scale)
 
 
 
 
 
 
 
521
 
522
  if final_velocity_base < 1:
523
  final_velocity_base = 1
 
517
  chord_start_time = min(n.start for n in chord_notes)
518
  chord_end_time = max(n.end for n in chord_notes)
519
  avg_velocity = int(np.mean([n.velocity for n in chord_notes]))
520
+
521
+ # --- Apply an exponential curve to the velocity scale ---
522
+ # This makes the slider much more sensitive at lower values,
523
+ # allowing for true background-level arpeggios.
524
+ scale = params.s8bit_arpeggio_velocity_scale
525
+ # We use a power of 2 here, but could be tuned (e.g., 1.5, 2.5, 3.0)
526
+ # A higher power makes the attenuation at low scale values even more aggressive.
527
+ final_velocity_base = int(avg_velocity * (scale ** 2.5))
528
 
529
  if final_velocity_base < 1:
530
  final_velocity_base = 1