Files
cuetools.net/CUEToolsLib/AudioReadWrite.cs

56 lines
1.6 KiB
C#
Raw Normal View History

2008-10-13 19:25:11 +00:00
using System;
using System.IO;
using FLACDotNet;
using WavPackDotNet;
using APEDotNet;
using ALACDotNet;
using AudioCodecsDotNet;
2008-10-13 19:25:11 +00:00
using System.Collections.Generic;
using System.Collections.Specialized;
namespace CUEToolsLib {
2008-10-13 19:25:11 +00:00
public static class AudioReadWrite {
public static IAudioSource GetAudioSource(string path, Stream IO)
{
switch (Path.GetExtension(path).ToLower())
{
2008-11-10 09:31:14 +00:00
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 ".ape":
return new APEReader(path, IO);
#endif
default:
throw new Exception("Unsupported audio type.");
}
}
2008-10-13 19:25:11 +00:00
public static IAudioDest GetAudioDest(string path, int bitsPerSample, int channelCount, int sampleRate, long finalSampleCount) {
IAudioDest dest;
switch (Path.GetExtension(path).ToLower()) {
case ".wav":
dest = new WAVWriter(path, bitsPerSample, channelCount, sampleRate); break;
#if !MONO
2008-10-13 19:25:11 +00:00
case ".flac":
dest = new FLACWriter(path, bitsPerSample, channelCount, sampleRate); break;
case ".wv":
dest = new WavPackWriter(path, bitsPerSample, channelCount, sampleRate); break;
case ".ape":
dest = new APEWriter(path, bitsPerSample, channelCount, sampleRate); break;
2008-10-13 19:25:11 +00:00
case ".dummy":
dest = new DummyWriter(path, bitsPerSample, channelCount, sampleRate); break;
#endif
2008-10-13 19:25:11 +00:00
default:
throw new Exception("Unsupported audio type.");
}
dest.FinalSampleCount = finalSampleCount;
return dest;
}
}
}