From 0cd320b52b8b583d8b48e8793411a7382a133891 Mon Sep 17 00:00:00 2001 From: Sugita Akira Date: Fri, 2 Jun 2023 22:42:04 -0700 Subject: [PATCH 1/9] silence pan loging --- OpenUtau.Core/Commands/Notifications.cs | 3 ++- OpenUtau/Views/PianoRollWindow.axaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenUtau.Core/Commands/Notifications.cs b/OpenUtau.Core/Commands/Notifications.cs index 48ae7ce42..7d0ed375b 100644 --- a/OpenUtau.Core/Commands/Notifications.cs +++ b/OpenUtau.Core/Commands/Notifications.cs @@ -1,4 +1,4 @@ -using System; +using System; using OpenUtau.Core.Ustx; namespace OpenUtau.Core { @@ -118,6 +118,7 @@ public VolumeChangeNotification(int trackNo, double volume) { public class PanChangeNotification : UNotification { public double Pan; public int TrackNo; + public override bool Silent => true; public PanChangeNotification(int trackNo, double pan) { TrackNo = trackNo; Pan = pan; diff --git a/OpenUtau/Views/PianoRollWindow.axaml b/OpenUtau/Views/PianoRollWindow.axaml index a2c73b2ab..df55b4ceb 100644 --- a/OpenUtau/Views/PianoRollWindow.axaml +++ b/OpenUtau/Views/PianoRollWindow.axaml @@ -322,7 +322,7 @@ + ToolTip.Tip="{DynamicResource pianoroll.toggle.noteparams}" IsVisible="False"> From a11623da32476d2b4332c6665f5e46015b85f390 Mon Sep 17 00:00:00 2001 From: Sugita Akira Date: Sat, 3 Jun 2023 01:17:22 -0700 Subject: [PATCH 2/9] fix updater dialog crash --- OpenUtau/ViewModels/UpdaterViewModel.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OpenUtau/ViewModels/UpdaterViewModel.cs b/OpenUtau/ViewModels/UpdaterViewModel.cs index b59d66f63..6b030b8a1 100644 --- a/OpenUtau/ViewModels/UpdaterViewModel.cs +++ b/OpenUtau/ViewModels/UpdaterViewModel.cs @@ -104,8 +104,13 @@ public UpdaterViewModel() { async void Init() { UpdaterStatus = ThemeManager.GetString("updater.status.checking"); sparkle = await NewUpdaterAsync(); + if (sparkle == null) { + UpdaterStatus = ThemeManager.GetString("updater.status.unknown"); + return; + } updateInfo = await sparkle.CheckForUpdatesQuietly(); if (updateInfo == null) { + UpdaterStatus = ThemeManager.GetString("updater.status.unknown"); return; } switch (updateInfo.Status) { From 5e9a9e6058d83e7fe178836ce46997663f38183b Mon Sep 17 00:00:00 2001 From: Maiko Date: Sun, 4 Jun 2023 03:01:28 +0900 Subject: [PATCH 3/9] Add solo keyboard shortcut --- OpenUtau/Views/MainWindow.axaml.cs | 16 ++++++++++++++++ OpenUtau/Views/PianoRollWindow.axaml.cs | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/OpenUtau/Views/MainWindow.axaml.cs b/OpenUtau/Views/MainWindow.axaml.cs index c3f744d6a..a28db3f15 100644 --- a/OpenUtau/Views/MainWindow.axaml.cs +++ b/OpenUtau/Views/MainWindow.axaml.cs @@ -15,6 +15,7 @@ using Avalonia.Markup.Xaml; using Avalonia.Threading; using Avalonia.VisualTree; +using Melanchall.DryWetMidi.MusicTheory; using OpenUtau.App.Controls; using OpenUtau.App.ViewModels; using OpenUtau.Classic; @@ -681,6 +682,21 @@ void OnKeyDown(object sender, KeyEventArgs args) { args.Handled = false; break; } + } else if (args.KeyModifiers == KeyModifiers.Shift) { + args.Handled = true; + switch (args.Key) { + case Key.S: + if (viewModel.TracksViewModel.SelectedParts.Count > 0) { + var part = viewModel.TracksViewModel.SelectedParts.First(); + var track = DocManager.Inst.Project.tracks[part.trackNo]; + MessageBus.Current.SendMessage(new TracksSoloEvent(part.trackNo, !track.Solo)); + } + break; + //case Key.M: ; break; + default: + args.Handled = false; + break; + } } else if (args.KeyModifiers == (cmdKey | KeyModifiers.Shift)) { args.Handled = true; switch (args.Key) { diff --git a/OpenUtau/Views/PianoRollWindow.axaml.cs b/OpenUtau/Views/PianoRollWindow.axaml.cs index b2ea74a09..1664b9c6e 100644 --- a/OpenUtau/Views/PianoRollWindow.axaml.cs +++ b/OpenUtau/Views/PianoRollWindow.axaml.cs @@ -1229,6 +1229,12 @@ bool OnKeyExtendedHandler(KeyEventArgs args) { _ = MainWindow?.Save(); return true; } + // solo + if(isShift) { + var track = project.tracks[notesVm.Part.trackNo]; + MessageBus.Current.SendMessage(new TracksSoloEvent(notesVm.Part.trackNo, !track.Solo)); + return true; + } break; case Key.F: // scroll selection into focus From e32ff4af0b6ce6d494e27e901204b767c06d86cd Mon Sep 17 00:00:00 2001 From: Maiko Date: Mon, 5 Jun 2023 16:44:17 +0900 Subject: [PATCH 4/9] Add mute shortcut, mute restoration --- OpenUtau.Core/PlaybackManager.cs | 3 +- OpenUtau.Core/Render/RenderEngine.cs | 2 +- OpenUtau.Core/Ustx/UTrack.cs | 9 +++-- OpenUtau/Controls/TrackHeader.axaml | 2 +- OpenUtau/Controls/TrackHeaderCanvas.cs | 34 +++++++++++++++---- OpenUtau/ViewModels/TrackHeaderViewModel.cs | 37 ++++++++++++++------- OpenUtau/ViewModels/TracksViewModel.cs | 6 ++++ OpenUtau/Views/MainWindow.axaml.cs | 9 ++++- OpenUtau/Views/PianoRollWindow.axaml.cs | 6 ++++ 9 files changed, 83 insertions(+), 25 deletions(-) diff --git a/OpenUtau.Core/PlaybackManager.cs b/OpenUtau.Core/PlaybackManager.cs index 996361bc2..a29ef5570 100644 --- a/OpenUtau.Core/PlaybackManager.cs +++ b/OpenUtau.Core/PlaybackManager.cs @@ -62,6 +62,7 @@ private PlaybackManager() { public Audio.IAudioOutput AudioOutput { get; set; } = new Audio.DummyAudioOutput(); public bool Playing => AudioOutput.PlaybackState == PlaybackState.Playing; public bool StartingToPlay { get; private set; } + public bool SoloTrackExist { get; set; } = false; public void PlayTestSound() { masterMix = null; @@ -170,7 +171,7 @@ public void RenderToFiles(UProject project, string exportPath) { RenderEngine engine = new RenderEngine(project); var trackMixes = engine.RenderTracks(DocManager.Inst.MainScheduler, ref renderCancellation); for (int i = 0; i < trackMixes.Count; ++i) { - if (trackMixes[i] == null || i >= project.tracks.Count || project.tracks[i].Mute) { + if (trackMixes[i] == null || i >= project.tracks.Count || project.tracks[i].ApparentMute) { continue; } var file = PathManager.Inst.GetExportPath(exportPath, project.tracks[i]); diff --git a/OpenUtau.Core/Render/RenderEngine.cs b/OpenUtau.Core/Render/RenderEngine.cs index 97216fd4c..f60ad1d3e 100644 --- a/OpenUtau.Core/Render/RenderEngine.cs +++ b/OpenUtau.Core/Render/RenderEngine.cs @@ -85,7 +85,7 @@ public Tuple> RenderMixdown(int startTick, TaskScheduler ui })); var trackMix = new WaveMix(trackSources); var fader = new Fader(trackMix); - fader.Scale = PlaybackManager.DecibelToVolume(track.Mute ? -24 : track.Volume); + fader.Scale = PlaybackManager.DecibelToVolume(track.ApparentMute ? -24 : track.Volume); fader.Pan = (float)track.Pan; fader.SetScaleToTarget(); faders.Add(fader); diff --git a/OpenUtau.Core/Ustx/UTrack.cs b/OpenUtau.Core/Ustx/UTrack.cs index 4bb0cf9f9..21bc5ade1 100644 --- a/OpenUtau.Core/Ustx/UTrack.cs +++ b/OpenUtau.Core/Ustx/UTrack.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using OpenUtau.Api; using OpenUtau.Core.Render; @@ -89,8 +88,9 @@ public USinger Singer { [YamlIgnore] public string SingerName => Singer != null ? Singer.DisplayName : "[No Singer]"; [YamlIgnore] public int TrackNo { set; get; } public string TrackName { get; set; } = "New Track"; - public bool Mute { set; get; } - public bool Solo { set; get; } + public bool ApparentMute { set; get; } + public bool Mute { get; set; } + public bool Solo { get; set; } public double Volume { set; get; } public double Pan { set; get; } [YamlIgnore] public UExpressionDescriptor VoiceColorExp { set; get; } @@ -179,6 +179,9 @@ public void AfterLoad(UProject project) { }; } TrackNo = project.tracks.IndexOf(this); + if (Solo) { + PlaybackManager.Inst.SoloTrackExist = true; + } } } } diff --git a/OpenUtau/Controls/TrackHeader.axaml b/OpenUtau/Controls/TrackHeader.axaml index d0b575130..d8a0ed0dd 100644 --- a/OpenUtau/Controls/TrackHeader.axaml +++ b/OpenUtau/Controls/TrackHeader.axaml @@ -82,7 +82,7 @@ + IsChecked="{Binding ApparentMute, Mode=OneWay}" Command="{Binding ToggleMute}"> { foreach (var (track, header) in trackHeaders) { if (header.ViewModel != null) { - if (track.TrackNo == e.trackNo) { - header.ViewModel.Solo = e.solo; - if (e.solo) { - header.ViewModel.Mute = false; + if (e.solo) { + PlaybackManager.Inst.SoloTrackExist = true; + + if (track.TrackNo == e.trackNo) { + header.ViewModel.Solo = true; + header.ViewModel.ApparentMute = false; + } else { + header.ViewModel.Solo = false; + header.ViewModel.ApparentMute = true; } } else { - header.ViewModel.Solo = false; - header.ViewModel.Mute = e.solo; + PlaybackManager.Inst.SoloTrackExist = false; + if (track.TrackNo == e.trackNo) { + header.ViewModel.Solo = false; + } + if (track.Mute) { + header.ViewModel.ApparentMute = true; + } else { + header.ViewModel.ApparentMute = false; + } } header.ViewModel.ManuallyRaise(); } } + }); MessageBus.Current.Listen() + .Subscribe(e => { + foreach (var (track, header) in trackHeaders) { + if (header.ViewModel != null) { + if (track.TrackNo == e.trackNo) { + header.ViewModel.ToggleMute(); + } + } + } }); } diff --git a/OpenUtau/ViewModels/TrackHeaderViewModel.cs b/OpenUtau/ViewModels/TrackHeaderViewModel.cs index dcab22d61..a232845a5 100644 --- a/OpenUtau/ViewModels/TrackHeaderViewModel.cs +++ b/OpenUtau/ViewModels/TrackHeaderViewModel.cs @@ -33,7 +33,7 @@ public class TrackHeaderViewModel : ViewModelBase, IActivatableViewModel { [Reactive] public string TrackName { get; set; } [Reactive] public double Volume { get; set; } [Reactive] public double Pan { get; set; } - [Reactive] public bool Mute { get; set; } + [Reactive] public bool ApparentMute { get; set; } [Reactive] public bool Solo { get; set; } [Reactive] public Bitmap? Avatar { get; set; } @@ -131,26 +131,22 @@ public TrackHeaderViewModel(UTrack track) { TrackName = track.TrackName; Volume = track.Volume; Pan = track.Pan; - Mute = track.Mute; + ApparentMute = track.ApparentMute; Solo = track.Solo; - this.WhenAnyValue(x => x.track.TrackName) - .Subscribe(trackName => { - TrackName = trackName; - }); this.WhenAnyValue(x => x.Volume) .Subscribe(volume => { track.Volume = volume; - DocManager.Inst.ExecuteCmd(new VolumeChangeNotification(track.TrackNo, Mute ? -24 : volume)); + DocManager.Inst.ExecuteCmd(new VolumeChangeNotification(track.TrackNo, ApparentMute ? -24 : volume)); }); this.WhenAnyValue(x => x.Pan) .Subscribe(pan => { track.Pan = pan; DocManager.Inst.ExecuteCmd(new PanChangeNotification(track.TrackNo, pan)); }); - this.WhenAnyValue(x => x.Mute) - .Subscribe(mute => { - track.Mute = mute; - DocManager.Inst.ExecuteCmd(new VolumeChangeNotification(track.TrackNo, mute ? -24 : Volume)); + this.WhenAnyValue(x => x.ApparentMute) + .Subscribe(apparentMute => { + track.ApparentMute = apparentMute; + DocManager.Inst.ExecuteCmd(new VolumeChangeNotification(track.TrackNo, apparentMute ? -24 : Volume)); }); this.WhenAnyValue(x => x.Solo) .Subscribe(solo => { @@ -164,6 +160,21 @@ public void ToggleSolo() { MessageBus.Current.SendMessage(new TracksSoloEvent(track.TrackNo, !track.Solo)); } + public void ToggleMute() { + if (!track.Mute) { + track.Mute = true; + ApparentMute = true; + } else { + track.Mute = false; + if (PlaybackManager.Inst.SoloTrackExist) { + ApparentMute = true; + } else { + ApparentMute = false; + } + } + this.RaisePropertyChanged(nameof(ApparentMute)); + } + private bool TryChangePhonemizer(string phonemizerName) { try { var factory = DocManager.Inst.PhonemizerFactories.FirstOrDefault(factory => factory.type.FullName == phonemizerName); @@ -270,7 +281,7 @@ public void ManuallyRaise() { this.RaisePropertyChanged(nameof(Phonemizer)); this.RaisePropertyChanged(nameof(PhonemizerTag)); this.RaisePropertyChanged(nameof(Renderer)); - this.RaisePropertyChanged(nameof(Mute)); + this.RaisePropertyChanged(nameof(ApparentMute)); this.RaisePropertyChanged(nameof(Solo)); this.RaisePropertyChanged(nameof(Volume)); this.RaisePropertyChanged(nameof(Pan)); @@ -327,6 +338,7 @@ public void Duplicate() { Phonemizer = track.Phonemizer, RendererSettings = track.RendererSettings, Mute = track.Mute, + ApparentMute = track.ApparentMute, Solo = track.Solo, Volume = track.Volume, Pan = track.Pan, @@ -351,6 +363,7 @@ public void DuplicateSettings() { Phonemizer = track.Phonemizer, RendererSettings = track.RendererSettings, Mute = track.Mute, + ApparentMute = track.ApparentMute, Solo = track.Solo, Volume = track.Volume, Pan = track.Pan, diff --git a/OpenUtau/ViewModels/TracksViewModel.cs b/OpenUtau/ViewModels/TracksViewModel.cs index f19ba4f59..0cf817a06 100644 --- a/OpenUtau/ViewModels/TracksViewModel.cs +++ b/OpenUtau/ViewModels/TracksViewModel.cs @@ -21,6 +21,12 @@ public TracksSoloEvent(int trackNo, bool solo) { this.solo = solo; } } + public class TracksMuteEvent { + public readonly int trackNo; + public TracksMuteEvent(int trackNo) { + this.trackNo = trackNo; + } + } public class PartsSelectionEvent { public readonly UPart[] selectedParts; public readonly UPart[] tempSelectedParts; diff --git a/OpenUtau/Views/MainWindow.axaml.cs b/OpenUtau/Views/MainWindow.axaml.cs index a28db3f15..97f73b660 100644 --- a/OpenUtau/Views/MainWindow.axaml.cs +++ b/OpenUtau/Views/MainWindow.axaml.cs @@ -685,6 +685,7 @@ void OnKeyDown(object sender, KeyEventArgs args) { } else if (args.KeyModifiers == KeyModifiers.Shift) { args.Handled = true; switch (args.Key) { + // solo case Key.S: if (viewModel.TracksViewModel.SelectedParts.Count > 0) { var part = viewModel.TracksViewModel.SelectedParts.First(); @@ -692,7 +693,13 @@ void OnKeyDown(object sender, KeyEventArgs args) { MessageBus.Current.SendMessage(new TracksSoloEvent(part.trackNo, !track.Solo)); } break; - //case Key.M: ; break; + // mute + case Key.M: + if (viewModel.TracksViewModel.SelectedParts.Count > 0) { + var part = viewModel.TracksViewModel.SelectedParts.First(); + MessageBus.Current.SendMessage(new TracksMuteEvent(part.trackNo)); + } + break; default: args.Handled = false; break; diff --git a/OpenUtau/Views/PianoRollWindow.axaml.cs b/OpenUtau/Views/PianoRollWindow.axaml.cs index 1664b9c6e..f82b198e8 100644 --- a/OpenUtau/Views/PianoRollWindow.axaml.cs +++ b/OpenUtau/Views/PianoRollWindow.axaml.cs @@ -1236,6 +1236,12 @@ bool OnKeyExtendedHandler(KeyEventArgs args) { return true; } break; + case Key.M: + // mute + if (isShift) { + MessageBus.Current.SendMessage(new TracksMuteEvent(notesVm.Part.trackNo)); + } + break; case Key.F: // scroll selection into focus if (isNone) { From 56a19f43862ddd04877e85f49c5e06f8ac0d6652 Mon Sep 17 00:00:00 2001 From: Maiko Date: Mon, 5 Jun 2023 16:47:59 +0900 Subject: [PATCH 5/9] delete unnecessary --- OpenUtau/Views/MainWindow.axaml.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenUtau/Views/MainWindow.axaml.cs b/OpenUtau/Views/MainWindow.axaml.cs index 97f73b660..dec68295e 100644 --- a/OpenUtau/Views/MainWindow.axaml.cs +++ b/OpenUtau/Views/MainWindow.axaml.cs @@ -15,7 +15,6 @@ using Avalonia.Markup.Xaml; using Avalonia.Threading; using Avalonia.VisualTree; -using Melanchall.DryWetMidi.MusicTheory; using OpenUtau.App.Controls; using OpenUtau.App.ViewModels; using OpenUtau.Classic; From ce8c906ded5faa054d0529dc74f3afa534059556 Mon Sep 17 00:00:00 2001 From: Maiko Date: Mon, 5 Jun 2023 17:07:14 +0900 Subject: [PATCH 6/9] Revert "silence pan loging" This reverts commit 0cd320b52b8b583d8b48e8793411a7382a133891. --- OpenUtau.Core/Commands/Notifications.cs | 3 +-- OpenUtau/Views/PianoRollWindow.axaml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/OpenUtau.Core/Commands/Notifications.cs b/OpenUtau.Core/Commands/Notifications.cs index 7d0ed375b..48ae7ce42 100644 --- a/OpenUtau.Core/Commands/Notifications.cs +++ b/OpenUtau.Core/Commands/Notifications.cs @@ -1,4 +1,4 @@ -using System; +using System; using OpenUtau.Core.Ustx; namespace OpenUtau.Core { @@ -118,7 +118,6 @@ public VolumeChangeNotification(int trackNo, double volume) { public class PanChangeNotification : UNotification { public double Pan; public int TrackNo; - public override bool Silent => true; public PanChangeNotification(int trackNo, double pan) { TrackNo = trackNo; Pan = pan; diff --git a/OpenUtau/Views/PianoRollWindow.axaml b/OpenUtau/Views/PianoRollWindow.axaml index df55b4ceb..a2c73b2ab 100644 --- a/OpenUtau/Views/PianoRollWindow.axaml +++ b/OpenUtau/Views/PianoRollWindow.axaml @@ -322,7 +322,7 @@ + ToolTip.Tip="{DynamicResource pianoroll.toggle.noteparams}"> From 9a90e5509a872357a07550a037b0f333404e9572 Mon Sep 17 00:00:00 2001 From: Maiko Date: Mon, 5 Jun 2023 17:07:22 +0900 Subject: [PATCH 7/9] Revert "fix updater dialog crash" This reverts commit a11623da32476d2b4332c6665f5e46015b85f390. --- OpenUtau/ViewModels/UpdaterViewModel.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/OpenUtau/ViewModels/UpdaterViewModel.cs b/OpenUtau/ViewModels/UpdaterViewModel.cs index 6b030b8a1..b59d66f63 100644 --- a/OpenUtau/ViewModels/UpdaterViewModel.cs +++ b/OpenUtau/ViewModels/UpdaterViewModel.cs @@ -104,13 +104,8 @@ public UpdaterViewModel() { async void Init() { UpdaterStatus = ThemeManager.GetString("updater.status.checking"); sparkle = await NewUpdaterAsync(); - if (sparkle == null) { - UpdaterStatus = ThemeManager.GetString("updater.status.unknown"); - return; - } updateInfo = await sparkle.CheckForUpdatesQuietly(); if (updateInfo == null) { - UpdaterStatus = ThemeManager.GetString("updater.status.unknown"); return; } switch (updateInfo.Status) { From a137775a6f1c5a110ed84189eac44784eb1d9450 Mon Sep 17 00:00:00 2001 From: Maiko Date: Tue, 13 Jun 2023 01:19:11 +0900 Subject: [PATCH 8/9] Add [YamlIgnore] and rename Muted --- OpenUtau.Core/PlaybackManager.cs | 2 +- OpenUtau.Core/Render/RenderEngine.cs | 2 +- OpenUtau.Core/Ustx/UTrack.cs | 4 ++- OpenUtau/Controls/TrackHeader.axaml | 2 +- OpenUtau/Controls/TrackHeaderCanvas.cs | 11 +++++--- OpenUtau/ViewModels/TrackHeaderViewModel.cs | 28 ++++++++++----------- 6 files changed, 27 insertions(+), 22 deletions(-) diff --git a/OpenUtau.Core/PlaybackManager.cs b/OpenUtau.Core/PlaybackManager.cs index a29ef5570..2b4a6d053 100644 --- a/OpenUtau.Core/PlaybackManager.cs +++ b/OpenUtau.Core/PlaybackManager.cs @@ -171,7 +171,7 @@ public void RenderToFiles(UProject project, string exportPath) { RenderEngine engine = new RenderEngine(project); var trackMixes = engine.RenderTracks(DocManager.Inst.MainScheduler, ref renderCancellation); for (int i = 0; i < trackMixes.Count; ++i) { - if (trackMixes[i] == null || i >= project.tracks.Count || project.tracks[i].ApparentMute) { + if (trackMixes[i] == null || i >= project.tracks.Count || project.tracks[i].Muted) { continue; } var file = PathManager.Inst.GetExportPath(exportPath, project.tracks[i]); diff --git a/OpenUtau.Core/Render/RenderEngine.cs b/OpenUtau.Core/Render/RenderEngine.cs index f60ad1d3e..3f3ba17fb 100644 --- a/OpenUtau.Core/Render/RenderEngine.cs +++ b/OpenUtau.Core/Render/RenderEngine.cs @@ -85,7 +85,7 @@ public Tuple> RenderMixdown(int startTick, TaskScheduler ui })); var trackMix = new WaveMix(trackSources); var fader = new Fader(trackMix); - fader.Scale = PlaybackManager.DecibelToVolume(track.ApparentMute ? -24 : track.Volume); + fader.Scale = PlaybackManager.DecibelToVolume(track.Muted ? -24 : track.Volume); fader.Pan = (float)track.Pan; fader.SetScaleToTarget(); faders.Add(fader); diff --git a/OpenUtau.Core/Ustx/UTrack.cs b/OpenUtau.Core/Ustx/UTrack.cs index 21bc5ade1..c2e915bb4 100644 --- a/OpenUtau.Core/Ustx/UTrack.cs +++ b/OpenUtau.Core/Ustx/UTrack.cs @@ -88,7 +88,7 @@ public USinger Singer { [YamlIgnore] public string SingerName => Singer != null ? Singer.DisplayName : "[No Singer]"; [YamlIgnore] public int TrackNo { set; get; } public string TrackName { get; set; } = "New Track"; - public bool ApparentMute { set; get; } + [YamlIgnore] public bool Muted { set; get; } public bool Mute { get; set; } public bool Solo { get; set; } public double Volume { set; get; } @@ -181,6 +181,8 @@ public void AfterLoad(UProject project) { TrackNo = project.tracks.IndexOf(this); if (Solo) { PlaybackManager.Inst.SoloTrackExist = true; + } else if (Mute) { + Muted = true; } } } diff --git a/OpenUtau/Controls/TrackHeader.axaml b/OpenUtau/Controls/TrackHeader.axaml index d8a0ed0dd..530dc68ed 100644 --- a/OpenUtau/Controls/TrackHeader.axaml +++ b/OpenUtau/Controls/TrackHeader.axaml @@ -82,7 +82,7 @@ + IsChecked="{Binding Muted, Mode=OneWay}" Command="{Binding ToggleMute}"> () .Subscribe(_ => { foreach (var (track, header) in trackHeaders) { + if (PlaybackManager.Inst.SoloTrackExist && !track.Solo) { + header.ViewModel.Muted = true; + } header.ViewModel?.ManuallyRaise(); } if (trackAdder != null) { @@ -67,10 +70,10 @@ public TrackHeaderCanvas() { if (track.TrackNo == e.trackNo) { header.ViewModel.Solo = true; - header.ViewModel.ApparentMute = false; + header.ViewModel.Muted = false; } else { header.ViewModel.Solo = false; - header.ViewModel.ApparentMute = true; + header.ViewModel.Muted = true; } } else { PlaybackManager.Inst.SoloTrackExist = false; @@ -78,9 +81,9 @@ public TrackHeaderCanvas() { header.ViewModel.Solo = false; } if (track.Mute) { - header.ViewModel.ApparentMute = true; + header.ViewModel.Muted = true; } else { - header.ViewModel.ApparentMute = false; + header.ViewModel.Muted = false; } } header.ViewModel.ManuallyRaise(); diff --git a/OpenUtau/ViewModels/TrackHeaderViewModel.cs b/OpenUtau/ViewModels/TrackHeaderViewModel.cs index a232845a5..f9e436324 100644 --- a/OpenUtau/ViewModels/TrackHeaderViewModel.cs +++ b/OpenUtau/ViewModels/TrackHeaderViewModel.cs @@ -33,7 +33,7 @@ public class TrackHeaderViewModel : ViewModelBase, IActivatableViewModel { [Reactive] public string TrackName { get; set; } [Reactive] public double Volume { get; set; } [Reactive] public double Pan { get; set; } - [Reactive] public bool ApparentMute { get; set; } + [Reactive] public bool Muted { get; set; } [Reactive] public bool Solo { get; set; } [Reactive] public Bitmap? Avatar { get; set; } @@ -131,22 +131,22 @@ public TrackHeaderViewModel(UTrack track) { TrackName = track.TrackName; Volume = track.Volume; Pan = track.Pan; - ApparentMute = track.ApparentMute; + Muted = track.Muted; Solo = track.Solo; this.WhenAnyValue(x => x.Volume) .Subscribe(volume => { track.Volume = volume; - DocManager.Inst.ExecuteCmd(new VolumeChangeNotification(track.TrackNo, ApparentMute ? -24 : volume)); + DocManager.Inst.ExecuteCmd(new VolumeChangeNotification(track.TrackNo, Muted ? -24 : volume)); }); this.WhenAnyValue(x => x.Pan) .Subscribe(pan => { track.Pan = pan; DocManager.Inst.ExecuteCmd(new PanChangeNotification(track.TrackNo, pan)); }); - this.WhenAnyValue(x => x.ApparentMute) - .Subscribe(apparentMute => { - track.ApparentMute = apparentMute; - DocManager.Inst.ExecuteCmd(new VolumeChangeNotification(track.TrackNo, apparentMute ? -24 : Volume)); + this.WhenAnyValue(x => x.Muted) + .Subscribe(muted => { + track.Muted = muted; + DocManager.Inst.ExecuteCmd(new VolumeChangeNotification(track.TrackNo, muted ? -24 : Volume)); }); this.WhenAnyValue(x => x.Solo) .Subscribe(solo => { @@ -163,16 +163,16 @@ public void ToggleSolo() { public void ToggleMute() { if (!track.Mute) { track.Mute = true; - ApparentMute = true; + Muted = true; } else { track.Mute = false; if (PlaybackManager.Inst.SoloTrackExist) { - ApparentMute = true; + Muted = true; } else { - ApparentMute = false; + Muted = false; } } - this.RaisePropertyChanged(nameof(ApparentMute)); + this.RaisePropertyChanged(nameof(Muted)); } private bool TryChangePhonemizer(string phonemizerName) { @@ -281,7 +281,7 @@ public void ManuallyRaise() { this.RaisePropertyChanged(nameof(Phonemizer)); this.RaisePropertyChanged(nameof(PhonemizerTag)); this.RaisePropertyChanged(nameof(Renderer)); - this.RaisePropertyChanged(nameof(ApparentMute)); + this.RaisePropertyChanged(nameof(Muted)); this.RaisePropertyChanged(nameof(Solo)); this.RaisePropertyChanged(nameof(Volume)); this.RaisePropertyChanged(nameof(Pan)); @@ -338,7 +338,7 @@ public void Duplicate() { Phonemizer = track.Phonemizer, RendererSettings = track.RendererSettings, Mute = track.Mute, - ApparentMute = track.ApparentMute, + Muted = track.Muted, Solo = track.Solo, Volume = track.Volume, Pan = track.Pan, @@ -363,7 +363,7 @@ public void DuplicateSettings() { Phonemizer = track.Phonemizer, RendererSettings = track.RendererSettings, Mute = track.Mute, - ApparentMute = track.ApparentMute, + Muted = track.Muted, Solo = track.Solo, Volume = track.Volume, Pan = track.Pan, From 79309f5d54683d38992c0c9dfda98d2c238cdc6b Mon Sep 17 00:00:00 2001 From: StAkira Date: Wed, 14 Jun 2023 23:32:22 -0700 Subject: [PATCH 9/9] Fix nullness --- OpenUtau/Controls/TrackHeaderCanvas.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenUtau/Controls/TrackHeaderCanvas.cs b/OpenUtau/Controls/TrackHeaderCanvas.cs index 39951cd2e..fb9943be8 100644 --- a/OpenUtau/Controls/TrackHeaderCanvas.cs +++ b/OpenUtau/Controls/TrackHeaderCanvas.cs @@ -52,10 +52,13 @@ public TrackHeaderCanvas() { MessageBus.Current.Listen() .Subscribe(_ => { foreach (var (track, header) in trackHeaders) { + if (header.ViewModel == null) { + continue; + } if (PlaybackManager.Inst.SoloTrackExist && !track.Solo) { header.ViewModel.Muted = true; } - header.ViewModel?.ManuallyRaise(); + header.ViewModel.ManuallyRaise(); } if (trackAdder != null) { trackAdder.TrackNo = trackHeaders.Count;