All audio formats can now be read from a .rar archive.

Cleaned up .APE library of outdated code.
This commit is contained in:
chudov
2008-11-10 16:12:16 +00:00
parent d4e68c5261
commit 58d3af09c7
18 changed files with 306 additions and 1026 deletions

View File

@@ -10,40 +10,24 @@ using System.Collections.Specialized;
namespace CUEToolsLib {
public static class AudioReadWrite {
public static IAudioSource GetAudioSource(string path) {
switch (Path.GetExtension(path).ToLower()) {
case ".wav":
return new WAVReader(path, null);
#if !MONO
case ".flac":
return new FLACReader(path, null);
case ".wv":
return new WavPackReader(path, null, null);
case ".ape":
return new APEReader(path);
case ".m4a":
return new ALACReader(path, null);
#endif
default:
throw new Exception("Unsupported audio type.");
}
}
public static IAudioSource GetAudioSource(string path, Stream IO)
{
switch (Path.GetExtension(path).ToLower())
{
case ".wav":
return new WAVReader(path, IO);
case ".m4a":
return new ALACReader(path, IO);
#if !MONO
case ".flac":
return new FLACReader(path, IO);
case ".wv":
return new WavPackReader(path, IO, null);
case ".m4a":
return new ALACReader(path, IO);
case ".ape":
return new APEReader(path, IO);
#endif
default:
throw new Exception("Unsupported audio type in archive.");
throw new Exception("Unsupported audio type.");
}
}
@@ -242,8 +226,8 @@ namespace CUEToolsLib {
int[,] _sampleBuffer;
uint _bufferOffset, _bufferLength;
public APEReader(string path) {
_apeReader = new APEDotNet.APEReader(path);
public APEReader(string path, Stream IO) {
_apeReader = new APEDotNet.APEReader(path, IO);
_bufferOffset = 0;
_bufferLength = 0;
}

View File

@@ -541,7 +541,7 @@ namespace CUEToolsLib
NameValueCollection tags;
string cuesheetTag = null;
audioSource = AudioReadWrite.GetAudioSource(pathIn);
audioSource = AudioReadWrite.GetAudioSource(pathIn,null);
tags = audioSource.Tags;
cuesheetTag = tags.Get("CUESHEET");
_accurateRipId = tags.Get("ACCURATERIPID");
@@ -1017,7 +1017,7 @@ namespace CUEToolsLib
audioSource = AudioReadWrite.GetAudioSource(path, IO);
} else
#endif
audioSource = AudioReadWrite.GetAudioSource(path);
audioSource = AudioReadWrite.GetAudioSource(path, null);
if ((audioSource.BitsPerSample != 16) ||
(audioSource.ChannelCount != 2) ||
@@ -1760,7 +1760,7 @@ namespace CUEToolsLib
if (_hasEmbeddedCUESheet)
{
IAudioSource audioSource = AudioReadWrite.GetAudioSource(_sourcePaths[0]);
IAudioSource audioSource = AudioReadWrite.GetAudioSource(_sourcePaths[0], null);
NameValueCollection tags = audioSource.Tags;
CleanupTags(tags, "ACCURATERIP");
GenerateAccurateRipTags (tags, 0, bestOffset, -1);
@@ -1775,7 +1775,7 @@ namespace CUEToolsLib
for (int iTrack = 0; iTrack < TrackCount; iTrack++)
{
string src = _sourcePaths[iTrack + (_hasHTOAFilename ? 1 : 0)];
IAudioSource audioSource = AudioReadWrite.GetAudioSource(src);
IAudioSource audioSource = AudioReadWrite.GetAudioSource(src, null);
#if !MONO
if (audioSource is FLACReader)
{
@@ -2414,7 +2414,7 @@ namespace CUEToolsLib
}
else
#endif
audioSource = AudioReadWrite.GetAudioSource(sourceInfo.Path);
audioSource = AudioReadWrite.GetAudioSource(sourceInfo.Path, null);
}
if (sourceInfo.Offset != 0)