Skip to content

Commit 8f76486

Browse files
committed
Update PitchSyncMode to ParameterSyncMode and extend sync
1 parent aff7b87 commit 8f76486

File tree

5 files changed

+42
-10
lines changed

5 files changed

+42
-10
lines changed

TuneLab/Configs/Settings.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal static class Settings
1919
public static NotifiableProperty<string> BackgroundImagePath { get; } = DefaultSettings.BackgroundImagePath;
2020
public static NotifiableProperty<double> BackgroundImageOpacity { get; } = DefaultSettings.BackgroundImageOpacity;
2121
public static NotifiableProperty<double> ParameterBoundaryExtension { get; } = DefaultSettings.ParameterBoundaryExtension;
22-
public static NotifiableProperty<bool> PitchSyncMode { get; } = new(DefaultSettings.PitchSyncMode);
22+
public static NotifiableProperty<bool> ParameterSyncMode { get; } = new(DefaultSettings.ParameterSyncMode);
2323
public static NotifiableProperty<string> PianoKeySamplesPath { get; } = DefaultSettings.PianoKeySamplesPath;
2424
public static NotifiableProperty<int> AutoSaveInterval { get; } = DefaultSettings.AutoSaveInterval;
2525
public static NotifiableProperty<int> BufferSize { get; } = DefaultSettings.BufferSize;
@@ -50,7 +50,7 @@ public static void Init(string path)
5050
BackgroundImagePath.Value = settingsFile.BackgroundImagePath;
5151
BackgroundImageOpacity.Value = settingsFile.BackgroundImageOpacity;
5252
ParameterBoundaryExtension.Value = settingsFile.ParameterBoundaryExtension;
53-
PitchSyncMode.Value = settingsFile.PitchSyncMode;
53+
ParameterSyncMode.Value = settingsFile.ParameterSyncMode;
5454
PianoKeySamplesPath.Value = settingsFile.PianoKeySamplesPath;
5555
AutoSaveInterval.Value = settingsFile.AutoSaveInterval;
5656
BufferSize.Value = settingsFile.BufferSize;
@@ -71,7 +71,7 @@ public static void Save(string path)
7171
BackgroundImagePath = BackgroundImagePath,
7272
BackgroundImageOpacity = BackgroundImageOpacity,
7373
ParameterBoundaryExtension = ParameterBoundaryExtension,
74-
PitchSyncMode = PitchSyncMode.Value,
74+
ParameterSyncMode = ParameterSyncMode.Value,
7575
PianoKeySamplesPath = PianoKeySamplesPath,
7676
AutoSaveInterval = AutoSaveInterval,
7777
BufferSize = BufferSize,

TuneLab/Configs/SettingsFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class SettingsFile
1313
public string BackgroundImagePath { get; set; } = string.Empty;
1414
public double BackgroundImageOpacity { get; set; } = 0.5;
1515
public double ParameterBoundaryExtension { get; set; } = 5;
16-
public bool PitchSyncMode { get; set; } = false;
16+
public bool ParameterSyncMode { get; set; } = false;
1717
public string PianoKeySamplesPath { get; set; } = string.Empty;
1818
public int AutoSaveInterval { get; set; } = 10;
1919
public int BufferSize { get; set; } = 1024;

TuneLab/Resources/Translations/zh-CN.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"Piano Key Samples" = "钢琴音采样"
1313
"Auto Save Interval (second)" = "自动保存间隔(秒)"
1414
"Parameter Boundary Extension (tick)" = "参数边界扩展(tick)"
15-
"Pitch Sync Mode" = "音高同步模式"
15+
"Parameter Sync Mode" = "参数同步模式"
1616
"Track Hue Change Rate (degree/second)" = "轨道色相变化速率(度/秒)"
1717

1818
[FunctionBar]

TuneLab/UI/MainWindow/Editor/PianoWindow/PianoScrollView/PianoScrollViewOperation.cs

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,8 @@ public void Move(Avalonia.Point point, bool alt, bool shift)
15771577
part.BeginMergeReSegment();
15781578
part.Notes.ListModified.BeginMerge();
15791579
List<List<List<Point>>> pitchInfos = new();
1580-
if (Settings.PitchSyncMode)
1580+
Dictionary<string, List<List<Point>>> automationInfos = new();
1581+
if (Settings.ParameterSyncMode)
15811582
{
15821583
foreach (var note in mMoveNotes)
15831584
{
@@ -1590,6 +1591,21 @@ public void Move(Avalonia.Point point, bool alt, bool shift)
15901591
}
15911592
}
15921593
pitchInfos.Add(pitchInfo);
1594+
1595+
foreach (var kvp in part.Automations)
1596+
{
1597+
var autoInfo = kvp.Value.RangeInfo(note.StartPos(), note.EndPos());
1598+
for (int i = 0; i < autoInfo.Count; i++)
1599+
{
1600+
autoInfo[i] = new(autoInfo[i].X + note.StartPos() + posOffset, autoInfo[i].Y);
1601+
}
1602+
if (!automationInfos.TryGetValue(kvp.Key, out var list))
1603+
{
1604+
list = new List<List<Point>>();
1605+
automationInfos[kvp.Key] = list;
1606+
}
1607+
list.Add(autoInfo);
1608+
}
15931609
}
15941610
}
15951611

@@ -1599,19 +1615,23 @@ public void Move(Avalonia.Point point, bool alt, bool shift)
15991615
note.Pitch.Set(note.Pitch.Value + pitchOffset);
16001616
part.RemoveNote(note);
16011617
}
1602-
if (Settings.PitchSyncMode)
1618+
if (Settings.ParameterSyncMode)
16031619
{
16041620
foreach (var note in mMoveNotes)
16051621
{
16061622
part.Pitch.Clear(note.StartPos(), note.EndPos());
1623+
foreach (var kvp in part.Automations)
1624+
{
1625+
kvp.Value.Clear(note.StartPos(), note.EndPos(), Settings.ParameterBoundaryExtension);
1626+
}
16071627
}
16081628
}
16091629

16101630
foreach (var note in mMoveNotes)
16111631
{
16121632
part.InsertNote(note);
16131633
}
1614-
if (Settings.PitchSyncMode)
1634+
if (Settings.ParameterSyncMode)
16151635
{
16161636
foreach (var info in pitchInfos)
16171637
{
@@ -1620,6 +1640,18 @@ public void Move(Avalonia.Point point, bool alt, bool shift)
16201640
part.Pitch.AddLine(line, Settings.ParameterBoundaryExtension);
16211641
}
16221642
}
1643+
1644+
foreach (var kvp in automationInfos)
1645+
{
1646+
if (!part.Automations.TryGetValue(kvp.Key, out var automation))
1647+
continue;
1648+
1649+
var defaultValue = automation.DefaultValue.Value;
1650+
foreach (var line in kvp.Value)
1651+
{
1652+
automation.AddLine(line.Convert(p => new Point(p.X, p.Y + defaultValue)), Settings.ParameterBoundaryExtension);
1653+
}
1654+
}
16231655
}
16241656
part.Notes.ListModified.EndMerge();
16251657
part.EndMergeReSegment();

TuneLab/UI/Settings/SettingsWindow.axaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ public SettingsWindow()
220220
var panel = new DockPanel() { Margin = new(24, 12) };
221221
{
222222
var checkBox = new GUI.Components.CheckBox();
223-
checkBox.Bind(Settings.PitchSyncMode, false, s);
223+
checkBox.Bind(Settings.ParameterSyncMode, false, s);
224224
panel.AddDock(checkBox, Dock.Right);
225225
}
226226
{
227-
var name = new TextBlock() { Text = "Pitch Sync Mode".Tr(this) + ": ", VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center };
227+
var name = new TextBlock() { Text = "Parameter Sync Mode".Tr(this) + ": ", VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center };
228228
panel.AddDock(name);
229229
}
230230
listView.Content.Children.Add(panel);

0 commit comments

Comments
 (0)