mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 19:24:41 +00:00
DataPlayback option applies to saving tracks
This commit is contained in:
@@ -628,13 +628,13 @@ namespace RedBookPlayer.GUI.ViewModels
|
||||
/// Extract a single track from the image to WAV
|
||||
/// </summary>
|
||||
/// <param name="trackNumber"></param>
|
||||
/// <param name="outputDirectory">Output path to write data to</param
|
||||
/// <param name="outputDirectory">Output path to write data to</param>
|
||||
public void ExtractSingleTrackToWav(uint trackNumber, string outputDirectory) => _player?.ExtractSingleTrackToWav(trackNumber, outputDirectory);
|
||||
|
||||
/// <summary>
|
||||
/// Extract all tracks from the image to WAV
|
||||
/// </summary>
|
||||
/// <param name="outputDirectory">Output path to write data to</param
|
||||
/// <param name="outputDirectory">Output path to write data to</param>
|
||||
public void ExtractAllTracksToWav(string outputDirectory) => _player?.ExtractAllTracksToWav(outputDirectory);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -449,17 +449,22 @@ namespace RedBookPlayer.Models.Discs
|
||||
Track track = _image.Tracks.FirstOrDefault(t => t.TrackSequence == trackNumber);
|
||||
|
||||
// If the track isn't valid, we can't do anything
|
||||
if(track == null || track.TrackType != TrackType.Audio)
|
||||
if(track == null || !(DataPlayback != DataPlayback.Skip || track.TrackType == TrackType.Audio))
|
||||
return;
|
||||
|
||||
// Read in the track data to a buffer
|
||||
// Get the number of sectors to read
|
||||
uint length = (uint)(track.TrackEndSector - track.TrackStartSector);
|
||||
byte[] buffer = _image.ReadSectors(track.TrackStartSector, length);
|
||||
|
||||
// Read in the track data to a buffer
|
||||
byte[] buffer = ReadSectors(track.TrackStartSector, length);
|
||||
|
||||
// Build the WAV output
|
||||
string filename = Path.Combine(outputDirectory, $"Track {trackNumber.ToString().PadLeft(2, '0')}.wav");
|
||||
using(WaveWriter waveWriter = new WaveWriter(filename, new CSCore.WaveFormat()))
|
||||
{
|
||||
// TODO: This should also apply de-emphasis as on playback
|
||||
// Should this be configurable? Match the de-emphasis status?
|
||||
|
||||
// Write out to the file
|
||||
waveWriter.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
@@ -502,15 +507,31 @@ namespace RedBookPlayer.Models.Discs
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override byte[] ReadSectors(uint sectorsToRead)
|
||||
public override byte[] ReadSectors(uint sectorsToRead) => ReadSectors(CurrentSector, sectorsToRead);
|
||||
|
||||
/// <summary>
|
||||
/// Read sector data from the base image starting from the specified sector
|
||||
/// </summary>
|
||||
/// <param name="startSector">Sector to start at for reading</param>
|
||||
/// <param name="sectorsToRead">Current number of sectors to read</param>
|
||||
/// <returns>Byte array representing the read sectors, if possible</returns>
|
||||
private byte[] ReadSectors(ulong startSector, uint sectorsToRead)
|
||||
{
|
||||
if(TrackType == TrackType.Audio || DataPlayback == DataPlayback.Play)
|
||||
return base.ReadSectors(sectorsToRead);
|
||||
{
|
||||
return _image.ReadSectors(startSector, sectorsToRead);
|
||||
}
|
||||
else if(DataPlayback == DataPlayback.Blank)
|
||||
return new byte[sectorsToRead * BytesPerSector];
|
||||
{
|
||||
byte[] sectors = _image.ReadSectors(startSector, sectorsToRead);
|
||||
Array.Clear(sectors, 0, sectors.Length);
|
||||
return sectors;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new byte[0];
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetTotalIndexes()
|
||||
|
||||
@@ -131,13 +131,13 @@ namespace RedBookPlayer.Models.Discs
|
||||
/// Extract a track to WAV
|
||||
/// </summary>
|
||||
/// <param name="trackNumber">Track number to extract</param>
|
||||
/// <param name="outputDirectory">Output path to write data to</param
|
||||
/// <param name="outputDirectory">Output path to write data to</param>
|
||||
public abstract void ExtractTrackToWav(uint trackNumber, string outputDirectory);
|
||||
|
||||
/// <summary>
|
||||
/// Extract all tracks to WAV
|
||||
/// </summary>
|
||||
/// <param name="outputDirectory">Output path to write data to</param
|
||||
/// <param name="outputDirectory">Output path to write data to</param>
|
||||
public abstract void ExtractAllTracksToWav(string outputDirectory);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -535,12 +535,12 @@ namespace RedBookPlayer.Models.Hardware
|
||||
/// Extract a single track from the image to WAV
|
||||
/// </summary>
|
||||
/// <param name="trackNumber"></param>
|
||||
/// <param name="outputDirectory">Output path to write data to</param
|
||||
/// <param name="outputDirectory">Output path to write data to</param>
|
||||
public void ExtractSingleTrackToWav(uint trackNumber, string outputDirectory) => _opticalDisc?.ExtractTrackToWav(trackNumber, outputDirectory);
|
||||
|
||||
/// <summary>
|
||||
/// Extract all tracks from the image to WAV
|
||||
/// <param name="outputDirectory">Output path to write data to</param
|
||||
/// <param name="outputDirectory">Output path to write data to</param>
|
||||
public void ExtractAllTracksToWav(string outputDirectory) => _opticalDisc?.ExtractAllTracksToWav(outputDirectory);
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user