Add audio, data and copy flags

This commit is contained in:
deagahelio
2021-04-14 20:36:34 -03:00
parent 916c10a8a0
commit 2b1cf26942
3 changed files with 50 additions and 10 deletions

View File

@@ -10,11 +10,18 @@ using CSCore;
using NWaves.Audio;
using NWaves.Filters.BiQuad;
using static Aaru.Decoders.CD.FullTOC;
using Aaru.CommonTypes.Structs;
namespace RedBookPlayer
{
public class Player
{
public enum TrackType
{
Audio,
Data
}
public bool Initialized = false;
private int currentTrack = 0;
public int CurrentTrack
@@ -44,16 +51,19 @@ namespace RedBookPlayer
byte[] flagsData = Image.ReadSectorTag(Image.Tracks[CurrentTrack].TrackSequence, SectorTagType.CdTrackFlags);
ApplyDeEmphasis = ((CdFlags)flagsData[0]).HasFlag(CdFlags.PreEmphasis);
byte[] subchannel = Image.ReadSectorTag(
Image.Tracks[CurrentTrack].TrackStartSector,
SectorTagType.CdSectorSubchannel
);
if (!ApplyDeEmphasis)
{
byte[] subchannel = Image.ReadSectorTag(
Image.Tracks[CurrentTrack].TrackStartSector,
SectorTagType.CdSectorSubchannel
);
ApplyDeEmphasis = (subchannel[3] & 0b01000000) != 0;
}
CopyAllowed = (subchannel[2] & 0b01000000) != 0;
TrackType_ = (subchannel[1] & 0b01000000) != 0 ? TrackType.Data : TrackType.Audio;
TrackHasEmphasis = ApplyDeEmphasis;
TotalIndexes = Image.Tracks[CurrentTrack].Indexes.Keys.Max();
@@ -104,6 +114,8 @@ namespace RedBookPlayer
}
public bool TrackHasEmphasis { get; private set; } = false;
public bool ApplyDeEmphasis { get; private set; } = false;
public bool CopyAllowed { get; private set; } = false;
public TrackType? TrackType_ { get; private set; }
public int TotalTracks { get; private set; } = 0;
public int TotalIndexes { get; private set; } = 0;
public ulong TimeOffset { get; private set; } = 0;

View File

@@ -83,10 +83,16 @@
<Button Click="DisableDeEmphasisButton_Click" IsVisible="{Binding ApplyDeEmphasis}" Width="200" Margin="0,0,16,0">Disable De-Emphasis</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<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 !IsAudioTrack}">AUDIO</TextBlock>
<TextBlock Margin="0,0,16,0" IsVisible="{Binding IsAudioTrack}">AUDIO</TextBlock>
<TextBlock Margin="0,0,16,0" Foreground="LightGray" IsVisible="{Binding !IsDataTrack}">DATA</TextBlock>
<TextBlock Margin="0,0,16,0" IsVisible="{Binding IsDataTrack}">DATA</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>
<TextBlock Margin="0,0,16,0" Foreground="LightGray" IsVisible="{Binding !CopyAllowed}">COPY</TextBlock>
<TextBlock Margin="0,0,16,0" IsVisible="{Binding CopyAllowed}">COPY</TextBlock>
<TextBlock Margin="0,0,16,0" Foreground="LightGray" IsVisible="{Binding !HiddenTrack}">HIDDEN</TextBlock>
<TextBlock Margin="0,0,16,0" IsVisible="{Binding HiddenTrack}">HIDDEN</TextBlock>
</StackPanel>
</StackPanel>
</UserControl>

View File

@@ -161,9 +161,13 @@ namespace RedBookPlayer
}
}
((PlayerViewModel)DataContext).HiddenTrack = Player.TimeOffset > 150;
((PlayerViewModel)DataContext).ApplyDeEmphasis = Player.ApplyDeEmphasis;
((PlayerViewModel)DataContext).TrackHasEmphasis = Player.TrackHasEmphasis;
PlayerViewModel dataContext = (PlayerViewModel)DataContext;
dataContext.HiddenTrack = Player.TimeOffset > 150;
dataContext.ApplyDeEmphasis = Player.ApplyDeEmphasis;
dataContext.TrackHasEmphasis = Player.TrackHasEmphasis;
dataContext.CopyAllowed = Player.CopyAllowed;
dataContext.IsAudioTrack = Player.TrackType_ == Player.TrackType.Audio;
dataContext.IsDataTrack = Player.TrackType_ == Player.TrackType.Data;
});
}
else
@@ -285,5 +289,23 @@ namespace RedBookPlayer
get => hiddenTrack;
set => this.RaiseAndSetIfChanged(ref hiddenTrack, value);
}
private bool copyAllowed;
public bool CopyAllowed
{
get => copyAllowed;
set => this.RaiseAndSetIfChanged(ref copyAllowed, value);
}
private bool isAudioTrack;
public bool IsAudioTrack
{
get => isAudioTrack;
set => this.RaiseAndSetIfChanged(ref isAudioTrack, value);
}
private bool isDataTrack;
public bool IsDataTrack
{
get => isDataTrack;
set => this.RaiseAndSetIfChanged(ref isDataTrack, value);
}
}
}