From 1e6bc4ca8b8bea3ab736a219047dda4bcefc6d28 Mon Sep 17 00:00:00 2001
From: deagahelio <16138291+deagahelio@users.noreply.github.com>
Date: Mon, 12 Apr 2021 18:12:51 -0300
Subject: [PATCH] Add hidden track/pre-emphasis flag displays to UI
---
RedBookPlayer/Player.cs | 17 ++++++++++-------
RedBookPlayer/PlayerView.xaml | 10 ++++++++--
RedBookPlayer/PlayerView.xaml.cs | 27 +++++++++++++++++++++------
3 files changed, 39 insertions(+), 15 deletions(-)
diff --git a/RedBookPlayer/Player.cs b/RedBookPlayer/Player.cs
index 0e7c4eb..0a6397a 100644
--- a/RedBookPlayer/Player.cs
+++ b/RedBookPlayer/Player.cs
@@ -42,18 +42,20 @@ namespace RedBookPlayer
}
byte[] flagsData = Image.ReadSectorTag(Image.Tracks[CurrentTrack].TrackSequence, SectorTagType.CdTrackFlags);
- HasPreEmphasis = ((CdFlags)flagsData[0]).HasFlag(CdFlags.PreEmphasis);
+ ApplyDeEmphasis = ((CdFlags)flagsData[0]).HasFlag(CdFlags.PreEmphasis);
- if (!HasPreEmphasis)
+ if (!ApplyDeEmphasis)
{
byte[] subchannel = Image.ReadSectorTag(
Image.Tracks[CurrentTrack].TrackStartSector,
SectorTagType.CdSectorSubchannel
);
- HasPreEmphasis = (subchannel[3] & 0b01000000) != 0;
+ ApplyDeEmphasis = (subchannel[3] & 0b01000000) != 0;
}
+ TrackHasEmphasis = ApplyDeEmphasis;
+
TotalIndexes = Image.Tracks[CurrentTrack].Indexes.Count;
CurrentIndex = Image.Tracks[CurrentTrack].Indexes.Keys.GetEnumerator().Current;
}
@@ -96,7 +98,8 @@ namespace RedBookPlayer
}
}
}
- public bool HasPreEmphasis { get; private set; } = false;
+ public bool TrackHasEmphasis { get; private set; } = false;
+ public bool ApplyDeEmphasis { get; private set; } = false;
public int TotalTracks { get; private set; } = 0;
public int TotalIndexes { get; private set; } = 0;
public ulong TimeOffset { get; private set; } = 0;
@@ -269,7 +272,7 @@ namespace RedBookPlayer
byte[] audioDataSegment = new byte[count];
Array.Copy(audioData, currentSectorReadPosition, audioDataSegment, 0, count);
- if (HasPreEmphasis)
+ if (ApplyDeEmphasis)
{
float[][] floatAudioData = new float[2][];
floatAudioData[0] = new float[audioDataSegment.Length / 4];
@@ -451,12 +454,12 @@ namespace RedBookPlayer
public void EnableDeEmphasis()
{
- HasPreEmphasis = true;
+ ApplyDeEmphasis = true;
}
public void DisableDeEmphasis()
{
- HasPreEmphasis = false;
+ ApplyDeEmphasis = false;
}
}
diff --git a/RedBookPlayer/PlayerView.xaml b/RedBookPlayer/PlayerView.xaml
index e54f191..a940140 100644
--- a/RedBookPlayer/PlayerView.xaml
+++ b/RedBookPlayer/PlayerView.xaml
@@ -65,9 +65,15 @@
+
+
+
+
-
-
+ HIDDEN
+ HIDDEN
+ EMPHASIS
+ EMPHASIS
diff --git a/RedBookPlayer/PlayerView.xaml.cs b/RedBookPlayer/PlayerView.xaml.cs
index 940f82d..15989ac 100644
--- a/RedBookPlayer/PlayerView.xaml.cs
+++ b/RedBookPlayer/PlayerView.xaml.cs
@@ -57,7 +57,8 @@ namespace RedBookPlayer
await Dispatcher.UIThread.InvokeAsync(() =>
{
MainWindow.Instance.Title = "RedBookPlayer - " + path.Split('/').Last().Split('\\').Last();
- });
+ }
+ );
}
public async Task GetPath()
@@ -157,7 +158,9 @@ namespace RedBookPlayer
}
}
- ((PlayerViewModel)DataContext).PreEmphasis = Player.HasPreEmphasis;
+ ((PlayerViewModel)DataContext).HiddenTrack = Player.TimeOffset > 150;
+ ((PlayerViewModel)DataContext).ApplyDeEmphasis = Player.ApplyDeEmphasis;
+ ((PlayerViewModel)DataContext).TrackHasEmphasis = Player.TrackHasEmphasis;
});
}
else
@@ -254,11 +257,23 @@ namespace RedBookPlayer
public class PlayerViewModel : ReactiveObject
{
- private bool preEmphasis;
- public bool PreEmphasis
+ private bool applyDeEmphasis;
+ public bool ApplyDeEmphasis
{
- get => preEmphasis;
- set => this.RaiseAndSetIfChanged(ref preEmphasis, value);
+ get => applyDeEmphasis;
+ set => this.RaiseAndSetIfChanged(ref applyDeEmphasis, value);
+ }
+ private bool trackHasEmphasis;
+ public bool TrackHasEmphasis
+ {
+ get => trackHasEmphasis;
+ set => this.RaiseAndSetIfChanged(ref trackHasEmphasis, value);
+ }
+ private bool hiddenTrack;
+ public bool HiddenTrack
+ {
+ get => hiddenTrack;
+ set => this.RaiseAndSetIfChanged(ref hiddenTrack, value);
}
}
}
\ No newline at end of file