Skip to content

Commit

Permalink
Add [YamlIgnore] and rename Muted
Browse files Browse the repository at this point in the history
  • Loading branch information
maiko3tattun committed Jun 12, 2023
1 parent 9a90e55 commit a137775
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion OpenUtau.Core/PlaybackManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion OpenUtau.Core/Render/RenderEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public Tuple<WaveMix, List<Fader>> 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);
Expand Down
4 changes: 3 additions & 1 deletion OpenUtau.Core/Ustx/UTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion OpenUtau/Controls/TrackHeader.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
</Button>
<ToggleButton Grid.Row="1" Grid.Column="3" Margin="1" Padding="0" Height="18"
HorizontalAlignment="Stretch"
IsChecked="{Binding ApparentMute, Mode=OneWay}" Command="{Binding ToggleMute}">
IsChecked="{Binding Muted, Mode=OneWay}" Command="{Binding ToggleMute}">
<TextBlock Text="M" TextAlignment="Center"/>
</ToggleButton>
<ToggleButton Grid.Row="2" Grid.Column="3" Margin="1" Padding="0" Height="18"
Expand Down
11 changes: 7 additions & 4 deletions OpenUtau/Controls/TrackHeaderCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public TrackHeaderCanvas() {
MessageBus.Current.Listen<TracksRefreshEvent>()
.Subscribe(_ => {
foreach (var (track, header) in trackHeaders) {
if (PlaybackManager.Inst.SoloTrackExist && !track.Solo) {
header.ViewModel.Muted = true;
}
header.ViewModel?.ManuallyRaise();
}
if (trackAdder != null) {
Expand All @@ -67,20 +70,20 @@ 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;
if (track.TrackNo == e.trackNo) {
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();
Expand Down
28 changes: 14 additions & 14 deletions OpenUtau/ViewModels/TrackHeaderViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -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 => {
Expand All @@ -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) {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit a137775

Please sign in to comment.