Skip to content

armgit / nota

Public Imported from GitHub
0

Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.

Fixed updating audio level on arangement when changing volume

Egor Khindikaynend86e60d85d43
diff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.cs
index cc4df40e..f788c491 100644
--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs
+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs
@@ -1388,7 +1388,7 @@ public sealed partial class ArrangementView
// Draw the clip being resized from its full-material peaks, mapping each timeline
// beat through the committed window so the SAME audio stays anchored and dragging
// reveals/hides real content (point 2) rather than squashing the window peaks.
- private void DrawResizeWaveform(DrawingContext ctx, Rect r, IBrush brush)
+ private void DrawResizeWaveform(DrawingContext ctx, Rect r, IBrush brush, float gain)
{
double mid = r.Y + r.Height / 2, amp = r.Height / 2 - 1;
double ppb = _o._pixelsPerBeat, scroll = _o._scrollBeats;
@@ -1407,6 +1407,7 @@ public sealed partial class ArrangementView
float min = 1f, max = -1f;
for (int b = b0; b < b1; b++) { min = Math.Min(min, _rpPeaks![b * 2]); max = Math.Max(max, _rpPeaks[b * 2 + 1]); }
if (min > max) continue;
+ min = Math.Clamp(min * gain, -1f, 1f); max = Math.Clamp(max * gain, -1f, 1f);
AddRect(g, px, mid - max * amp, 1, Math.Max(1, (max - min) * amp));
}
ctx.DrawGeometry(brush, null, geo);
@@ -1418,7 +1419,7 @@ public sealed partial class ArrangementView
if ((_drag == Drag.TrimL || _drag == Drag.TrimR) && ReferenceEquals(c, _dragClip)
&& _rpPeaks is not null && _rpCount > 0 && _rpMTotal > 0 && _origLen > 0 && r.Height > 0 && r.Width > 0)
{
- DrawResizeWaveform(ctx, r, brush);
+ DrawResizeWaveform(ctx, r, brush, c.Gain);
return;
}
if (c.Peaks is null || c.PeakCount <= 0 || r.Height <= 0 || r.Width <= 0) return;
@@ -1437,6 +1438,8 @@ public sealed partial class ArrangementView
float min = 1f, max = -1f;
for (int b = b0; b < b1; b++) { min = Math.Min(min, c.Peaks[b * 2]); max = Math.Max(max, c.Peaks[b * 2 + 1]); }
if (min > max) continue;
+ // Clip gain scales the drawn waveform, matching the clip editor.
+ min = Math.Clamp(min * c.Gain, -1f, 1f); max = Math.Clamp(max * c.Gain, -1f, 1f);
AddRect(g, px, mid - max * amp, 1, Math.Max(1, (max - min) * amp));
}
ctx.DrawGeometry(brush, null, geo);
diff --git a/src/managed/Nota.App/ArrangementView.Vms.cs b/src/managed/Nota.App/ArrangementView.Vms.cs
index 6481b038..97226542 100644
--- a/src/managed/Nota.App/ArrangementView.Vms.cs
+++ b/src/managed/Nota.App/ArrangementView.Vms.cs
@@ -75,6 +75,8 @@ public sealed partial class ArrangementView
public bool Active = true; // false = deactivated (key 0): stays but silent + greyed
public float[]? Peaks;
public int PeakCount;
+ /// <summary>Clip gain (linear) — peaks are raw material, the lane scales them by this.</summary>
+ public float Gain = 1f;
public NotaNote[]? Notes;
public string Name = "";
/// <summary>True when no clip on the same track ends where this one begins — the head
diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.cs
index de9ccc0f..ce672b4f 100644
--- a/src/managed/Nota.App/ArrangementView.cs
+++ b/src/managed/Nota.App/ArrangementView.cs
@@ -728,6 +728,7 @@ public sealed partial class ArrangementView : UserControl
cvm.PeakCount = eng.GetClipPeaks(ti.Id, c, peaks, buckets);
cvm.Peaks = peaks;
}
+ if (!ci.IsMidi && eng.TryGetAudioClipInfo(ti.Id, c, out var ai)) cvm.Gain = ai.Gain;
tvm.Clips.Add(cvm);
}
MarkClipRuns(tvm);