mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2026-09-17 04:14:17 +00:00
Add hidden track/pre-emphasis flag displays to UI
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,9 +65,15 @@
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,16">
|
||||
<Button Click="EnableDeEmphasisButton_Click" IsVisible="{Binding !ApplyDeEmphasis}" Width="200" Margin="0,0,16,0">Enable De-Emphasis</Button>
|
||||
<Button Click="DisableDeEmphasisButton_Click" IsVisible="{Binding ApplyDeEmphasis}" Width="200" Margin="0,0,16,0">Disable De-Emphasis</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Button Click="EnableDeEmphasisButton_Click" IsVisible="{Binding !PreEmphasis}" Width="200" Margin="0,0,16,0">Enable De-Emphasis</Button>
|
||||
<Button Click="DisableDeEmphasisButton_Click" IsVisible="{Binding PreEmphasis}" Width="200" Margin="0,0,16,0">Disable De-Emphasis</Button>
|
||||
<TextBlock Margin="0,0,16,0" Foreground="LightGray" IsVisible="{Binding !HiddenTrack}">HIDDEN</TextBlock>
|
||||
<TextBlock Margin="0,0,16,0" IsVisible="{Binding HiddenTrack}">HIDDEN</TextBlock>
|
||||
<TextBlock Margin="0,0,16,0" Foreground="LightGray" IsVisible="{Binding !TrackHasEmphasis}">EMPHASIS</TextBlock>
|
||||
<TextBlock Margin="0,0,16,0" IsVisible="{Binding TrackHasEmphasis}">EMPHASIS</TextBlock>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -57,7 +57,8 @@ namespace RedBookPlayer
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
MainWindow.Instance.Title = "RedBookPlayer - " + path.Split('/').Last().Split('\\').Last();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public async Task<string> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user