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
|
/// Extract a single track from the image to WAV
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="trackNumber"></param>
|
/// <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);
|
public void ExtractSingleTrackToWav(uint trackNumber, string outputDirectory) => _player?.ExtractSingleTrackToWav(trackNumber, outputDirectory);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extract all tracks from the image to WAV
|
/// Extract all tracks from the image to WAV
|
||||||
/// </summary>
|
/// </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);
|
public void ExtractAllTracksToWav(string outputDirectory) => _player?.ExtractAllTracksToWav(outputDirectory);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -449,17 +449,22 @@ namespace RedBookPlayer.Models.Discs
|
|||||||
Track track = _image.Tracks.FirstOrDefault(t => t.TrackSequence == trackNumber);
|
Track track = _image.Tracks.FirstOrDefault(t => t.TrackSequence == trackNumber);
|
||||||
|
|
||||||
// If the track isn't valid, we can't do anything
|
// 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;
|
return;
|
||||||
|
|
||||||
// Read in the track data to a buffer
|
// Get the number of sectors to read
|
||||||
uint length = (uint)(track.TrackEndSector - track.TrackStartSector);
|
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
|
// Build the WAV output
|
||||||
string filename = Path.Combine(outputDirectory, $"Track {trackNumber.ToString().PadLeft(2, '0')}.wav");
|
string filename = Path.Combine(outputDirectory, $"Track {trackNumber.ToString().PadLeft(2, '0')}.wav");
|
||||||
using(WaveWriter waveWriter = new WaveWriter(filename, new CSCore.WaveFormat()))
|
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
|
// Write out to the file
|
||||||
waveWriter.Write(buffer, 0, buffer.Length);
|
waveWriter.Write(buffer, 0, buffer.Length);
|
||||||
}
|
}
|
||||||
@@ -502,15 +507,31 @@ namespace RedBookPlayer.Models.Discs
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <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)
|
if(TrackType == TrackType.Audio || DataPlayback == DataPlayback.Play)
|
||||||
return base.ReadSectors(sectorsToRead);
|
{
|
||||||
|
return _image.ReadSectors(startSector, sectorsToRead);
|
||||||
|
}
|
||||||
else if(DataPlayback == DataPlayback.Blank)
|
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
|
else
|
||||||
|
{
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void SetTotalIndexes()
|
public override void SetTotalIndexes()
|
||||||
|
|||||||
@@ -131,13 +131,13 @@ namespace RedBookPlayer.Models.Discs
|
|||||||
/// Extract a track to WAV
|
/// Extract a track to WAV
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="trackNumber">Track number to extract</param>
|
/// <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);
|
public abstract void ExtractTrackToWav(uint trackNumber, string outputDirectory);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extract all tracks to WAV
|
/// Extract all tracks to WAV
|
||||||
/// </summary>
|
/// </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);
|
public abstract void ExtractAllTracksToWav(string outputDirectory);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -535,12 +535,12 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
/// Extract a single track from the image to WAV
|
/// Extract a single track from the image to WAV
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="trackNumber"></param>
|
/// <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);
|
public void ExtractSingleTrackToWav(uint trackNumber, string outputDirectory) => _opticalDisc?.ExtractTrackToWav(trackNumber, outputDirectory);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extract all tracks from the image to WAV
|
/// 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);
|
public void ExtractAllTracksToWav(string outputDirectory) => _opticalDisc?.ExtractAllTracksToWav(outputDirectory);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user