Skip to content

Commit

Permalink
Transpose Piano Sheet as well
Browse files Browse the repository at this point in the history
Fixes #20
  • Loading branch information
sabihoshi committed Jan 5, 2022
1 parent 35e876e commit ef78f74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
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.3</Version>
<Version>3.0.0</Version>
<ApplicationIcon>item_windsong_lyre.ico</ApplicationIcon>
<Nullable>enable</Nullable>
<RepositoryUrl>https://github.com/sabihoshi/GenshinLyreMidiPlayer</RepositoryUrl>
Expand Down
23 changes: 13 additions & 10 deletions GenshinLyreMidiPlayer.WPF/ViewModels/PianoSheetViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Melanchall.DryWetMidi.Interaction;
using PropertyChanged;
using Stylet;
using static GenshinLyreMidiPlayer.WPF.Core.LyrePlayer.Transpose;

namespace GenshinLyreMidiPlayer.WPF.ViewModels;

Expand Down Expand Up @@ -35,7 +36,7 @@ public PianoSheetViewModel(SettingsPageViewModel settingsPage,

public SettingsPageViewModel SettingsPage { get; }

public string Result { get; private set; }
public string Result { get; private set; } = string.Empty;

[OnChangedMethod(nameof(Update))]
public uint Bars
Expand Down Expand Up @@ -82,17 +83,19 @@ public void Update()

foreach (var note in notes)
{
var id = LyrePlayer.TransposeNote(note.NoteNumber);
if (layout.TryGetKey(id, out var key))
{
var difference = note.Time - last;
var dotCount = difference / Shorten;
var offset = note.NoteNumber - SettingsPage.KeyOffset;
var transpose = SettingsPage.Transpose ?? Ignore;
var id = LyrePlayer.TransposeNote(offset, transpose);

sb.Append(new string(Delimiter, (int) dotCount));
sb.Append(key.ToString().Last());
if (!layout.TryGetKey(id, out var key)) continue;

last = (int) note.Time;
}
var difference = note.Time - last;
var dotCount = difference / Shorten;

sb.Append(new string(Delimiter, (int) dotCount));
sb.Append(key.ToString().Last());

last = (int) note.Time;
}

sb.AppendLine();
Expand Down

0 comments on commit ef78f74

Please sign in to comment.