mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
Cleanup IAudioDest; CompressionLevel is now part of AudioEncoderSettings.
FLAC encoders no longer offer non-subset compression levels by default.
This commit is contained in:
@@ -1018,7 +1018,7 @@ namespace CUERipper
|
||||
{
|
||||
trackBarEncoderMode.Maximum = modes.Length - 1;
|
||||
trackBarEncoderMode.Value = encoder.DefaultModeIndex == -1 ? modes.Length - 1 : encoder.DefaultModeIndex;
|
||||
labelEncoderMode.Text = encoder.default_mode;
|
||||
labelEncoderMode.Text = encoder.EncoderMode;
|
||||
labelEncoderMinMode.Text = modes[0];
|
||||
labelEncoderMaxMode.Text = modes[modes.Length - 1];
|
||||
trackBarEncoderMode.Visible = true;
|
||||
@@ -1032,8 +1032,8 @@ namespace CUERipper
|
||||
{
|
||||
CUEToolsUDC encoder = bnComboBoxEncoder.SelectedItem as CUEToolsUDC;
|
||||
string[] modes = encoder.SupportedModes;
|
||||
encoder.default_mode = modes[trackBarEncoderMode.Value];
|
||||
labelEncoderMode.Text = encoder.default_mode;
|
||||
encoder.EncoderMode = modes[trackBarEncoderMode.Value];
|
||||
labelEncoderMode.Text = encoder.EncoderMode;
|
||||
}
|
||||
|
||||
private void trackBarSecureMode_Scroll(object sender, EventArgs e)
|
||||
|
||||
@@ -176,8 +176,11 @@ namespace CUETools.ALACEnc
|
||||
|
||||
try
|
||||
{
|
||||
if (level >= 0)
|
||||
alac.CompressionLevel = level;
|
||||
var settings = new ALACWriterSettings();
|
||||
settings.DoVerify = do_verify;
|
||||
if (level >= 0)
|
||||
settings.EncoderModeIndex = level;
|
||||
alac.Settings = settings;
|
||||
if (stereo_method != null)
|
||||
alac.StereoMethod = Alac.LookupStereoMethod(stereo_method);
|
||||
if (order_method != null)
|
||||
|
||||
@@ -931,21 +931,15 @@ namespace CUETools.AccurateRip
|
||||
throw new Exception("unsupported");
|
||||
}
|
||||
|
||||
public int CompressionLevel
|
||||
{
|
||||
get { return 0; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public object Settings
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
return new AudioEncoderSettings();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value.GetType() != typeof(object))
|
||||
if (value != null && value.GetType() != typeof(AudioEncoderSettings))
|
||||
throw new Exception("Unsupported options " + value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,21 +413,15 @@ namespace CUETools.AccurateRip
|
||||
throw new Exception("unsupported");
|
||||
}
|
||||
|
||||
public int CompressionLevel
|
||||
{
|
||||
get { return 0; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public object Settings
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
return new AudioEncoderSettings();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value.GetType() != typeof(object))
|
||||
if (value != null && value.GetType() != typeof(AudioEncoderSettings))
|
||||
throw new Exception("Unsupported options " + value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,16 +33,21 @@ using CUETools.Codecs;
|
||||
|
||||
namespace CUETools.Codecs.ALAC
|
||||
{
|
||||
public class ALACWriterSettings
|
||||
public class ALACWriterSettings: AudioEncoderSettings
|
||||
{
|
||||
public ALACWriterSettings() { DoVerify = false; }
|
||||
public ALACWriterSettings()
|
||||
: base("0 1 2 3 4 5 6 7 8 9 10", "3")
|
||||
{
|
||||
DoVerify = false;
|
||||
}
|
||||
|
||||
[DefaultValue(false)]
|
||||
[DisplayName("Verify")]
|
||||
[Description("Decode each frame and compare with original")]
|
||||
public bool DoVerify { get; set; }
|
||||
}
|
||||
|
||||
[AudioEncoderClass("cuetools", "m4a", true, "0 1 2 3 4 5 6 7 8 9 10", "3", 1, typeof(ALACWriterSettings))]
|
||||
[AudioEncoderClass("cuetools", "m4a", true, 1, typeof(ALACWriterSettings))]
|
||||
public class ALACWriter : IAudioDest
|
||||
{
|
||||
Stream _IO = null;
|
||||
@@ -81,7 +86,6 @@ namespace CUETools.Codecs.ALAC
|
||||
float[] windowBuffer;
|
||||
int samplesInBuffer = 0;
|
||||
|
||||
int _compressionLevel = 5;
|
||||
int _blocksize = 0;
|
||||
int _totalSize = 0;
|
||||
int _windowsize = 0, _windowcount = 0;
|
||||
@@ -114,7 +118,7 @@ namespace CUETools.Codecs.ALAC
|
||||
residualBuffer = new int[Alac.MAX_BLOCKSIZE * (_pcm.ChannelCount == 2 ? 6 : _pcm.ChannelCount + 1)];
|
||||
windowBuffer = new float[Alac.MAX_BLOCKSIZE * 2 * Alac.MAX_LPC_WINDOWS];
|
||||
|
||||
eparams.set_defaults(_compressionLevel);
|
||||
eparams.set_defaults(5);
|
||||
eparams.padding_size = 4096;
|
||||
|
||||
frame = new ALACFrame(_pcm.ChannelCount == 2 ? 5 : _pcm.ChannelCount);
|
||||
@@ -134,24 +138,9 @@ namespace CUETools.Codecs.ALAC
|
||||
}
|
||||
}
|
||||
|
||||
public int CompressionLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
return _compressionLevel;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0 || value > 10)
|
||||
throw new Exception("unsupported compression level");
|
||||
_compressionLevel = value;
|
||||
eparams.set_defaults(_compressionLevel);
|
||||
}
|
||||
}
|
||||
|
||||
ALACWriterSettings _settings = new ALACWriterSettings();
|
||||
|
||||
public object Settings
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -162,7 +151,11 @@ namespace CUETools.Codecs.ALAC
|
||||
if (value as ALACWriterSettings == null)
|
||||
throw new Exception("Unsupported options " + value);
|
||||
_settings = value as ALACWriterSettings;
|
||||
}
|
||||
var _compressionLevel = _settings.EncoderModeIndex;
|
||||
if (_compressionLevel < 0 || _compressionLevel > 10)
|
||||
throw new Exception("unsupported compression level");
|
||||
eparams.set_defaults(_compressionLevel);
|
||||
}
|
||||
}
|
||||
|
||||
public long Padding
|
||||
|
||||
@@ -252,12 +252,22 @@ namespace CUETools { namespace Codecs { namespace APE {
|
||||
}
|
||||
};
|
||||
|
||||
[AudioEncoderClass("MAC_SDK", "ape", true, "fast normal high extra insane", "high", 1, Object::typeid)]
|
||||
public ref class APEWriterSettings : AudioEncoderSettings
|
||||
{
|
||||
public:
|
||||
APEWriterSettings()
|
||||
: AudioEncoderSettings("fast normal high extra insane", "high")
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
[AudioEncoderClass("MAC_SDK", "ape", true, 1, APEWriterSettings::typeid)]
|
||||
public ref class APEWriter : IAudioDest
|
||||
{
|
||||
public:
|
||||
APEWriter(String^ path, AudioPCMConfig^ pcm)
|
||||
{
|
||||
_settings = gcnew APEWriterSettings();
|
||||
_pcm = pcm;
|
||||
|
||||
if (_pcm->ChannelCount != 1 && _pcm->ChannelCount != 2)
|
||||
@@ -268,8 +278,6 @@ namespace CUETools { namespace Codecs { namespace APE {
|
||||
_path = path;
|
||||
_winFileIO = NULL;
|
||||
|
||||
_compressionLevel = COMPRESSION_LEVEL_NORMAL;
|
||||
|
||||
int nRetVal;
|
||||
pAPECompress = CreateIAPECompress (&nRetVal);
|
||||
if (!pAPECompress)
|
||||
@@ -286,7 +294,7 @@ namespace CUETools { namespace Codecs { namespace APE {
|
||||
_gchBuffer.Free();
|
||||
}
|
||||
|
||||
virtual void Close()
|
||||
void DoClose()
|
||||
{
|
||||
if (pAPECompress)
|
||||
{
|
||||
@@ -295,10 +303,6 @@ namespace CUETools { namespace Codecs { namespace APE {
|
||||
pAPECompress = NULL;
|
||||
}
|
||||
|
||||
if ((_finalSampleCount != 0) && (_samplesWritten != _finalSampleCount)) {
|
||||
throw gcnew Exception("Samples written differs from the expected sample count.");
|
||||
}
|
||||
|
||||
if (_IO != nullptr)
|
||||
{
|
||||
_IO->Close ();
|
||||
@@ -306,9 +310,19 @@ namespace CUETools { namespace Codecs { namespace APE {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Close()
|
||||
{
|
||||
DoClose();
|
||||
|
||||
if ((_finalSampleCount != 0) && (_samplesWritten != _finalSampleCount)) {
|
||||
throw gcnew Exception("Samples written differs from the expected sample count.");
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Delete()
|
||||
{
|
||||
try { Close (); } catch (Exception^) {}
|
||||
DoClose ();
|
||||
|
||||
File::Delete(_path);
|
||||
}
|
||||
|
||||
@@ -361,34 +375,24 @@ namespace CUETools { namespace Codecs { namespace APE {
|
||||
}
|
||||
}
|
||||
|
||||
virtual property Int32 CompressionLevel {
|
||||
Int32 get() {
|
||||
return _compressionLevel / 1000 - 1;
|
||||
}
|
||||
void set(Int32 value) {
|
||||
if (value < 0 || value > 4)
|
||||
throw gcnew Exception("Invalid compression mode.");
|
||||
_compressionLevel = (value + 1) * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
virtual property __int64 Padding
|
||||
{
|
||||
void set(__int64 value) {
|
||||
}
|
||||
}
|
||||
|
||||
virtual property Object^ Settings
|
||||
virtual property AudioEncoderSettings^ Settings
|
||||
{
|
||||
Object^ get()
|
||||
AudioEncoderSettings^ get()
|
||||
{
|
||||
return nullptr;
|
||||
return _settings;
|
||||
}
|
||||
|
||||
void set(Object^ value)
|
||||
void set(AudioEncoderSettings^ value)
|
||||
{
|
||||
if (value != nullptr && value->GetType() != Object::typeid)
|
||||
if (value != nullptr && value->GetType() != APEWriterSettings::typeid)
|
||||
throw gcnew Exception(String::Format("Unsupported options: {0}", value));
|
||||
_settings = (APEWriterSettings^)value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,7 +401,7 @@ namespace CUETools { namespace Codecs { namespace APE {
|
||||
bool _initialized;
|
||||
Int32 _finalSampleCount, _samplesWritten;
|
||||
AudioPCMConfig^ _pcm;
|
||||
Int32 _compressionLevel;
|
||||
APEWriterSettings^ _settings;
|
||||
String^ _path;
|
||||
Stream^ _IO;
|
||||
GCHandle _gchIO, _gchBuffer;
|
||||
@@ -416,6 +420,8 @@ namespace CUETools { namespace Codecs { namespace APE {
|
||||
WAVEFORMATEX waveFormat;
|
||||
FillWaveFormatEx (&waveFormat, _pcm->SampleRate, _pcm->BitsPerSample, _pcm->ChannelCount);
|
||||
|
||||
Int32 _compressionLevel = (_settings->EncoderModeIndex + 1) * 1000;
|
||||
|
||||
int res = pAPECompress->StartEx (_winFileIO,
|
||||
&waveFormat,
|
||||
(_finalSampleCount == 0) ? MAX_AUDIO_BYTES_UNKNOWN : _finalSampleCount * _pcm->BlockAlign,
|
||||
|
||||
@@ -494,21 +494,15 @@ namespace CUETools.Codecs.CoreAudio
|
||||
set { ; }
|
||||
}
|
||||
|
||||
public int CompressionLevel
|
||||
{
|
||||
get { return 0; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public object Settings
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
return new AudioEncoderSettings();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value.GetType() != typeof(object))
|
||||
if (value != null && value.GetType() != typeof(AudioEncoderSettings))
|
||||
throw new Exception("Unsupported options " + value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,10 +448,11 @@ namespace CUETools { namespace Codecs { namespace FLAC {
|
||||
}
|
||||
};
|
||||
|
||||
public ref class FLACWriterSettings
|
||||
public ref class FLACWriterSettings: AudioEncoderSettings
|
||||
{
|
||||
public:
|
||||
FLACWriterSettings()
|
||||
: AudioEncoderSettings("0 1 2 3 4 5 6 7 8", "5")
|
||||
{
|
||||
_md5Sum = true;
|
||||
_verify = false;
|
||||
@@ -498,7 +499,7 @@ namespace CUETools { namespace Codecs { namespace FLAC {
|
||||
bool _md5Sum, _verify, _disableAsm;
|
||||
};
|
||||
|
||||
[AudioEncoderClass("libFLAC", "flac", true, "0 1 2 3 4 5 6 7 8", "5", 2, FLACWriterSettings::typeid)]
|
||||
[AudioEncoderClass("libFLAC", "flac", true, 2, FLACWriterSettings::typeid)]
|
||||
public ref class FLACWriter : IAudioDest
|
||||
{
|
||||
public:
|
||||
@@ -515,7 +516,6 @@ namespace CUETools { namespace Codecs { namespace FLAC {
|
||||
_path = path;
|
||||
_finalSampleCount = 0;
|
||||
_samplesWritten = 0;
|
||||
_compressionLevel = 5;
|
||||
_paddingLength = 8192;
|
||||
_blockSize = 0;
|
||||
|
||||
@@ -608,25 +608,14 @@ namespace CUETools { namespace Codecs { namespace FLAC {
|
||||
_samplesWritten += sampleBuffer->Length;
|
||||
}
|
||||
|
||||
virtual property Int32 CompressionLevel {
|
||||
Int32 get() {
|
||||
return _compressionLevel;
|
||||
}
|
||||
void set(Int32 value) {
|
||||
if ((value < 0) || (value > 8))
|
||||
throw gcnew Exception("invalid compression level");
|
||||
_compressionLevel = value;
|
||||
}
|
||||
}
|
||||
|
||||
virtual property Object^ Settings
|
||||
virtual property AudioEncoderSettings^ Settings
|
||||
{
|
||||
Object^ get()
|
||||
AudioEncoderSettings^ get()
|
||||
{
|
||||
return _settings;
|
||||
}
|
||||
|
||||
void set(Object^ value)
|
||||
void set(AudioEncoderSettings^ value)
|
||||
{
|
||||
if (value == nullptr || value->GetType() != FLACWriterSettings::typeid)
|
||||
throw gcnew Exception(String::Format("Unsupported options: {0}", value));
|
||||
@@ -652,7 +641,6 @@ namespace CUETools { namespace Codecs { namespace FLAC {
|
||||
String^ _path;
|
||||
Int64 _finalSampleCount, _samplesWritten, _blockSize;
|
||||
AudioPCMConfig^ _pcm;
|
||||
Int32 _compressionLevel;
|
||||
__int64 _paddingLength;
|
||||
FLAC__StreamMetadata **_metadataList;
|
||||
int _metadataCount;
|
||||
@@ -726,7 +714,7 @@ namespace CUETools { namespace Codecs { namespace FLAC {
|
||||
FLAC__stream_encoder_set_total_samples_estimate(_encoder, _finalSampleCount);
|
||||
}
|
||||
|
||||
FLAC__stream_encoder_set_compression_level(_encoder, _compressionLevel);
|
||||
FLAC__stream_encoder_set_compression_level(_encoder, _settings->EncoderModeIndex);
|
||||
|
||||
if (_blockSize > 0)
|
||||
FLAC__stream_encoder_set_blocksize(_encoder, (unsigned)_blockSize);
|
||||
|
||||
@@ -31,9 +31,10 @@ using OpenCLNet;
|
||||
|
||||
namespace CUETools.Codecs.FLACCL
|
||||
{
|
||||
public class FLACCLWriterSettings
|
||||
public class FLACCLWriterSettings: AudioEncoderSettings
|
||||
{
|
||||
public FLACCLWriterSettings()
|
||||
: base("", "8")
|
||||
{
|
||||
this.DoVerify = false;
|
||||
this.GPUOnly = true;
|
||||
@@ -43,8 +44,14 @@ namespace CUETools.Codecs.FLACCL
|
||||
this.GroupSize = 128;
|
||||
this.TaskSize = 8;
|
||||
this.DeviceType = OpenCLDeviceType.GPU;
|
||||
this.AllowNonSubset = false;
|
||||
}
|
||||
|
||||
public override string GetSupportedModes()
|
||||
{
|
||||
return this.AllowNonSubset ? "0 1 2 3 4 5 6 7 8 9 10 11" : "0 1 2 3 4 5 6 7 8";
|
||||
}
|
||||
|
||||
[DefaultValue(false)]
|
||||
[DisplayName("Verify")]
|
||||
[SRDescription(typeof(Properties.Resources), "DoVerifyDescription")]
|
||||
@@ -120,7 +127,12 @@ namespace CUETools.Codecs.FLACCL
|
||||
padding = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(false)]
|
||||
[DisplayName("Allow Non-subset")]
|
||||
[SRDescription(typeof(Properties.Resources), "AllowNonSubsetDescription")]
|
||||
public bool AllowNonSubset { get; set; }
|
||||
}
|
||||
|
||||
public class FLACCLWriterSettingsPlatformConverter : TypeConverter
|
||||
{
|
||||
@@ -157,7 +169,7 @@ namespace CUETools.Codecs.FLACCL
|
||||
GPU = DeviceType.GPU
|
||||
}
|
||||
|
||||
[AudioEncoderClass("FLACCL", "flac", true, "0 1 2 3 4 5 6 7 8 9 10 11", "8", 2, typeof(FLACCLWriterSettings))]
|
||||
[AudioEncoderClass("FLACCL", "flac", true, 2, typeof(FLACCLWriterSettings))]
|
||||
//[AudioEncoderClass("FLACCL nonsub", "flac", true, "9 10 11", "9", 1, typeof(FLACCLWriterSettings))]
|
||||
public class FLACCLWriter : IAudioDest
|
||||
{
|
||||
@@ -200,7 +212,6 @@ namespace CUETools.Codecs.FLACCL
|
||||
|
||||
int samplesInBuffer = 0;
|
||||
|
||||
int _compressionLevel = 7;
|
||||
int _blocksize = 0;
|
||||
int _totalSize = 0;
|
||||
|
||||
@@ -245,7 +256,7 @@ namespace CUETools.Codecs.FLACCL
|
||||
_path = path;
|
||||
_IO = IO;
|
||||
|
||||
eparams.flake_set_defaults(_compressionLevel);
|
||||
eparams.flake_set_defaults(7);
|
||||
eparams.padding_size = _settings.Padding;
|
||||
|
||||
crc8 = new Crc8();
|
||||
@@ -276,24 +287,9 @@ namespace CUETools.Codecs.FLACCL
|
||||
}
|
||||
}
|
||||
|
||||
public int CompressionLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
return _compressionLevel;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0 || value > 11)
|
||||
throw new Exception("unsupported compression level");
|
||||
_compressionLevel = value;
|
||||
eparams.flake_set_defaults(_compressionLevel);
|
||||
}
|
||||
}
|
||||
|
||||
internal FLACCLWriterSettings _settings = new FLACCLWriterSettings();
|
||||
|
||||
public object Settings
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -304,6 +300,10 @@ namespace CUETools.Codecs.FLACCL
|
||||
if (value as FLACCLWriterSettings == null)
|
||||
throw new Exception("Unsupported options " + value);
|
||||
_settings = value as FLACCLWriterSettings;
|
||||
var _compressionLevel = _settings.EncoderModeIndex;
|
||||
if (_compressionLevel < 0 || _compressionLevel > 11)
|
||||
throw new Exception("unsupported compression level");
|
||||
eparams.flake_set_defaults(_compressionLevel);
|
||||
eparams.padding_size = _settings.Padding;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,15 @@ namespace CUETools.Codecs.FLACCL.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Allow non-subset modes, which allow for greater compression, but are less compatible.
|
||||
/// </summary>
|
||||
internal static string AllowNonSubsetDescription {
|
||||
get {
|
||||
return ResourceManager.GetString("AllowNonSubsetDescription", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Use additional CPU threads.
|
||||
/// </summary>
|
||||
|
||||
@@ -117,6 +117,9 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AllowNonSubsetDescription" xml:space="preserve">
|
||||
<value>Allow non-subset modes, which allow for greater compression, but are less compatible</value>
|
||||
</data>
|
||||
<data name="DescriptionCPUThreads" xml:space="preserve">
|
||||
<value>Use additional CPU threads</value>
|
||||
</data>
|
||||
|
||||
@@ -34,9 +34,21 @@ using CUETools.Codecs;
|
||||
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
{
|
||||
public class FlakeWriterSettings
|
||||
public class FlakeWriterSettings: AudioEncoderSettings
|
||||
{
|
||||
public FlakeWriterSettings() { DoVerify = false; DoMD5 = true; }
|
||||
public FlakeWriterSettings()
|
||||
: base("", "7")
|
||||
{
|
||||
DoVerify = false;
|
||||
DoMD5 = true;
|
||||
AllowNonSubset = false;
|
||||
}
|
||||
|
||||
public override string GetSupportedModes()
|
||||
{
|
||||
return this.AllowNonSubset ? "0 1 2 3 4 5 6 7 8 9 10 11" : "0 1 2 3 4 5 6 7 8";
|
||||
}
|
||||
|
||||
[DefaultValue(false)]
|
||||
[DisplayName("Verify")]
|
||||
[SRDescription(typeof(Properties.Resources), "DoVerifyDescription")]
|
||||
@@ -46,9 +58,14 @@ namespace CUETools.Codecs.FLAKE
|
||||
[DisplayName("MD5")]
|
||||
[SRDescription(typeof(Properties.Resources), "DoMD5Description")]
|
||||
public bool DoMD5 { get; set; }
|
||||
}
|
||||
|
||||
[AudioEncoderClass("cuetools", "flac", true, "0 1 2 3 4 5 6 7 8 9 10 11", "7", 4, typeof(FlakeWriterSettings))]
|
||||
[DefaultValue(false)]
|
||||
[DisplayName("Allow Non-subset")]
|
||||
[SRDescription(typeof(Properties.Resources), "AllowNonSubsetDescription")]
|
||||
public bool AllowNonSubset { get; set; }
|
||||
}
|
||||
|
||||
[AudioEncoderClass("cuetools", "flac", true, 4, typeof(FlakeWriterSettings))]
|
||||
//[AudioEncoderClass("libFlake nonsub", "flac", true, "9 10 11", "9", 3, typeof(FlakeWriterSettings))]
|
||||
public class FlakeWriter : IAudioDest
|
||||
{
|
||||
@@ -103,7 +120,6 @@ namespace CUETools.Codecs.FLAKE
|
||||
double[] windowScale;
|
||||
int samplesInBuffer = 0;
|
||||
|
||||
int _compressionLevel = 7;
|
||||
int _blocksize = 0;
|
||||
int _totalSize = 0;
|
||||
int _windowsize = 0, _windowcount = 0;
|
||||
@@ -141,7 +157,7 @@ namespace CUETools.Codecs.FLAKE
|
||||
windowBuffer = new float[Flake.MAX_BLOCKSIZE * 2 * lpc.MAX_LPC_WINDOWS];
|
||||
windowScale = new double[lpc.MAX_LPC_WINDOWS];
|
||||
|
||||
eparams.flake_set_defaults(_compressionLevel);
|
||||
eparams.flake_set_defaults(7);
|
||||
eparams.padding_size = 8192;
|
||||
|
||||
crc8 = new Crc8();
|
||||
@@ -161,24 +177,9 @@ namespace CUETools.Codecs.FLAKE
|
||||
}
|
||||
}
|
||||
|
||||
public int CompressionLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
return _compressionLevel;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0 || value > 11)
|
||||
throw new Exception("unsupported compression level");
|
||||
_compressionLevel = value;
|
||||
eparams.flake_set_defaults(_compressionLevel);
|
||||
}
|
||||
}
|
||||
|
||||
FlakeWriterSettings _settings = new FlakeWriterSettings();
|
||||
|
||||
public object Settings
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -188,7 +189,11 @@ namespace CUETools.Codecs.FLAKE
|
||||
{
|
||||
if (value as FlakeWriterSettings == null)
|
||||
throw new Exception("Unsupported options " + value);
|
||||
_settings = value as FlakeWriterSettings;
|
||||
_settings = value as FlakeWriterSettings;
|
||||
var _compressionLevel = _settings.EncoderModeIndex;
|
||||
if (_compressionLevel < 0 || _compressionLevel > 11)
|
||||
throw new Exception("unsupported compression level");
|
||||
eparams.flake_set_defaults(_compressionLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.239
|
||||
// Runtime Version:4.0.30319.18033
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
@@ -60,6 +60,15 @@ namespace CUETools.Codecs.FLAKE.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Allow non-subset modes, which allow for greater compression, but are less compatible.
|
||||
/// </summary>
|
||||
internal static string AllowNonSubsetDescription {
|
||||
get {
|
||||
return ResourceManager.GetString("AllowNonSubsetDescription", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Calculate MD5 hash for audio stream.
|
||||
/// </summary>
|
||||
|
||||
@@ -117,6 +117,9 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AllowNonSubsetDescription" xml:space="preserve">
|
||||
<value>Allow non-subset modes, which allow for greater compression, but are less compatible</value>
|
||||
</data>
|
||||
<data name="DoMD5Description" xml:space="preserve">
|
||||
<value>Calculate MD5 hash for audio stream</value>
|
||||
</data>
|
||||
|
||||
@@ -104,13 +104,7 @@ namespace HDCDDotNet
|
||||
set { throw new Exception("unsupported"); }
|
||||
}
|
||||
|
||||
public object Settings
|
||||
{
|
||||
get { throw new Exception("unsupported"); }
|
||||
set { throw new Exception("unsupported"); }
|
||||
}
|
||||
|
||||
public int CompressionLevel
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get { throw new Exception("unsupported"); }
|
||||
set { throw new Exception("unsupported"); }
|
||||
|
||||
@@ -210,21 +210,15 @@ namespace CUETools.Codecs.Icecast
|
||||
set { ; }
|
||||
}
|
||||
|
||||
public int CompressionLevel
|
||||
{
|
||||
get { return 0; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public object Settings
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
return new AudioEncoderSettings();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value.GetType() != typeof(object))
|
||||
if (value != null && value.GetType() != typeof(AudioEncoderSettings))
|
||||
throw new Exception("Unsupported options " + value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,28 +22,15 @@ namespace CUETools.Codecs.LAME
|
||||
private long bytesWritten = 0;
|
||||
private bool inited = false;
|
||||
|
||||
public virtual int CompressionLevel
|
||||
public virtual AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
return new AudioEncoderSettings();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != 0)
|
||||
throw new Exception("unsupported compression level");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual object Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value.GetType() != typeof(object))
|
||||
if (value != null && value.GetType() != typeof(AudioEncoderSettings))
|
||||
throw new Exception("Unsupported options " + value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,12 @@ using CUETools.Codecs.LAME.Interop;
|
||||
|
||||
namespace CUETools.Codecs.LAME
|
||||
{
|
||||
//[AudioEncoderClass("lame CBR", "mp3", false, "96 128 192 256 320", "256", 2, typeof(LAMEEncoderCBRSettings))]
|
||||
//[AudioEncoderClass("lame CBR", "mp3", false, 2, typeof(LAMEEncoderCBRSettings))]
|
||||
public class LAMEEncoderCBR : LAMEEncoder
|
||||
{
|
||||
private static readonly uint[] bps_table = new uint[] { 96, 128, 192, 256, 320 };
|
||||
|
||||
private uint bps;
|
||||
private LAMEEncoderCBRSettings _settings = new LAMEEncoderCBRSettings();
|
||||
|
||||
public override object Settings
|
||||
public override AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -26,27 +23,6 @@ namespace CUETools.Codecs.LAME
|
||||
}
|
||||
}
|
||||
|
||||
public override int CompressionLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int i = 0; i < bps_table.Length; i++)
|
||||
{
|
||||
if (bps == bps_table[i])
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0 || value > bps_table.Length)
|
||||
throw new Exception("unsupported compression level");
|
||||
bps = bps_table[value];
|
||||
}
|
||||
}
|
||||
|
||||
public LAMEEncoderCBR(string path, Stream IO, AudioPCMConfig pcm)
|
||||
: base(path, IO, pcm)
|
||||
{
|
||||
@@ -59,7 +35,7 @@ namespace CUETools.Codecs.LAME
|
||||
|
||||
protected override BE_CONFIG MakeConfig()
|
||||
{
|
||||
BE_CONFIG Mp3Config = new BE_CONFIG(PCM, _settings.CustomBitrate > 0 ? (uint)_settings.CustomBitrate : bps, 5);
|
||||
BE_CONFIG Mp3Config = new BE_CONFIG(PCM, _settings.CustomBitrate > 0 ? (uint)_settings.CustomBitrate : LAMEEncoderCBRSettings.bps_table[_settings.EncoderModeIndex], 5);
|
||||
Mp3Config.format.lhv1.bWriteVBRHeader = 1;
|
||||
Mp3Config.format.lhv1.nMode = _settings.StereoMode;
|
||||
//Mp3Config.format.lhv1.nVbrMethod = VBRMETHOD.VBR_METHOD_NONE; // --cbr
|
||||
|
||||
@@ -3,8 +3,10 @@ using CUETools.Codecs.LAME.Interop;
|
||||
|
||||
namespace CUETools.Codecs.LAME
|
||||
{
|
||||
public class LAMEEncoderCBRSettings
|
||||
public class LAMEEncoderCBRSettings : AudioEncoderSettings
|
||||
{
|
||||
public static readonly uint[] bps_table = new uint[] { 96, 128, 192, 256, 320 };
|
||||
|
||||
[DefaultValue(0)]
|
||||
public int CustomBitrate { get; set; }
|
||||
|
||||
@@ -12,12 +14,8 @@ namespace CUETools.Codecs.LAME
|
||||
public MpegMode StereoMode { get; set; }
|
||||
|
||||
public LAMEEncoderCBRSettings()
|
||||
: base("96 128 192 256 320", "256")
|
||||
{
|
||||
// Iterate through each property and call ResetValue()
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this))
|
||||
{
|
||||
property.ResetValue(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,27 +4,12 @@ using CUETools.Codecs.LAME.Interop;
|
||||
|
||||
namespace CUETools.Codecs.LAME
|
||||
{
|
||||
//[AudioEncoderClass("lame VBR", "mp3", false, "V9 V8 V7 V6 V5 V4 V3 V2 V1 V0", "V2", 2, typeof(LAMEEncoderVBRSettings))]
|
||||
//[AudioEncoderClass("lame VBR", "mp3", false, 2, typeof(LAMEEncoderVBRSettings))]
|
||||
public class LAMEEncoderVBR : LAMEEncoder
|
||||
{
|
||||
private int quality = 0;
|
||||
private LAMEEncoderVBRSettings _settings = new LAMEEncoderVBRSettings();
|
||||
|
||||
public override int CompressionLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
return 9 - quality;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0 || value > 9)
|
||||
throw new Exception("unsupported compression level");
|
||||
quality = 9 - value;
|
||||
}
|
||||
}
|
||||
|
||||
public override object Settings
|
||||
public override AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -54,7 +39,7 @@ namespace CUETools.Codecs.LAME
|
||||
Mp3Config.format.lhv1.bWriteVBRHeader = 1;
|
||||
Mp3Config.format.lhv1.nMode = MpegMode.JOINT_STEREO;
|
||||
Mp3Config.format.lhv1.bEnableVBR = 1;
|
||||
Mp3Config.format.lhv1.nVBRQuality = quality;
|
||||
Mp3Config.format.lhv1.nVBRQuality = 9 - _settings.EncoderModeIndex;
|
||||
Mp3Config.format.lhv1.nVbrMethod = VBRMETHOD.VBR_METHOD_NEW; // --vbr-new
|
||||
return Mp3Config;
|
||||
}
|
||||
|
||||
@@ -2,17 +2,14 @@
|
||||
|
||||
namespace CUETools.Codecs.LAME
|
||||
{
|
||||
public class LAMEEncoderVBRSettings
|
||||
public class LAMEEncoderVBRSettings : AudioEncoderSettings
|
||||
{
|
||||
[DefaultValue(LAMEEncoderVBRProcessingQuality.Normal)]
|
||||
public LAMEEncoderVBRProcessingQuality Quality { get; set; }
|
||||
|
||||
public LAMEEncoderVBRSettings()
|
||||
: base("V9 V8 V7 V6 V5 V4 V3 V2 V1 V0", "V2")
|
||||
{
|
||||
// Iterate through each property and call ResetValue()
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this)) {
|
||||
property.ResetValue(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,12 +61,6 @@ namespace CUETools.Codecs.LAME
|
||||
set { }
|
||||
}
|
||||
|
||||
public virtual int CompressionLevel
|
||||
{
|
||||
get { return 0; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public long FinalSampleCount
|
||||
{
|
||||
set
|
||||
@@ -94,11 +88,11 @@ namespace CUETools.Codecs.LAME
|
||||
get { return this.outputPath; }
|
||||
}
|
||||
|
||||
public virtual object Settings
|
||||
public virtual AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
return new AudioEncoderSettings();
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
@@ -3,12 +3,9 @@ using System.IO;
|
||||
|
||||
namespace CUETools.Codecs.LAME
|
||||
{
|
||||
[AudioEncoderClass("CBR (libmp3lame)", "mp3", false, "96 128 192 256 320", "256", 1, typeof(LameWriterCBRSettings))]
|
||||
[AudioEncoderClass("CBR (libmp3lame)", "mp3", false, 1, typeof(LameWriterCBRSettings))]
|
||||
public class LameWriterCBR : LameWriter
|
||||
{
|
||||
private static readonly int[] bps_table = new int[] { 96, 128, 192, 256, 320 };
|
||||
private int bps;
|
||||
|
||||
public LameWriterCBR(string path, Stream IO, AudioPCMConfig pcm)
|
||||
: base(IO, pcm)
|
||||
{
|
||||
@@ -19,30 +16,9 @@ namespace CUETools.Codecs.LAME
|
||||
{
|
||||
}
|
||||
|
||||
public override int CompressionLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int i = 0; i < bps_table.Length; i++)
|
||||
{
|
||||
if (bps == bps_table[i])
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0 || value > bps_table.Length)
|
||||
throw new Exception("unsupported compression level");
|
||||
bps = bps_table[value];
|
||||
}
|
||||
}
|
||||
|
||||
LameWriterCBRSettings _settings = new LameWriterCBRSettings();
|
||||
|
||||
public override object Settings
|
||||
public override AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -60,7 +36,7 @@ namespace CUETools.Codecs.LAME
|
||||
{
|
||||
get
|
||||
{
|
||||
return LameWriterConfig.CreateCbr(this.bps, this._settings.Quality);
|
||||
return LameWriterConfig.CreateCbr(LameWriterCBRSettings.bps_table[this._settings.EncoderModeIndex], this._settings.Quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,19 +5,16 @@ using System.Text;
|
||||
|
||||
namespace CUETools.Codecs.LAME
|
||||
{
|
||||
public class LameWriterCBRSettings
|
||||
public class LameWriterCBRSettings : AudioEncoderSettings
|
||||
{
|
||||
public static readonly int[] bps_table = new int[] { 96, 128, 192, 256, 320 };
|
||||
|
||||
[DefaultValue(LameQuality.High)]
|
||||
public LameQuality Quality { get; set; }
|
||||
|
||||
public LameWriterCBRSettings()
|
||||
: base("96 128 192 256 320", "256")
|
||||
{
|
||||
// Iterate through each property and call ResetValue()
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this))
|
||||
{
|
||||
property.ResetValue(this);
|
||||
}
|
||||
this.Quality = LameQuality.High;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,9 @@ using System.IO;
|
||||
|
||||
namespace CUETools.Codecs.LAME
|
||||
{
|
||||
[AudioEncoderClass("VBR (libmp3lame)", "mp3", false, "V9 V8 V7 V6 V5 V4 V3 V2 V1 V0", "V2", 2, typeof(LameWriterVBRSettings))]
|
||||
[AudioEncoderClass("VBR (libmp3lame)", "mp3", false, 2, typeof(LameWriterVBRSettings))]
|
||||
public class LameWriterVBR : LameWriter
|
||||
{
|
||||
private int quality = 0;
|
||||
|
||||
public LameWriterVBR(string path, Stream IO, AudioPCMConfig pcm)
|
||||
: base(IO, pcm)
|
||||
{
|
||||
@@ -18,23 +16,9 @@ namespace CUETools.Codecs.LAME
|
||||
{
|
||||
}
|
||||
|
||||
public override int CompressionLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
return 9 - quality;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0 || value > 9)
|
||||
throw new Exception("unsupported compression level");
|
||||
quality = 9 - value;
|
||||
}
|
||||
}
|
||||
|
||||
LameWriterVBRSettings _settings = new LameWriterVBRSettings();
|
||||
|
||||
public override object Settings
|
||||
public override AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -52,7 +36,7 @@ namespace CUETools.Codecs.LAME
|
||||
{
|
||||
get
|
||||
{
|
||||
return LameWriterConfig.CreateVbr(this.quality, this._settings.Quality);
|
||||
return LameWriterConfig.CreateVbr(9 - this._settings.EncoderModeIndex, this._settings.Quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,14 @@ using System.Text;
|
||||
|
||||
namespace CUETools.Codecs.LAME
|
||||
{
|
||||
public class LameWriterVBRSettings
|
||||
public class LameWriterVBRSettings: AudioEncoderSettings
|
||||
{
|
||||
[DefaultValue(LameQuality.High)]
|
||||
public LameQuality Quality { get; set; }
|
||||
|
||||
public LameWriterVBRSettings()
|
||||
: base("V9 V8 V7 V6 V5 V4 V3 V2 V1 V0", "V2")
|
||||
{
|
||||
// Iterate through each property and call ResetValue()
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this)) {
|
||||
property.ResetValue(this);
|
||||
}
|
||||
this.Quality = LameQuality.High;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,21 +76,15 @@ namespace CUETools.Codecs.LossyWAV
|
||||
set { }
|
||||
}
|
||||
|
||||
public int CompressionLevel
|
||||
{
|
||||
get { return 0; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public object Settings
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
return new AudioEncoderSettings();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value.GetType() != typeof(object))
|
||||
if (value != null && value.GetType() != typeof(AudioEncoderSettings))
|
||||
throw new Exception("Unsupported options " + value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace TTA {
|
||||
}
|
||||
};
|
||||
|
||||
[AudioEncoderClass("ttalib", "tta", true, "", "", 1, Object::typeid)]
|
||||
[AudioEncoderClass("ttalib", "tta", true, 1, AudioEncoderSettings::typeid)]
|
||||
public ref class TTAWriter : public IAudioDest
|
||||
{
|
||||
public:
|
||||
@@ -221,7 +221,6 @@ namespace TTA {
|
||||
_path = path;
|
||||
_finalSampleCount = 0;
|
||||
_samplesWritten = 0;
|
||||
_compressionLevel = 5;
|
||||
_blockSize = 0;
|
||||
}
|
||||
|
||||
@@ -316,33 +315,22 @@ namespace TTA {
|
||||
_samplesWritten += sampleBuffer->Length;
|
||||
}
|
||||
|
||||
virtual property Int32 CompressionLevel {
|
||||
Int32 get() {
|
||||
return _compressionLevel;
|
||||
}
|
||||
void set(Int32 value) {
|
||||
if (value > 0)
|
||||
throw gcnew Exception("Invalid compression level.");
|
||||
_compressionLevel = value;
|
||||
}
|
||||
}
|
||||
|
||||
virtual property __int64 Padding
|
||||
{
|
||||
void set(__int64 value) {
|
||||
}
|
||||
}
|
||||
|
||||
virtual property Object^ Settings
|
||||
virtual property AudioEncoderSettings^ Settings
|
||||
{
|
||||
Object^ get()
|
||||
AudioEncoderSettings^ get()
|
||||
{
|
||||
return nullptr;
|
||||
return gcnew AudioEncoderSettings();
|
||||
}
|
||||
|
||||
void set(Object^ value)
|
||||
void set(AudioEncoderSettings^ value)
|
||||
{
|
||||
if (value != nullptr && value->GetType() != Object::typeid)
|
||||
if (value != nullptr && value->GetType() != AudioEncoderSettings::typeid)
|
||||
throw gcnew Exception(String::Format("Unsupported options: {0}", value));
|
||||
}
|
||||
}
|
||||
@@ -355,87 +343,12 @@ namespace TTA {
|
||||
String^ _path;
|
||||
Int64 _finalSampleCount, _samplesWritten, _blockSize;
|
||||
AudioPCMConfig^ _pcm;
|
||||
Int32 _compressionLevel;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
if (!_finalSampleCount)
|
||||
throw gcnew Exception("FinalSampleCount not set.");
|
||||
|
||||
//FLAC__StreamMetadata *padding, *seektable, *vorbiscomment;
|
||||
|
||||
//_metadataList = new FLAC__StreamMetadata*[8];
|
||||
//_metadataCount = 0;
|
||||
|
||||
//if (_finalSampleCount != 0) {
|
||||
// seektable = FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE);
|
||||
// FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(
|
||||
// seektable, _sampleRate * 10, _finalSampleCount);
|
||||
// FLAC__metadata_object_seektable_template_sort(seektable, true);
|
||||
// _metadataList[_metadataCount++] = seektable;
|
||||
//}
|
||||
|
||||
//vorbiscomment = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
|
||||
|
||||
//for (int tagno = 0; tagno < _tags->Count; tagno++)
|
||||
//{
|
||||
// String ^ tag_name = _tags->GetKey(tagno);
|
||||
// int tag_len = tag_name->Length;
|
||||
// char * tag = new char [tag_len + 1];
|
||||
// IntPtr nameChars = Marshal::StringToHGlobalAnsi(tag_name);
|
||||
// memcpy (tag, (const char*)nameChars.ToPointer(), tag_len);
|
||||
// Marshal::FreeHGlobal(nameChars);
|
||||
// tag[tag_len] = 0;
|
||||
|
||||
// array<String^>^ tag_values = _tags->GetValues(tagno);
|
||||
// for (int valno = 0; valno < tag_values->Length; valno++)
|
||||
// {
|
||||
// UTF8Encoding^ enc = gcnew UTF8Encoding();
|
||||
// array<Byte>^ value_array = enc->GetBytes (tag_values[valno]);
|
||||
// int value_len = value_array->Length;
|
||||
// char * value = new char [value_len + 1];
|
||||
// Marshal::Copy (value_array, 0, (IntPtr) value, value_len);
|
||||
// value[value_len] = 0;
|
||||
|
||||
// FLAC__StreamMetadata_VorbisComment_Entry entry;
|
||||
// /* create and entry and append it */
|
||||
// if(!FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, tag, value)) {
|
||||
// throw gcnew Exception("Unable to add tags, must be valid utf8.");
|
||||
// }
|
||||
// if(!FLAC__metadata_object_vorbiscomment_append_comment(vorbiscomment, entry, /*copy=*/false)) {
|
||||
// throw gcnew Exception("Unable to add tags.");
|
||||
// }
|
||||
// delete [] value;
|
||||
// }
|
||||
// delete [] tag;
|
||||
//}
|
||||
//_metadataList[_metadataCount++] = vorbiscomment;
|
||||
|
||||
//if (_paddingLength != 0) {
|
||||
// padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING);
|
||||
// padding->length = _paddingLength;
|
||||
// _metadataList[_metadataCount++] = padding;
|
||||
//}
|
||||
|
||||
//FLAC__stream_encoder_set_metadata(_encoder, _metadataList, _metadataCount);
|
||||
|
||||
//FLAC__stream_encoder_set_verify(_encoder, _verify);
|
||||
|
||||
//if (_finalSampleCount != 0) {
|
||||
// FLAC__stream_encoder_set_total_samples_estimate(_encoder, _finalSampleCount);
|
||||
//}
|
||||
|
||||
//FLAC__stream_encoder_set_compression_level(_encoder, _compressionLevel);
|
||||
|
||||
//if (_blockSize > 0)
|
||||
// FLAC__stream_encoder_set_blocksize(_encoder, (unsigned)_blockSize);
|
||||
|
||||
//if (FLAC__stream_encoder_init_FILE(_encoder, hFile, NULL, NULL) !=
|
||||
// FLAC__STREAM_ENCODER_INIT_STATUS_OK)
|
||||
//{
|
||||
// throw gcnew Exception("Unable to initialize the encoder.");
|
||||
//}
|
||||
|
||||
_IO = gcnew FileStream (_path, FileMode::Create, FileAccess::Write, FileShare::Read);
|
||||
try
|
||||
{
|
||||
|
||||
@@ -2,19 +2,18 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using CUETools.Codecs;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using WindowsMediaLib;
|
||||
using WindowsMediaLib.Defs;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace CUETools.Codecs.WMA
|
||||
{
|
||||
public class WMAWriterSettings
|
||||
public class WMAWriterSettings : AudioEncoderSettings
|
||||
{
|
||||
public WMAWriterSettings() { }
|
||||
}
|
||||
|
||||
|
||||
[AudioEncoderClass("windows", "wma", true, "", "", 1, typeof(WMAWriterSettings))]
|
||||
[AudioEncoderClass("windows", "wma", true, 1, typeof(WMAWriterSettings))]
|
||||
public class WMAWriter : IAudioDest
|
||||
{
|
||||
IWMProfileManager m_pProfileManager;
|
||||
@@ -32,12 +31,6 @@ namespace CUETools.Codecs.WMA
|
||||
set { }
|
||||
}
|
||||
|
||||
public virtual int CompressionLevel
|
||||
{
|
||||
get { return 0; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public long FinalSampleCount
|
||||
{
|
||||
set
|
||||
@@ -61,9 +54,20 @@ namespace CUETools.Codecs.WMA
|
||||
get { return this.outputPath; }
|
||||
}
|
||||
|
||||
public virtual object Settings
|
||||
AudioEncoderSettings m_settings = new AudioEncoderSettings();
|
||||
|
||||
public virtual AudioEncoderSettings Settings
|
||||
{
|
||||
get; set;
|
||||
get
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value.GetType() != typeof(AudioEncoderSettings))
|
||||
throw new Exception("Unsupported options " + value);
|
||||
m_settings = value;
|
||||
}
|
||||
}
|
||||
|
||||
public WMAWriter(string path, AudioPCMConfig pcm)
|
||||
@@ -81,6 +85,10 @@ namespace CUETools.Codecs.WMA
|
||||
bool codecFound = false;
|
||||
for (int iCodec = 0; iCodec < cCodecs; iCodec++)
|
||||
{
|
||||
int szCodecName = 0;
|
||||
pCodecInfo3.GetCodecName(MediaType.Audio, iCodec, null, ref szCodecName);
|
||||
var codecName = new StringBuilder(szCodecName);
|
||||
pCodecInfo3.GetCodecName(MediaType.Audio, iCodec, codecName, ref szCodecName);
|
||||
//if (codec != WMAvoice)
|
||||
try
|
||||
{
|
||||
|
||||
@@ -293,10 +293,11 @@ namespace CUETools { namespace Codecs { namespace WavPack {
|
||||
}
|
||||
};
|
||||
|
||||
public ref class WavPackWriterSettings
|
||||
public ref class WavPackWriterSettings : AudioEncoderSettings
|
||||
{
|
||||
public:
|
||||
WavPackWriterSettings()
|
||||
: AudioEncoderSettings("fast normal high high+", "normal")
|
||||
{
|
||||
_md5Sum = true;
|
||||
_extraMode = 0;
|
||||
@@ -333,7 +334,7 @@ namespace CUETools { namespace Codecs { namespace WavPack {
|
||||
Int32 _extraMode;
|
||||
};
|
||||
|
||||
[AudioEncoderClass("libwavpack", "wv", true, "fast normal high high+", "normal", 1, WavPackWriterSettings::typeid)]
|
||||
[AudioEncoderClass("libwavpack", "wv", true, 1, WavPackWriterSettings::typeid)]
|
||||
public ref class WavPackWriter : IAudioDest
|
||||
{
|
||||
public:
|
||||
@@ -350,7 +351,6 @@ namespace CUETools { namespace Codecs { namespace WavPack {
|
||||
|
||||
_path = path;
|
||||
|
||||
_compressionMode = 1;
|
||||
_blockSize = 0;
|
||||
|
||||
IntPtr pathChars = Marshal::StringToHGlobalUni(path);
|
||||
@@ -452,33 +452,20 @@ namespace CUETools { namespace Codecs { namespace WavPack {
|
||||
}
|
||||
}
|
||||
|
||||
virtual property int CompressionLevel
|
||||
{
|
||||
int get() {
|
||||
return _compressionMode;
|
||||
}
|
||||
void set(int value) {
|
||||
if ((value < 0) || (value > 3)) {
|
||||
throw gcnew Exception("Invalid compression mode.");
|
||||
}
|
||||
_compressionMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
virtual property __int64 Padding
|
||||
{
|
||||
void set(__int64 value) {
|
||||
}
|
||||
}
|
||||
|
||||
virtual property Object^ Settings
|
||||
virtual property AudioEncoderSettings^ Settings
|
||||
{
|
||||
Object^ get()
|
||||
AudioEncoderSettings^ get()
|
||||
{
|
||||
return _settings;
|
||||
}
|
||||
|
||||
void set(Object^ value)
|
||||
void set(AudioEncoderSettings^ value)
|
||||
{
|
||||
if (value == nullptr || value->GetType() != WavPackWriterSettings::typeid)
|
||||
throw gcnew Exception(String::Format("Unsupported options: {0}", value));
|
||||
@@ -500,7 +487,7 @@ namespace CUETools { namespace Codecs { namespace WavPack {
|
||||
bool _initialized;
|
||||
WavpackContext *_wpc;
|
||||
Int32 _finalSampleCount, _samplesWritten;
|
||||
Int32 _compressionMode, _blockSize;
|
||||
Int32 _blockSize;
|
||||
String^ _path;
|
||||
MD5^ _md5hasher;
|
||||
array<int,2>^ _shiftedSampleBuffer;
|
||||
@@ -521,6 +508,7 @@ namespace CUETools { namespace Codecs { namespace WavPack {
|
||||
config.num_channels = _pcm->ChannelCount;
|
||||
config.channel_mask = 5 - _pcm->ChannelCount;
|
||||
config.sample_rate = _pcm->SampleRate;
|
||||
Int32 _compressionMode = _settings->EncoderModeIndex;
|
||||
if (_compressionMode == 0) config.flags |= CONFIG_FAST_FLAG;
|
||||
if (_compressionMode == 2) config.flags |= CONFIG_HIGH_FLAG;
|
||||
if (_compressionMode == 3) config.flags |= CONFIG_HIGH_FLAG | CONFIG_VERY_HIGH_FLAG;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace CUETools.Codecs
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
public sealed class AudioEncoderClass : Attribute
|
||||
{
|
||||
private string _encoderName, _extension, _supportedModes, _defaultMode;
|
||||
private string _encoderName, _extension;
|
||||
private bool _lossless;
|
||||
private int _priority;
|
||||
private Type _settings;
|
||||
@@ -36,16 +36,6 @@ namespace CUETools.Codecs
|
||||
get { return _extension; }
|
||||
}
|
||||
|
||||
public string SupportedModes
|
||||
{
|
||||
get { return _supportedModes; }
|
||||
}
|
||||
|
||||
public string DefaultMode
|
||||
{
|
||||
get { return _defaultMode; }
|
||||
}
|
||||
|
||||
public bool Lossless
|
||||
{
|
||||
get { return _lossless; }
|
||||
@@ -61,12 +51,10 @@ namespace CUETools.Codecs
|
||||
get { return _settings; }
|
||||
}
|
||||
|
||||
public AudioEncoderClass(string encoderName, string extension, bool lossless, string supportedModes, string defaultMode, int priority, Type settings)
|
||||
public AudioEncoderClass(string encoderName, string extension, bool lossless, int priority, Type settings)
|
||||
{
|
||||
_encoderName = encoderName;
|
||||
_extension = extension;
|
||||
_supportedModes = supportedModes;
|
||||
_defaultMode = defaultMode;
|
||||
_lossless = lossless;
|
||||
_priority = priority;
|
||||
_settings = settings;
|
||||
|
||||
79
CUETools.Codecs/AudioEncoderSettings.cs
Normal file
79
CUETools.Codecs/AudioEncoderSettings.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
using System.Text;
|
||||
|
||||
namespace CUETools.Codecs
|
||||
{
|
||||
public class AudioEncoderSettings
|
||||
{
|
||||
public AudioEncoderSettings()
|
||||
{
|
||||
// Iterate through each property and call ResetValue()
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this))
|
||||
property.ResetValue(this);
|
||||
this.supported_modes = "";
|
||||
this.EncoderMode = "";
|
||||
}
|
||||
|
||||
public AudioEncoderSettings(string _supported_modes, string _default_mode)
|
||||
{
|
||||
// Iterate through each property and call ResetValue()
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this))
|
||||
property.ResetValue(this);
|
||||
this.supported_modes = _supported_modes;
|
||||
this.EncoderMode = _default_mode;
|
||||
}
|
||||
|
||||
private string supported_modes;
|
||||
|
||||
public virtual string GetSupportedModes()
|
||||
{
|
||||
return this.supported_modes;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public string EncoderMode
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
[Browsable(false)]
|
||||
public string[] SupportedModes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetSupportedModes().Split(' ');
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
[Browsable(false)]
|
||||
public int EncoderModeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
string[] modes = this.SupportedModes;
|
||||
if (modes == null || modes.Length < 1)
|
||||
return -1;
|
||||
for (int i = 0; i < modes.Length; i++)
|
||||
if (modes[i] == this.EncoderMode)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
string[] modes = this.SupportedModes;
|
||||
if (modes.Length == 0 && value < 0)
|
||||
return;
|
||||
if (value < 0 || value >= modes.Length)
|
||||
throw new InvalidOperationException();
|
||||
this.EncoderMode = modes[value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="AudioBuffer.cs" />
|
||||
<Compile Include="AudioDecoderClass.cs" />
|
||||
<Compile Include="AudioEncoderSettings.cs" />
|
||||
<Compile Include="AudioPCMConfig.cs" />
|
||||
<Compile Include="AudioPipe.cs" />
|
||||
<Compile Include="AudioSamples.cs" />
|
||||
|
||||
@@ -24,21 +24,15 @@ namespace CUETools.Codecs
|
||||
set { }
|
||||
}
|
||||
|
||||
public int CompressionLevel
|
||||
{
|
||||
get { return 0; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public object Settings
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
return new AudioEncoderSettings();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value.GetType() != typeof(object))
|
||||
if (value != null && value.GetType() != typeof(AudioEncoderSettings))
|
||||
throw new Exception("Unsupported options " + value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
AudioPCMConfig PCM { get; }
|
||||
string Path { get; }
|
||||
|
||||
int CompressionLevel { get; set; }
|
||||
object Settings { get; set; }
|
||||
AudioEncoderSettings Settings { get; set; }
|
||||
long FinalSampleCount { set; }
|
||||
long BlockSize { set; }
|
||||
long Padding { set; }
|
||||
|
||||
@@ -33,21 +33,16 @@ namespace CUETools.Codecs
|
||||
set { }
|
||||
}
|
||||
|
||||
public int CompressionLevel
|
||||
{
|
||||
get { return 0; }
|
||||
set { } // !!!! Must not start the process in constructor, so that we can set CompressionLevel!
|
||||
}
|
||||
|
||||
public object Settings
|
||||
// !!!! Must not start the process in constructor, so that we can set CompressionLevel via Settings!
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
return new AudioEncoderSettings();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value.GetType() != typeof(object))
|
||||
if (value != null && value.GetType() != typeof(AudioEncoderSettings))
|
||||
throw new Exception("Unsupported options " + value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.IO;
|
||||
|
||||
namespace CUETools.Codecs
|
||||
{
|
||||
[AudioEncoderClass("cuetools", "wav", true, "", "", 10, typeof(object))]
|
||||
[AudioEncoderClass("cuetools", "wav", true, 10, typeof(AudioEncoderSettings))]
|
||||
public class WAVWriter : IAudioDest
|
||||
{
|
||||
private Stream _IO;
|
||||
@@ -36,21 +36,15 @@ namespace CUETools.Codecs
|
||||
set { }
|
||||
}
|
||||
|
||||
public int CompressionLevel
|
||||
{
|
||||
get { return 0; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public object Settings
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
return new AudioEncoderSettings();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value.GetType() != typeof(object))
|
||||
if (value != null && value.GetType() != typeof(AudioEncoderSettings))
|
||||
throw new Exception("Unsupported options " + value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,21 +27,15 @@ namespace CUETools.DSP.Mixer
|
||||
set { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public int CompressionLevel
|
||||
{
|
||||
get { return 0; }
|
||||
set { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public object Settings
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
return new AudioEncoderSettings();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value.GetType() != typeof(object))
|
||||
if (value != null && value.GetType() != typeof(AudioEncoderSettings))
|
||||
throw new Exception("Unsupported options " + value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,12 +187,15 @@ namespace CUETools.FLACCL.cmd
|
||||
blocksize = intarg;
|
||||
else if ((args[arg] == "-p" || args[arg] == "--padding") && ++arg < args.Length && int.TryParse(args[arg], out intarg))
|
||||
padding = intarg;
|
||||
else if (args[arg] != "-" && args[arg][0] == '-' && int.TryParse(args[arg].Substring(1), out level))
|
||||
ok = level >= 0 && level <= 11;
|
||||
else if ((args[arg][0] != '-' || args[arg] == "-") && input_file == null)
|
||||
input_file = args[arg];
|
||||
else
|
||||
ok = false;
|
||||
else if (args[arg] != "-" && args[arg][0] == '-' && int.TryParse(args[arg].Substring(1), out level))
|
||||
{
|
||||
ok = level >= 0 && level <= 11;
|
||||
settings.EncoderModeIndex = level;
|
||||
}
|
||||
else if ((args[arg][0] != '-' || args[arg] == "-") && input_file == null)
|
||||
input_file = args[arg];
|
||||
else
|
||||
ok = false;
|
||||
if (!ok)
|
||||
break;
|
||||
}
|
||||
@@ -258,8 +261,6 @@ namespace CUETools.FLACCL.cmd
|
||||
if (device_type != null)
|
||||
settings.DeviceType = (OpenCLDeviceType)(Enum.Parse(typeof(OpenCLDeviceType), device_type, true));
|
||||
encoder.Settings = settings;
|
||||
if (level >= 0)
|
||||
encoder.CompressionLevel = level;
|
||||
if (stereo_method != null)
|
||||
encoder.StereoMethod = Flake.LookupStereoMethod(stereo_method);
|
||||
if (window_function != null)
|
||||
|
||||
@@ -326,11 +326,16 @@ namespace CUETools.FlakeExe
|
||||
flake.FinalSampleCount = audioSource.Length - skip_a - skip_b;
|
||||
IAudioDest audioDest = flake;
|
||||
AudioBuffer buff = new AudioBuffer(audioSource, 0x10000);
|
||||
var settings = new FlakeWriterSettings();
|
||||
|
||||
try
|
||||
{
|
||||
if (level >= 0)
|
||||
flake.CompressionLevel = level;
|
||||
settings.EncoderModeIndex = level;
|
||||
settings.DoVerify = do_verify;
|
||||
settings.DoMD5 = do_md5;
|
||||
|
||||
flake.Settings = settings;
|
||||
if (prediction_type != null)
|
||||
flake.PredictionType = Flake.LookupPredictionType(prediction_type);
|
||||
if (stereo_method != null)
|
||||
@@ -368,8 +373,6 @@ namespace CUETools.FlakeExe
|
||||
if (magic >= 0)
|
||||
flake.DevelopmentMode = magic;
|
||||
flake.DoSeekTable = do_seektable;
|
||||
(flake.Settings as FlakeWriterSettings).DoVerify = do_verify;
|
||||
(flake.Settings as FlakeWriterSettings).DoMD5 = do_md5;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace CUETools.Processor
|
||||
if (encoder == null)
|
||||
throw new Exception("Unsupported audio type: " + path);
|
||||
if (encoder.path != null)
|
||||
dest = new UserDefinedWriter(path, null, pcm, encoder.path, encoder.parameters, encoder.default_mode, padding);
|
||||
dest = new UserDefinedWriter(path, null, pcm, encoder.path, encoder.parameters, encoder.EncoderMode, padding);
|
||||
else if (encoder.type != null)
|
||||
{
|
||||
object o = Activator.CreateInstance(encoder.type, path, pcm);
|
||||
@@ -97,10 +97,9 @@ namespace CUETools.Processor
|
||||
}
|
||||
else
|
||||
throw new Exception("Unsupported audio type: " + path);
|
||||
dest.CompressionLevel = encoder.DefaultModeIndex;
|
||||
dest.Settings = encoder.settings;
|
||||
dest.FinalSampleCount = finalSampleCount;
|
||||
dest.Padding = padding;
|
||||
dest.Settings = encoder.settings;
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
@@ -325,13 +325,13 @@ return processor.Go();
|
||||
foreach (CUEToolsUDC encoder in encoders)
|
||||
{
|
||||
sw.Save(string.Format("ExternalEncoder{0}Name", nEncoders), encoder.name);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Modes", nEncoders), encoder.supported_modes);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Mode", nEncoders), encoder.default_mode);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Extension", nEncoders), encoder.extension);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Lossless", nEncoders), encoder.lossless);
|
||||
if (encoder.path != null)
|
||||
{
|
||||
sw.Save(string.Format("ExternalEncoder{0}Extension", nEncoders), encoder.extension);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Modes", nEncoders), encoder.SupportedModesStr);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Mode", nEncoders), encoder.EncoderMode);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Path", nEncoders), encoder.path);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Lossless", nEncoders), encoder.lossless);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Parameters", nEncoders), encoder.parameters);
|
||||
}
|
||||
else
|
||||
@@ -493,6 +493,8 @@ return processor.Go();
|
||||
encoder.path = path;
|
||||
encoder.lossless = lossless;
|
||||
encoder.parameters = parameters;
|
||||
encoder.SupportedModesStr = supported_modes;
|
||||
encoder.EncoderMode = default_mode;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -500,14 +502,12 @@ return processor.Go();
|
||||
try
|
||||
{
|
||||
using (TextReader reader = new StringReader(parameters))
|
||||
encoder.settings = encoder.settingsSerializer.Deserialize(reader);
|
||||
encoder.settings = encoder.settingsSerializer.Deserialize(reader) as AudioEncoderSettings;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
encoder.supported_modes = supported_modes;
|
||||
encoder.default_mode = default_mode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,14 @@ namespace CUETools.Processor
|
||||
public string path = "";
|
||||
public string parameters = "";
|
||||
public Type type = null;
|
||||
public object settings = null;
|
||||
public AudioEncoderSettings settings = null;
|
||||
public XmlSerializer settingsSerializer = null;
|
||||
public string supported_modes = "";
|
||||
public string default_mode = "";
|
||||
public bool lossless = false;
|
||||
public int priority = 0;
|
||||
|
||||
private string supported_modes = "";
|
||||
private string default_mode = "";
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public CUEToolsUDC(
|
||||
@@ -47,18 +48,16 @@ namespace CUETools.Processor
|
||||
name = enc.EncoderName;
|
||||
extension = enc.Extension;
|
||||
lossless = enc.Lossless;
|
||||
supported_modes = enc.SupportedModes;
|
||||
default_mode = enc.DefaultMode;
|
||||
priority = enc.Priority;
|
||||
path = null;
|
||||
parameters = "";
|
||||
type = enctype;
|
||||
settingsSerializer = null;
|
||||
settings = null;
|
||||
if (enc.Settings != null && enc.Settings != typeof(object))
|
||||
if (enc.Settings != null && typeof(AudioEncoderSettings).IsAssignableFrom(enc.Settings))
|
||||
{
|
||||
settingsSerializer = new XmlSerializer(enc.Settings);
|
||||
settings = Activator.CreateInstance(enc.Settings);
|
||||
settings = Activator.CreateInstance(enc.Settings) as AudioEncoderSettings;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +66,6 @@ namespace CUETools.Processor
|
||||
name = dec.DecoderName;
|
||||
extension = dec.Extension;
|
||||
lossless = true;
|
||||
supported_modes = "";
|
||||
default_mode = "";
|
||||
priority = dec.Priority;
|
||||
path = null;
|
||||
parameters = null;
|
||||
@@ -105,26 +102,50 @@ namespace CUETools.Processor
|
||||
get { return lossless; }
|
||||
set { lossless = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Lossless")); }
|
||||
}
|
||||
|
||||
public string Extension
|
||||
{
|
||||
get { return extension; }
|
||||
set { extension = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Extension")); }
|
||||
}
|
||||
|
||||
public string DotExtension
|
||||
{
|
||||
get { return "." + extension; }
|
||||
}
|
||||
|
||||
public string SupportedModesStr
|
||||
{
|
||||
get { return supported_modes; }
|
||||
set { supported_modes = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("SupportedModesStr")); }
|
||||
get
|
||||
{
|
||||
return this.settings == null ? this.supported_modes : this.settings.GetSupportedModes();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.settings != null) throw new NotSupportedException();
|
||||
supported_modes = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("SupportedModesStr"));
|
||||
}
|
||||
}
|
||||
|
||||
public string EncoderMode
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.settings != null) return this.settings.EncoderMode;
|
||||
else return this.default_mode;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.settings != null) this.settings.EncoderMode = value;
|
||||
else this.default_mode = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string[] SupportedModes
|
||||
{
|
||||
get
|
||||
{
|
||||
return supported_modes.Split(' ');
|
||||
return this.SupportedModesStr.Split(' ');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,11 +153,11 @@ namespace CUETools.Processor
|
||||
{
|
||||
get
|
||||
{
|
||||
string[] modes = supported_modes.Split(' ');
|
||||
string[] modes = this.SupportedModes;
|
||||
if (modes == null || modes.Length < 2)
|
||||
return -1;
|
||||
for (int i = 0; i < modes.Length; i++)
|
||||
if (modes[i] == default_mode)
|
||||
if (modes[i] == this.EncoderMode)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2464,7 +2464,7 @@ namespace JDP
|
||||
{
|
||||
trackBarEncoderMode.Maximum = modes.Length - 1;
|
||||
trackBarEncoderMode.Value = encoder.DefaultModeIndex == -1 ? modes.Length - 1 : encoder.DefaultModeIndex;
|
||||
labelEncoderMode.Text = encoder.default_mode;
|
||||
labelEncoderMode.Text = encoder.EncoderMode;
|
||||
labelEncoderMinMode.Text = modes[0];
|
||||
labelEncoderMaxMode.Text = modes[modes.Length - 1];
|
||||
trackBarEncoderMode.Visible = true;
|
||||
@@ -2478,8 +2478,8 @@ namespace JDP
|
||||
{
|
||||
CUEToolsUDC encoder = comboBoxEncoder.SelectedItem as CUEToolsUDC;
|
||||
string[] modes = encoder.SupportedModes;
|
||||
encoder.default_mode = modes[trackBarEncoderMode.Value];
|
||||
labelEncoderMode.Text = encoder.default_mode;
|
||||
encoder.EncoderMode = modes[trackBarEncoderMode.Value];
|
||||
labelEncoderMode.Text = encoder.EncoderMode;
|
||||
}
|
||||
|
||||
//private void toolStripButton1_Click(object sender, EventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user