Skip to content

Commit

Permalink
Ask transpose option for out of range notes only once
Browse files Browse the repository at this point in the history
  • Loading branch information
sabihoshi committed Jul 30, 2021
1 parent 6e53bcf commit acf8bdc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions GenshinLyreMidiPlayer.WPF/Core/LyrePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace GenshinLyreMidiPlayer.WPF.Core
{
public static class LyrePlayer
{
public enum Tranpose
public enum Transpose
{
Ignore,
Up,
Expand Down Expand Up @@ -46,7 +46,7 @@ public enum Tranpose
};

public static int TransposeNote(int noteId,
Tranpose direction = Tranpose.Ignore)
Transpose direction = Transpose.Ignore)
{
while (true)
{
Expand All @@ -61,9 +61,9 @@ public static int TransposeNote(int noteId,
{
return direction switch
{
Tranpose.Ignore => noteId,
Tranpose.Up => ++noteId,
Tranpose.Down => --noteId
Transpose.Ignore => noteId,
Transpose.Up => ++noteId,
Transpose.Down => --noteId
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion GenshinLyreMidiPlayer.WPF/GenshinLyreMidiPlayer.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UseWPF>true</UseWPF>
<StartupObject>GenshinLyreMidiPlayer.WPF.App</StartupObject>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Version>2.3.1</Version>
<Version>2.3.2</Version>
<ApplicationIcon>item_windsong_lyre.ico</ApplicationIcon>
<Nullable>enable</Nullable>
<RepositoryUrl>https://github.com/sabihoshi/GenshinLyreMidiPlayer</RepositoryUrl>
Expand Down
6 changes: 3 additions & 3 deletions GenshinLyreMidiPlayer.WPF/ViewModels/LyrePlayerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using Stylet;
using StyletIoC;
using static Windows.Media.MediaPlaybackAutoRepeatMode;
using static GenshinLyreMidiPlayer.WPF.Core.LyrePlayer.Tranpose;
using static GenshinLyreMidiPlayer.WPF.Core.LyrePlayer.Transpose;
using MidiFile = GenshinLyreMidiPlayer.Data.Midi.MidiFile;

namespace GenshinLyreMidiPlayer.WPF.ViewModels
Expand Down Expand Up @@ -298,7 +298,7 @@ private async Task InitializePlayback()
var outOfRange = midi.GetNotes().Where(note =>
!_settings.SelectedLayout.Key.TryGetKey(ApplyNoteSettings(note.NoteNumber), out _));

if (outOfRange.Any())
if (_settings.Transpose is null && outOfRange.Any())
{
await Application.Current.Dispatcher.Invoke(async () =>
{
Expand Down Expand Up @@ -352,7 +352,7 @@ private int ApplyNoteSettings(int noteId)
noteId -= Settings.KeyOffset;

if (Settings.TransposeNotes)
noteId = LyrePlayer.TransposeNote(noteId, _settings.Transpose);
noteId = LyrePlayer.TransposeNote(noteId, _settings.Transpose ?? Ignore);

return noteId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public int KeyOffset

public string UpdateString { get; set; } = string.Empty;

public LyrePlayer.Tranpose Transpose { get; set; } = LyrePlayer.Tranpose.Ignore;
public LyrePlayer.Transpose? Transpose { get; set; }

public uint MergeMilliseconds { get; set; } = Settings.MergeMilliseconds;

Expand Down

0 comments on commit acf8bdc

Please sign in to comment.