Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add overwrite option to DrawPitchTool #1089

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions OpenUtau.Core/Util/Preferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public class SerializablePreferences {
public bool ShowTips = true;
public int Theme;
public bool PenPlusDefault = false;
public bool OverwritePitchDrawTool = false;
public int DegreeStyle;
public bool UseTrackColor = false;
public bool ClearCacheOnQuit = false;
Expand Down
2 changes: 2 additions & 0 deletions OpenUtau/Strings/Strings.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@
<system:String x:Key="menu.edit.lockunselectednotes.pitchpoints">Pitch Points</system:String>
<system:String x:Key="menu.edit.lockunselectednotes.vibrato">Vibrato</system:String>
<system:String x:Key="menu.edit.lockunselectednotes.expressions">Expressions</system:String>
<system:String x:Key="menu.edit.overwritepitchdrawtool">Draw Pitch Tool to overwrite vibrato or MOD+</system:String>
<system:String x:Key="menu.edit.paste">Paste</system:String>
<system:String x:Key="menu.edit.redo">Redo</system:String>
<system:String x:Key="menu.edit.selectall">Select All</system:String>
<system:String x:Key="menu.edit.tooloptions">Tool Options</system:String>
<system:String x:Key="menu.edit.undo">Undo</system:String>
<system:String x:Key="menu.file">File</system:String>
<system:String x:Key="menu.file.exit">Exit</system:String>
Expand Down
2 changes: 2 additions & 0 deletions OpenUtau/Strings/Strings.ja-JP.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@
<system:String x:Key="menu.edit.lockunselectednotes.pitchpoints">ピッチ点</system:String>
<system:String x:Key="menu.edit.lockunselectednotes.vibrato">ビブラート</system:String>
<system:String x:Key="menu.edit.lockunselectednotes.expressions">表情</system:String>
<system:String x:Key="menu.edit.overwritepitchdrawtool">ピッチ描画ツールでビブラートやMOD+を上書きする</system:String>
<system:String x:Key="menu.edit.paste">貼り付け</system:String>
<system:String x:Key="menu.edit.redo">やり直す</system:String>
<system:String x:Key="menu.edit.selectall">全て選択</system:String>
<system:String x:Key="menu.edit.tooloptions">ツールオプション</system:String>
<system:String x:Key="menu.edit.undo">元に戻す</system:String>
<system:String x:Key="menu.file">ファイル</system:String>
<system:String x:Key="menu.file.exit">OpenUTAUを終了</system:String>
Expand Down
47 changes: 33 additions & 14 deletions OpenUtau/ViewModels/NotesViewModelHitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using OpenUtau.App.Controls;
using OpenUtau.Core;
using OpenUtau.Core.Ustx;
using OpenUtau.Core.Util;

namespace OpenUtau.App.ViewModels {
public struct NoteHitInfo {
Expand Down Expand Up @@ -200,22 +201,40 @@ public PitchPointHitInfo HitTestPitchPoint(Point point) {
return null;
}
double tick = viewModel.PointToTick(point);
var note = viewModel.Part.notes.FirstOrDefault(n => n.End >= tick);
if (note == null && viewModel.Part.notes.Count > 0) {
note = viewModel.Part.notes.Last();
}
if (note == null) {
return null;
}
double pitch = note.tone * 100;
pitch += note.pitch.Sample(viewModel.Project, viewModel.Part, note, tick) ?? 0;
if (note.Next != null && note.Next.position == note.End) {
double? delta = note.Next.pitch.Sample(viewModel.Project, viewModel.Part, note.Next, tick);
if (delta != null) {
pitch += delta.Value + note.Next.tone * 100 - note.tone * 100;

if (Preferences.Default.OverwritePitchDrawTool) {
if (viewModel.Part.renderPhrases.Count == 0) {
return null;
}
var phrase = viewModel.Part.renderPhrases.FirstOrDefault(p => p.position - p.leading >= tick);
if (phrase == null) {
phrase = viewModel.Part.renderPhrases.Last();
}
if (phrase == null || phrase.pitchesBeforeDeviation.Length == 0) {
return null;
}
var curve = phrase.pitchesBeforeDeviation;
var pitchIndex = (int)Math.Round((tick - phrase.position + phrase.leading) / 5);
pitchIndex = Math.Clamp(pitchIndex, 0, curve.Length - 1);
return curve[pitchIndex];
} else {
var note = viewModel.Part.notes.FirstOrDefault(n => n.End >= tick);
if (note == null && viewModel.Part.notes.Count > 0) {
note = viewModel.Part.notes.Last();
}
if (note == null) {
return null;
}
double pitch = note.tone * 100;
pitch += note.pitch.Sample(viewModel.Project, viewModel.Part, note, tick) ?? 0;
if (note.Next != null && note.Next.position == note.End) {
double? delta = note.Next.pitch.Sample(viewModel.Project, viewModel.Part, note.Next, tick);
if (delta != null) {
pitch += delta.Value + note.Next.tone * 100 - note.tone * 100;
}
}
return pitch;
}
return pitch;
}

public VibratoHitInfo HitTestVibrato(Point mousePos) {
Expand Down
1 change: 1 addition & 0 deletions OpenUtau/ViewModels/PianoRollViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class PianoRollViewModel : ViewModelBase, ICmdSubscriber {
public bool LockPitchPoints { get => Preferences.Default.LockUnselectedNotesPitch; }
public bool LockVibrato { get => Preferences.Default.LockUnselectedNotesVibrato; }
public bool LockExpressions { get => Preferences.Default.LockUnselectedNotesExpressions; }
public bool OverwritePitchDrawTool { get => Preferences.Default.OverwritePitchDrawTool; }
public bool ShowPortrait { get => Preferences.Default.ShowPortrait; }
public bool ShowIcon { get => Preferences.Default.ShowIcon; }
public bool ShowGhostNotes { get => Preferences.Default.ShowGhostNotes; }
Expand Down
7 changes: 7 additions & 0 deletions OpenUtau/Views/PianoRollWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@
</MenuItem.Icon>
</MenuItem>
</MenuItem>
<MenuItem Header="{DynamicResource menu.edit.tooloptions}">
<MenuItem Header="{DynamicResource menu.edit.overwritepitchdrawtool}" Click="OnMenuOverwritePitchDrawTool">
<MenuItem.Icon>
<CheckBox IsChecked="{Binding OverwritePitchDrawTool}" />
</MenuItem.Icon>
</MenuItem>
</MenuItem>
</MenuItem>

<MenuItem Header="{DynamicResource menu.view}">
Expand Down
5 changes: 5 additions & 0 deletions OpenUtau/Views/PianoRollWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ void OnMenuLockExpressions(object sender, RoutedEventArgs args) {
Preferences.Save();
ViewModel.RaisePropertyChanged(nameof(ViewModel.LockExpressions));
}
void OnMenuOverwritePitchDrawTool(object sender, RoutedEventArgs args) {
Preferences.Default.OverwritePitchDrawTool = !Preferences.Default.OverwritePitchDrawTool;
Preferences.Save();
ViewModel.RaisePropertyChanged(nameof(ViewModel.OverwritePitchDrawTool));
}

// View menu
void OnMenuShowPortrait(object sender, RoutedEventArgs args) {
Expand Down