mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
Removed AudioEncoderSettings/AudioDecoderSettings classes, all of their functionality is now in IAudioEncoderSettings/IAudioDecoderSettings interfaces.
This commit is contained in:
@@ -252,7 +252,7 @@
|
||||
<Content Include="Plugins\CUDA.NET.dll" />
|
||||
<Content Include="Plugins\CUETools.Codecs.ALAC.dll" />
|
||||
<Content Include="Plugins\CUETools.Codecs.FlaCuda.dll" />
|
||||
<Content Include="Plugins\CUETools.Codecs.FLAKE.dll" />
|
||||
<Content Include="Plugins\CUETools.Codecs.Flake.dll" />
|
||||
<Content Include="Plugins\CUETools.Ripper.SCSI.dll" />
|
||||
<None Include="Resources\cd_eject.png" />
|
||||
<None Include="Resources\wma.ico" />
|
||||
|
||||
@@ -1002,7 +1002,7 @@ namespace CUERipper
|
||||
{
|
||||
encoder.Settings.PCM = AudioPCMConfig.RedBook;
|
||||
buttonEncoderSettings.Enabled = encoder.Settings.HasBrowsableAttributes();
|
||||
string[] modes = encoder.SupportedModes;
|
||||
string[] modes = encoder.SupportedModes.Split(' ');
|
||||
if (modes == null || modes.Length < 2)
|
||||
{
|
||||
trackBarEncoderMode.Visible = false;
|
||||
@@ -1013,11 +1013,7 @@ namespace CUERipper
|
||||
else
|
||||
{
|
||||
if (encoder.EncoderModeIndex == -1)
|
||||
{
|
||||
string defaultMode;
|
||||
encoder.Settings.GetSupportedModes(out defaultMode);
|
||||
encoder.Settings.EncoderMode = defaultMode;
|
||||
}
|
||||
encoder.Settings.EncoderMode = encoder.Settings.DefaultMode;
|
||||
trackBarEncoderMode.Maximum = modes.Length - 1;
|
||||
trackBarEncoderMode.Value = encoder.EncoderModeIndex == -1 ? modes.Length - 1 : encoder.EncoderModeIndex;
|
||||
labelEncoderMode.Text = encoder.Settings.EncoderMode;
|
||||
@@ -1047,7 +1043,7 @@ namespace CUERipper
|
||||
private void trackBarEncoderMode_Scroll(object sender, EventArgs e)
|
||||
{
|
||||
var encoder = bnComboBoxEncoder.SelectedItem as AudioEncoderSettingsViewModel;
|
||||
string[] modes = encoder.SupportedModes;
|
||||
string[] modes = encoder.SupportedModes.Split(' ');
|
||||
encoder.Settings.EncoderMode = modes[trackBarEncoderMode.Value];
|
||||
labelEncoderMode.Text = encoder.Settings.EncoderMode;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace CUETools.ALACEnc
|
||||
else if (args[arg] != "-" && args[arg][0] == '-' && int.TryParse(args[arg].Substring(1), out intarg))
|
||||
{
|
||||
ok = intarg >= 0 && intarg <= 11;
|
||||
settings.EncoderModeIndex = intarg;
|
||||
settings.SetEncoderModeIndex(intarg);
|
||||
}
|
||||
else if ((args[arg][0] != '-' || args[arg] == "-") && input_file == null)
|
||||
input_file = args[arg];
|
||||
|
||||
@@ -930,25 +930,13 @@ namespace CUETools.AccurateRip
|
||||
throw new Exception("unsupported");
|
||||
}
|
||||
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return new AudioEncoderSettings(AudioPCMConfig.RedBook);
|
||||
}
|
||||
}
|
||||
public IAudioEncoderSettings Settings => new Codecs.WAV.EncoderSettings(AudioPCMConfig.RedBook);
|
||||
|
||||
public CDImageLayout TOC
|
||||
{
|
||||
get { return _toc; }
|
||||
}
|
||||
public CDImageLayout TOC => _toc;
|
||||
|
||||
public long FinalSampleCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return _finalSampleCount;
|
||||
}
|
||||
get => _finalSampleCount;
|
||||
set
|
||||
{
|
||||
if (value != _finalSampleCount)
|
||||
|
||||
@@ -413,15 +413,9 @@ namespace CUETools.AccurateRip
|
||||
throw new Exception("unsupported");
|
||||
}
|
||||
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return new AudioEncoderSettings(AudioPCMConfig.RedBook);
|
||||
}
|
||||
}
|
||||
public IAudioEncoderSettings Settings => new Codecs.WAV.EncoderSettings(AudioPCMConfig.RedBook);
|
||||
|
||||
public string Path
|
||||
public string Path
|
||||
{
|
||||
get { throw new Exception("unsupported"); }
|
||||
}
|
||||
|
||||
@@ -72,9 +72,9 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CUETools.Codecs.FLAKE\CUETools.Codecs.FLAKE.csproj">
|
||||
<ProjectReference Include="..\CUETools.Codecs.Flake\CUETools.Codecs.Flake.csproj">
|
||||
<Project>{082D6B9E-326E-4D15-9798-EDAE9EDE70A6}</Project>
|
||||
<Name>CUETools.Codecs.FLAKE</Name>
|
||||
<Name>CUETools.Codecs.Flake</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\CUETools.Codecs\CUETools.Codecs.csproj">
|
||||
|
||||
@@ -4,6 +4,8 @@ using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using CUETools.Codecs;
|
||||
using System.ComponentModel;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
//Copyright (c) 2008 Grigory Chudov.
|
||||
//This library is based on ALAC decoder by David Hammerton.
|
||||
@@ -27,17 +29,32 @@ using CUETools.Codecs;
|
||||
|
||||
namespace CUETools.Codecs.ALAC
|
||||
{
|
||||
public class DecoderSettings : AudioDecoderSettings
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class DecoderSettings : IAudioDecoderSettings
|
||||
{
|
||||
public override string Extension => "m4a";
|
||||
#region IAudioDecoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "m4a";
|
||||
|
||||
public override string Name => "cuetools";
|
||||
[Browsable(false)]
|
||||
public string Name => "cuetools";
|
||||
|
||||
public override Type DecoderType => typeof(AudioDecoder);
|
||||
[Browsable(false)]
|
||||
public Type DecoderType => typeof(AudioDecoder);
|
||||
|
||||
public override int Priority => 2;
|
||||
[Browsable(false)]
|
||||
public int Priority => 2;
|
||||
|
||||
public DecoderSettings() : base() { }
|
||||
public IAudioDecoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioDecoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public DecoderSettings()
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
}
|
||||
|
||||
public class AudioDecoder : IAudioSource
|
||||
@@ -73,7 +90,7 @@ namespace CUETools.Codecs.ALAC
|
||||
}
|
||||
|
||||
private DecoderSettings m_settings;
|
||||
public AudioDecoderSettings Settings => m_settings;
|
||||
public IAudioDecoderSettings Settings => m_settings;
|
||||
|
||||
private void InitTables()
|
||||
{
|
||||
|
||||
@@ -35,26 +35,59 @@ using Newtonsoft.Json;
|
||||
namespace CUETools.Codecs.ALAC
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class EncoderSettings: AudioEncoderSettings
|
||||
public class EncoderSettings: IAudioEncoderSettings
|
||||
{
|
||||
public override string Extension => "m4a";
|
||||
#region IAudioEncoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "m4a";
|
||||
|
||||
public override string Name => "cuetools";
|
||||
[Browsable(false)]
|
||||
public string Name => "cuetools";
|
||||
|
||||
public override Type EncoderType => typeof(AudioEncoder);
|
||||
[Browsable(false)]
|
||||
public Type EncoderType => typeof(AudioEncoder);
|
||||
|
||||
public override int Priority => 1;
|
||||
[Browsable(false)]
|
||||
public bool Lossless => true;
|
||||
|
||||
public override bool Lossless => true;
|
||||
[Browsable(false)]
|
||||
public int Priority => 1;
|
||||
|
||||
[Browsable(false)]
|
||||
public string SupportedModes => "0 1 2 3 4 5 6 7 8 9 10";
|
||||
|
||||
[Browsable(false)]
|
||||
public string DefaultMode => "5";
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string EncoderMode { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public AudioPCMConfig PCM { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int BlockSize { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue(4096)]
|
||||
public int Padding { get; set; }
|
||||
|
||||
public IAudioEncoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioEncoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public EncoderSettings()
|
||||
: base("0 1 2 3 4 5 6 7 8 9 10", "5")
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (EncoderModeIndex < 0
|
||||
if (this.GetEncoderModeIndex() < 0
|
||||
|| Padding < 0
|
||||
|| (BlockSize != 0 && (BlockSize < 256 || BlockSize >= Int32.MaxValue)))
|
||||
throw new Exception("unsupported encoder settings");
|
||||
@@ -140,7 +173,7 @@ namespace CUETools.Codecs.ALAC
|
||||
windowType = new WindowFunction[lpc.MAX_LPC_WINDOWS];
|
||||
windowSections = new LpcWindowSection[lpc.MAX_LPC_WINDOWS, lpc.MAX_LPC_SECTIONS];
|
||||
|
||||
eparams.set_defaults(m_settings.EncoderModeIndex);
|
||||
eparams.set_defaults(m_settings.GetEncoderModeIndex());
|
||||
|
||||
frame = new ALACFrame(Settings.PCM.ChannelCount == 2 ? 5 : Settings.PCM.ChannelCount);
|
||||
chunk_pos = new List<int>();
|
||||
@@ -161,13 +194,7 @@ namespace CUETools.Codecs.ALAC
|
||||
|
||||
EncoderSettings m_settings;
|
||||
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
}
|
||||
public IAudioEncoderSettings Settings => m_settings;
|
||||
|
||||
#if INTEROP
|
||||
[DllImport("kernel32.dll")]
|
||||
|
||||
@@ -82,35 +82,44 @@ namespace CUETools { namespace Codecs { namespace APE {
|
||||
|
||||
ref class AudioDecoder;
|
||||
|
||||
public ref class DecoderSettings : public AudioDecoderSettings
|
||||
[Newtonsoft::Json::JsonObject(Newtonsoft::Json::MemberSerialization::OptIn)]
|
||||
public ref class DecoderSettings : public IAudioDecoderSettings
|
||||
{
|
||||
public:
|
||||
DecoderSettings()
|
||||
: AudioDecoderSettings()
|
||||
{
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property String^ Name
|
||||
{
|
||||
String^ get() override { return "MAC_SDK"; }
|
||||
String^ get() { return "MAC_SDK"; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property String^ Extension
|
||||
{
|
||||
String^ get() override { return "ape"; }
|
||||
String^ get() { return "ape"; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property Type^ DecoderType
|
||||
{
|
||||
Type^ get() override { return AudioDecoder::typeid; }
|
||||
Type^ get() { return AudioDecoder::typeid; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property int Priority
|
||||
{
|
||||
int get() override { return 1; }
|
||||
int get() { return 1; }
|
||||
}
|
||||
|
||||
virtual property String^ Version
|
||||
virtual IAudioDecoderSettings^ Clone()
|
||||
{
|
||||
return (IAudioDecoderSettings^)MemberwiseClone();
|
||||
}
|
||||
|
||||
property String^ Version
|
||||
{
|
||||
String^ get()
|
||||
{
|
||||
@@ -248,8 +257,8 @@ namespace CUETools { namespace Codecs { namespace APE {
|
||||
return buff->Length;
|
||||
}
|
||||
|
||||
virtual property AudioDecoderSettings^ Settings {
|
||||
AudioDecoderSettings^ get(void) {
|
||||
virtual property IAudioDecoderSettings^ Settings {
|
||||
IAudioDecoderSettings^ get(void) {
|
||||
return m_settings;
|
||||
}
|
||||
}
|
||||
@@ -280,46 +289,103 @@ namespace CUETools { namespace Codecs { namespace APE {
|
||||
|
||||
ref class AudioEncoder;
|
||||
|
||||
public ref class EncoderSettings : public AudioEncoderSettings
|
||||
[Newtonsoft::Json::JsonObject(Newtonsoft::Json::MemberSerialization::OptIn)]
|
||||
public ref class EncoderSettings : public IAudioEncoderSettings
|
||||
{
|
||||
public:
|
||||
EncoderSettings()
|
||||
: AudioEncoderSettings("fast normal high extra insane", "high")
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property String^ Name
|
||||
{
|
||||
String^ get() override { return "MAC_SDK"; }
|
||||
String^ get() { return "MAC_SDK"; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property String^ Extension
|
||||
{
|
||||
String^ get() override { return "ape"; }
|
||||
String^ get() { return "ape"; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property Type^ EncoderType
|
||||
{
|
||||
Type^ get() override { return AudioEncoder::typeid; }
|
||||
Type^ get() { return AudioEncoder::typeid; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property bool Lossless
|
||||
{
|
||||
bool get() override { return true; }
|
||||
bool get() { return true; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property int Priority
|
||||
{
|
||||
int get() override { return 1; }
|
||||
int get() { return 1; }
|
||||
}
|
||||
|
||||
virtual property String^ Version
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property String^ SupportedModes
|
||||
{
|
||||
String^ get() { return "fast normal high extra insane"; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property String^ DefaultMode
|
||||
{
|
||||
String^ get() { return "high"; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
[Newtonsoft::Json::JsonProperty]
|
||||
virtual property String^ EncoderMode
|
||||
{
|
||||
String^ get() { return encoderMode; }
|
||||
void set(String^ value) { encoderMode = value; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property AudioPCMConfig^ PCM
|
||||
{
|
||||
AudioPCMConfig^ get() { return pcm; }
|
||||
void set(AudioPCMConfig^ value) { pcm = value; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property int BlockSize
|
||||
{
|
||||
int get() { return blockSize; }
|
||||
void set(int value) { blockSize = value; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property int Padding
|
||||
{
|
||||
int get() { return padding; }
|
||||
void set(int value) { padding = value; }
|
||||
}
|
||||
|
||||
virtual IAudioEncoderSettings^ Clone()
|
||||
{
|
||||
return (IAudioEncoderSettings^)MemberwiseClone();
|
||||
}
|
||||
|
||||
EncoderSettings()
|
||||
{
|
||||
IAudioEncoderSettingsExtensions::Init(this, nullptr);
|
||||
}
|
||||
|
||||
property String^ Version
|
||||
{
|
||||
String^ get()
|
||||
{
|
||||
return MAC_VERSION_STRING;
|
||||
}
|
||||
}
|
||||
private:
|
||||
String ^ encoderMode;
|
||||
AudioPCMConfig^ pcm;
|
||||
int blockSize;
|
||||
int padding;
|
||||
};
|
||||
|
||||
public ref class AudioEncoder : IAudioDest
|
||||
@@ -420,9 +486,9 @@ namespace CUETools { namespace Codecs { namespace APE {
|
||||
}
|
||||
}
|
||||
|
||||
virtual property AudioEncoderSettings^ Settings
|
||||
virtual property IAudioEncoderSettings^ Settings
|
||||
{
|
||||
AudioEncoderSettings^ get()
|
||||
IAudioEncoderSettings^ get()
|
||||
{
|
||||
return _settings;
|
||||
}
|
||||
@@ -452,7 +518,7 @@ namespace CUETools { namespace Codecs { namespace APE {
|
||||
WAVEFORMATEX waveFormat;
|
||||
FillWaveFormatEx (&waveFormat, _settings->PCM->SampleRate, _settings->PCM->BitsPerSample, _settings->PCM->ChannelCount);
|
||||
|
||||
Int32 _compressionLevel = (_settings->EncoderModeIndex + 1) * 1000;
|
||||
Int32 _compressionLevel = (IAudioEncoderSettingsExtensions::GetEncoderModeIndex(_settings) + 1) * 1000;
|
||||
|
||||
int res = pAPECompress->StartEx (_winFileIO,
|
||||
&waveFormat,
|
||||
|
||||
@@ -184,6 +184,12 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\bin\Release\net40\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace CUETools.Codecs.BDLPCM
|
||||
settings = new DecoderSettings();
|
||||
}
|
||||
|
||||
public AudioDecoderSettings Settings { get { return settings; } }
|
||||
public IAudioDecoderSettings Settings => settings;
|
||||
|
||||
public void Close()
|
||||
{
|
||||
|
||||
@@ -7,25 +7,39 @@ using Newtonsoft.Json;
|
||||
namespace CUETools.Codecs.BDLPCM
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class DecoderSettings : AudioDecoderSettings
|
||||
public class DecoderSettings : IAudioDecoderSettings
|
||||
{
|
||||
public override string Extension => "m2ts";
|
||||
#region IAudioDecoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "m2ts";
|
||||
|
||||
public override string Name => "cuetools";
|
||||
[Browsable(false)]
|
||||
public string Name => "cuetools";
|
||||
|
||||
public override Type DecoderType => typeof(AudioDecoder);
|
||||
[Browsable(false)]
|
||||
public Type DecoderType => typeof(AudioDecoder);
|
||||
|
||||
public override int Priority => 2;
|
||||
[Browsable(false)]
|
||||
public int Priority => 2;
|
||||
|
||||
public IAudioDecoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioDecoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public DecoderSettings()
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
|
||||
[DefaultValue(true)]
|
||||
public bool IgnoreShortItems { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int? Stream { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public ushort? Pid { get; set; }
|
||||
|
||||
public DecoderSettings() : base()
|
||||
{
|
||||
IgnoreShortItems = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace CUETools.Codecs.BDLPCM
|
||||
return mark;
|
||||
}
|
||||
|
||||
public AudioDecoderSettings Settings { get { return settings; } }
|
||||
public IAudioDecoderSettings Settings => settings;
|
||||
|
||||
public void Close()
|
||||
{
|
||||
|
||||
@@ -7,25 +7,39 @@ using Newtonsoft.Json;
|
||||
namespace CUETools.Codecs.MPLS
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class DecoderSettings : AudioDecoderSettings
|
||||
public class DecoderSettings : IAudioDecoderSettings
|
||||
{
|
||||
public override string Extension => "mpls";
|
||||
#region IAudioDecoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "mpls";
|
||||
|
||||
public override string Name => "cuetools";
|
||||
[Browsable(false)]
|
||||
public string Name => "cuetools";
|
||||
|
||||
public override Type DecoderType => typeof(BDLPCM.MPLSDecoder);
|
||||
[Browsable(false)]
|
||||
public Type DecoderType => typeof(BDLPCM.MPLSDecoder);
|
||||
|
||||
public override int Priority => 2;
|
||||
[Browsable(false)]
|
||||
public int Priority => 2;
|
||||
|
||||
public IAudioDecoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioDecoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public DecoderSettings()
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
|
||||
[DefaultValue(true)]
|
||||
public bool IgnoreShortItems { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int? Stream { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public ushort? Pid { get; set; }
|
||||
|
||||
public DecoderSettings() : base()
|
||||
{
|
||||
IgnoreShortItems = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace CUETools.Codecs.CoreAudio
|
||||
private long _sampleOffset;
|
||||
private NAudio.Wave.WaveFormatExtensible outputFormat;
|
||||
WaitHandle[] waitHandles;
|
||||
AudioEncoderSettings m_settings;
|
||||
Codecs.WAV.EncoderSettings m_settings;
|
||||
|
||||
/// <summary>
|
||||
/// Playback Stopped
|
||||
@@ -67,7 +67,7 @@ namespace CUETools.Codecs.CoreAudio
|
||||
/// <param name="latency"></param>
|
||||
public WasapiOut(MMDevice device, AudioClientShareMode shareMode, bool useEventSync, int latency, AudioPCMConfig pcm)
|
||||
{
|
||||
this.m_settings = new AudioEncoderSettings(pcm);
|
||||
this.m_settings = new Codecs.WAV.EncoderSettings(pcm);
|
||||
this.audioClient = device.AudioClient;
|
||||
this.shareMode = shareMode;
|
||||
this.isUsingEventSync = useEventSync;
|
||||
@@ -474,30 +474,18 @@ namespace CUETools.Codecs.CoreAudio
|
||||
|
||||
#endregion
|
||||
|
||||
#region IAudioDest Members
|
||||
#region IAudioDest Members
|
||||
|
||||
public long Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return _sampleOffset;
|
||||
}
|
||||
}
|
||||
public long Position => _sampleOffset;
|
||||
|
||||
public long FinalSampleCount
|
||||
{
|
||||
set { ; }
|
||||
}
|
||||
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
}
|
||||
public IAudioEncoderSettings Settings => m_settings;
|
||||
|
||||
public string Path { get { return null; } }
|
||||
public string Path => null;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -71,9 +71,9 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CUETools.Codecs.FLAKE\CUETools.Codecs.FLAKE.csproj">
|
||||
<ProjectReference Include="..\CUETools.Codecs.Flake\CUETools.Codecs.Flake.csproj">
|
||||
<Project>{082D6B9E-326E-4D15-9798-EDAE9EDE70A6}</Project>
|
||||
<Name>CUETools.Codecs.FLAKE</Name>
|
||||
<Name>CUETools.Codecs.Flake</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\CUETools.Codecs\CUETools.Codecs.csproj">
|
||||
|
||||
@@ -26,37 +26,64 @@ using System.Threading;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using CUETools.Codecs;
|
||||
using CUETools.Codecs.FLAKE;
|
||||
using CUETools.Codecs.Flake;
|
||||
using OpenCLNet;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace CUETools.Codecs.FLACCL
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class EncoderSettings : AudioEncoderSettings
|
||||
public class EncoderSettings : IAudioEncoderSettings
|
||||
{
|
||||
public override string Extension => "flac";
|
||||
#region IAudioEncoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "flac";
|
||||
|
||||
public override string Name => "FLACCL";
|
||||
[Browsable(false)]
|
||||
public string Name => "FLACCL";
|
||||
|
||||
public override Type EncoderType => typeof(AudioEncoder);
|
||||
[Browsable(false)]
|
||||
public Type EncoderType => typeof(AudioEncoder);
|
||||
|
||||
public override int Priority => 2;
|
||||
[Browsable(false)]
|
||||
public bool Lossless => true;
|
||||
|
||||
public override bool Lossless => true;
|
||||
[Browsable(false)]
|
||||
public int Priority => 2;
|
||||
|
||||
[Browsable(false)]
|
||||
public string SupportedModes => this.AllowNonSubset || (this.PCM != null && this.PCM.SampleRate > 48000) ? "0 1 2 3 4 5 6 7 8 9 10 11" : "0 1 2 3 4 5 6 7 8";
|
||||
|
||||
[Browsable(false)]
|
||||
public string DefaultMode => "8";
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string EncoderMode { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public AudioPCMConfig PCM { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int BlockSize { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue(4096)]
|
||||
public int Padding { get; set; }
|
||||
|
||||
public IAudioEncoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioEncoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
internal IntPtr m_platform = IntPtr.Zero;
|
||||
internal IntPtr m_device = IntPtr.Zero;
|
||||
|
||||
public EncoderSettings()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public override string GetSupportedModes(out string defaultMode)
|
||||
{
|
||||
defaultMode = "8";
|
||||
return this.AllowNonSubset || (this.PCM != null && this.PCM.SampleRate > 48000) ? "0 1 2 3 4 5 6 7 8 9 10 11" : "0 1 2 3 4 5 6 7 8";
|
||||
this.Init();
|
||||
}
|
||||
|
||||
public bool IsSubset()
|
||||
@@ -74,7 +101,7 @@ namespace CUETools.Codecs.FLACCL
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (EncoderModeIndex < 0)
|
||||
if (this.GetEncoderModeIndex() < 0)
|
||||
throw new Exception("unsupported encoder mode");
|
||||
if (OpenCL.NumberOfPlatforms < 1)
|
||||
throw new Exception("no opencl platforms found");
|
||||
@@ -109,7 +136,7 @@ namespace CUETools.Codecs.FLACCL
|
||||
Device = devices[0].Name;
|
||||
DriverVersion = devices[0].DriverVersion;
|
||||
}
|
||||
SetDefaultValuesForMode();
|
||||
this.SetDefaultValuesForMode();
|
||||
if (Padding < 0)
|
||||
throw new Exception("unsupported padding value " + Padding.ToString());
|
||||
if (BlockSize != 0 && (BlockSize < 256 || BlockSize >= FlakeConstants.MAX_BLOCKSIZE))
|
||||
@@ -384,7 +411,7 @@ namespace CUETools.Codecs.FLACCL
|
||||
|
||||
internal EncoderSettings m_settings;
|
||||
|
||||
public AudioEncoderSettings Settings
|
||||
public IAudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -2310,7 +2337,7 @@ namespace CUETools.Codecs.FLACCL
|
||||
|
||||
public int flake_set_defaults(EncoderSettings settings)
|
||||
{
|
||||
int lvl = settings.EncoderModeIndex;
|
||||
int lvl = settings.GetEncoderModeIndex();
|
||||
// default to level 5 params
|
||||
window_function = WindowFunction.Flattop | WindowFunction.Tukey;
|
||||
do_midside = true;
|
||||
@@ -2630,7 +2657,7 @@ namespace CUETools.Codecs.FLACCL
|
||||
frame.writer = new BitWriter(outputBuffer, 0, outputBuffer.Length);
|
||||
|
||||
if (writer.m_settings.DoVerify)
|
||||
verify = new FLAKE.AudioDecoder(writer.Settings.PCM);
|
||||
verify = new Flake.AudioDecoder(writer.Settings.PCM);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
public enum ChannelMode
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
unsafe public class FlacFrame
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
unsafe public class FlacSubframe
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
unsafe public class FlacSubframeInfo
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
public class FlakeConstants
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
public enum MetadataType
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
public enum OrderMethod
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
/// <summary>
|
||||
/// Type of linear prediction
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace CUETools.Codecs.FLAKE.Properties {
|
||||
namespace CUETools.Codecs.Flake.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace CUETools.Codecs.FLAKE.Properties {
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CUETools.Codecs.FLAKE.Properties.Resources", typeof(Resources).Assembly);
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CUETools.Codecs.Flake.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
unsafe public class RiceContext
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
public struct SeekPoint
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
public enum StereoMethod
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
public enum SubframeType
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
public enum WindowFunction
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
public enum WindowMethod
|
||||
{
|
||||
|
||||
@@ -72,9 +72,9 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CUETools.Codecs.FLAKE\CUETools.Codecs.FLAKE.csproj">
|
||||
<ProjectReference Include="..\CUETools.Codecs.Flake\CUETools.Codecs.Flake.csproj">
|
||||
<Project>{082D6B9E-326E-4D15-9798-EDAE9EDE70A6}</Project>
|
||||
<Name>CUETools.Codecs.FLAKE</Name>
|
||||
<Name>CUETools.Codecs.Flake</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\CUETools.Codecs\CUETools.Codecs.csproj">
|
||||
|
||||
@@ -24,21 +24,8 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
public class DecoderSettings : AudioDecoderSettings
|
||||
{
|
||||
public override string Extension => "flac";
|
||||
|
||||
public override string Name => "cuetools";
|
||||
|
||||
public override Type DecoderType => typeof(AudioDecoder);
|
||||
|
||||
public override int Priority => 2;
|
||||
|
||||
public DecoderSettings() : base() { }
|
||||
}
|
||||
|
||||
public class AudioDecoder: IAudioSource
|
||||
{
|
||||
int[] samplesBuffer;
|
||||
@@ -133,7 +120,7 @@ namespace CUETools.Codecs.FLAKE
|
||||
}
|
||||
|
||||
private DecoderSettings m_settings;
|
||||
public AudioDecoderSettings Settings => m_settings;
|
||||
public IAudioDecoderSettings Settings => m_settings;
|
||||
|
||||
public void Close()
|
||||
{
|
||||
@@ -34,244 +34,8 @@ using System.Runtime.InteropServices;
|
||||
using CUETools.Codecs;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace CUETools.Codecs.FLAKE
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class EncoderSettings : AudioEncoderSettings
|
||||
{
|
||||
public override string Extension => "flac";
|
||||
|
||||
public override string Name => "cuetools";
|
||||
|
||||
public override Type EncoderType => typeof(AudioEncoder);
|
||||
|
||||
public override int Priority => 4;
|
||||
|
||||
public override bool Lossless => true;
|
||||
|
||||
public EncoderSettings()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public override string GetSupportedModes(out string defaultMode)
|
||||
{
|
||||
defaultMode = "5";
|
||||
return this.AllowNonSubset || (this.PCM != null && this.PCM.SampleRate > 48000) ? "0 1 2 3 4 5 6 7 8 9 10 11" : "0 1 2 3 4 5 6 7 8";
|
||||
}
|
||||
|
||||
public bool IsSubset()
|
||||
{
|
||||
return (BlockSize == 0 || (BlockSize <= 16384 && (PCM.SampleRate > 48000 || BlockSize <= 4608)))
|
||||
&& (PCM.SampleRate > 48000 || MaxLPCOrder <= 12)
|
||||
&& MaxPartitionOrder <= 8
|
||||
;
|
||||
//The blocksize bits in the frame header must be 0001-1110. The blocksize must be <=16384; if the sample rate is <= 48000Hz, the blocksize must be <=4608.
|
||||
//The sample rate bits in the frame header must be 0001-1110.
|
||||
//The bits-per-sample bits in the frame header must be 001-111.
|
||||
//If the sample rate is <= 48000Hz, the filter order in LPC subframes must be less than or equal to 12, i.e. the subframe type bits in the subframe header may not be 101100-111111.
|
||||
//The Rice partition order in a Rice-coded residual section must be less than or equal to 8.
|
||||
}
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (EncoderModeIndex < 0)
|
||||
throw new Exception("unsupported encoder mode");
|
||||
SetDefaultValuesForMode();
|
||||
if (Padding < 0)
|
||||
throw new Exception("unsupported padding value " + Padding.ToString());
|
||||
if (BlockSize != 0 && (BlockSize < 256 || BlockSize >= FlakeConstants.MAX_BLOCKSIZE))
|
||||
throw new Exception("unsupported block size " + BlockSize.ToString());
|
||||
if (MinLPCOrder > MaxLPCOrder || MaxLPCOrder > lpc.MAX_LPC_ORDER)
|
||||
throw new Exception("invalid MaxLPCOrder " + MaxLPCOrder.ToString());
|
||||
if (MinFixedOrder < 0 || MinFixedOrder > 4)
|
||||
throw new Exception("invalid MinFixedOrder " + MinFixedOrder.ToString());
|
||||
if (MaxFixedOrder < 0 || MaxFixedOrder > 4)
|
||||
throw new Exception("invalid MaxFixedOrder " + MaxFixedOrder.ToString());
|
||||
if (MinPartitionOrder < 0)
|
||||
throw new Exception("invalid MinPartitionOrder " + MinPartitionOrder.ToString());
|
||||
if (MinPartitionOrder > MaxPartitionOrder || MaxPartitionOrder > 8)
|
||||
throw new Exception("invalid MaxPartitionOrder " + MaxPartitionOrder.ToString());
|
||||
if (PredictionType == PredictionType.None)
|
||||
throw new Exception("invalid PredictionType " + PredictionType.ToString());
|
||||
if (PredictionType != PredictionType.Fixed)
|
||||
{
|
||||
if (WindowMethod == WindowMethod.Invalid)
|
||||
throw new InvalidOperationException("invalid WindowMethod " + WindowMethod.ToString());
|
||||
if (WindowFunctions == WindowFunction.None)
|
||||
throw new InvalidOperationException("invalid WindowFunctions " + WindowFunctions.ToString());
|
||||
if (EstimationDepth > 32 || EstimationDepth < 1)
|
||||
throw new InvalidOperationException("invalid EstimationDepth " + EstimationDepth.ToString());
|
||||
if (MinPrecisionSearch < 0 || MinPrecisionSearch >= lpc.MAX_LPC_PRECISIONS)
|
||||
throw new Exception("unsupported MinPrecisionSearch value");
|
||||
if (MaxPrecisionSearch < 0 || MaxPrecisionSearch >= lpc.MAX_LPC_PRECISIONS)
|
||||
throw new Exception("unsupported MaxPrecisionSearch value");
|
||||
if (MaxPrecisionSearch < MinPrecisionSearch)
|
||||
throw new Exception("unsupported MaxPrecisionSearch value");
|
||||
}
|
||||
if (!AllowNonSubset && !IsSubset())
|
||||
throw new Exception("the encoding parameters specified do not conform to the FLAC Subset");
|
||||
}
|
||||
|
||||
[DefaultValue(-1)]
|
||||
[DefaultValueForMode(2, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0)]
|
||||
[Browsable(false)]
|
||||
[DisplayName("MinFixedOrder")]
|
||||
[SRDescription(typeof(Properties.Resources), "MinFixedOrderDescription")]
|
||||
public int MinFixedOrder { get; set; }
|
||||
|
||||
[DefaultValue(-1)]
|
||||
[DefaultValueForMode(2, 4, 4, 4, 2, 2, 4, 4, 4, 4, 4, 4)]
|
||||
[Browsable(false)]
|
||||
[DisplayName("MaxFixedOrder")]
|
||||
[SRDescription(typeof(Properties.Resources), "MaxFixedOrderDescription")]
|
||||
public int MaxFixedOrder { get; set; }
|
||||
|
||||
[DefaultValue(1)]
|
||||
[Browsable(false)]
|
||||
[DisplayName("MinLPCOrder")]
|
||||
[SRDescription(typeof(Properties.Resources), "MinLPCOrderDescription")]
|
||||
public int MinLPCOrder { get; set; }
|
||||
|
||||
[DefaultValue(-1)]
|
||||
[DefaultValueForMode(8, 8, 8, 12, 12, 12, 12, 12, 12, 32, 32, 32)]
|
||||
[Browsable(false)]
|
||||
[DisplayName("MaxLPCOrder")]
|
||||
[SRDescription(typeof(Properties.Resources), "MaxLPCOrderDescription")]
|
||||
public int MaxLPCOrder { get; set; }
|
||||
|
||||
[DefaultValue(0)]
|
||||
[DisplayName("MinPartitionOrder")]
|
||||
[Browsable(false)]
|
||||
[SRDescription(typeof(Properties.Resources), "MinPartitionOrderDescription")]
|
||||
public int MinPartitionOrder { get; set; }
|
||||
|
||||
[DefaultValue(-1)]
|
||||
[DefaultValueForMode(6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 8)]
|
||||
[DisplayName("MaxPartitionOrder")]
|
||||
[Browsable(false)]
|
||||
[SRDescription(typeof(Properties.Resources), "MaxPartitionOrderDescription")]
|
||||
public int MaxPartitionOrder { get; set; }
|
||||
|
||||
[DefaultValue(false)]
|
||||
[DisplayName("Verify")]
|
||||
[SRDescription(typeof(Properties.Resources), "DoVerifyDescription")]
|
||||
[JsonProperty]
|
||||
public bool DoVerify { get; set; }
|
||||
|
||||
[DefaultValue(true)]
|
||||
[DisplayName("MD5")]
|
||||
[SRDescription(typeof(Properties.Resources), "DoMD5Description")]
|
||||
[JsonProperty]
|
||||
public bool DoMD5 { get; set; }
|
||||
|
||||
[DefaultValue(false)]
|
||||
[DisplayName("Allow Non-subset")]
|
||||
[SRDescription(typeof(Properties.Resources), "AllowNonSubsetDescription")]
|
||||
[JsonProperty]
|
||||
public bool AllowNonSubset { get; set; }
|
||||
|
||||
[DefaultValue(StereoMethod.Invalid)]
|
||||
[DefaultValueForMode(
|
||||
/* 0 */ StereoMethod.Independent,
|
||||
/* 1 */ StereoMethod.EstimateFixed,
|
||||
/* 2 */ StereoMethod.Estimate,
|
||||
/* 3 */ StereoMethod.Estimate,
|
||||
/* 4 */ StereoMethod.Evaluate,
|
||||
/* 5 */ StereoMethod.Evaluate,
|
||||
/* 6 */ StereoMethod.Evaluate,
|
||||
/* 7 */ StereoMethod.Evaluate,
|
||||
/* 8 */ StereoMethod.Evaluate,
|
||||
/* 9 */ StereoMethod.Evaluate,
|
||||
/* 10 */ StereoMethod.Evaluate,
|
||||
/* 11 */ StereoMethod.Evaluate)]
|
||||
[Browsable(false)]
|
||||
public StereoMethod StereoMethod { get; set; }
|
||||
|
||||
[DefaultValue(PredictionType.None)]
|
||||
[DefaultValueForMode(
|
||||
/* 0 */ PredictionType.Fixed,
|
||||
/* 1 */ PredictionType.Fixed,
|
||||
/* 2 */ PredictionType.Levinson,
|
||||
/* 3 */ PredictionType.Levinson,
|
||||
/* 4 */ PredictionType.Search,
|
||||
/* 5 */ PredictionType.Search,
|
||||
/* 6 */ PredictionType.Search,
|
||||
/* 7 */ PredictionType.Search,
|
||||
/* 8 */ PredictionType.Search,
|
||||
/* 9 */ PredictionType.Levinson,
|
||||
/* 10 */ PredictionType.Search,
|
||||
/* 11 */ PredictionType.Search)]
|
||||
[Browsable(false)]
|
||||
public PredictionType PredictionType { get; set; }
|
||||
|
||||
[DefaultValue(WindowMethod.Invalid)]
|
||||
[DefaultValueForMode(
|
||||
/* 0 */ WindowMethod.Invalid,
|
||||
/* 1 */ WindowMethod.Invalid,
|
||||
/* 2 */ WindowMethod.Estimate,
|
||||
/* 3 */ WindowMethod.Estimate,
|
||||
/* 4 */ WindowMethod.Estimate,
|
||||
/* 5 */ WindowMethod.EvaluateN,
|
||||
/* 6 */ WindowMethod.EvaluateN,
|
||||
/* 7 */ WindowMethod.EvaluateN,
|
||||
/* 8 */ WindowMethod.EvaluateN,
|
||||
/* 9 */ WindowMethod.EvaluateN,
|
||||
/* 10 */ WindowMethod.EvaluateN,
|
||||
/* 11 */ WindowMethod.EvaluateN)]
|
||||
[Browsable(false)]
|
||||
public WindowMethod WindowMethod { get; set; }
|
||||
|
||||
[DefaultValue(WindowFunction.None)]
|
||||
[DefaultValueForMode(
|
||||
/* 0 */ WindowFunction.None,
|
||||
/* 1 */ WindowFunction.None,
|
||||
/* 2 */ WindowFunction.Tukey3,
|
||||
/* 3 */ WindowFunction.Tukey4,
|
||||
/* 4 */ WindowFunction.Tukey4,
|
||||
/* 5 */ WindowFunction.Tukey4 | WindowFunction.Tukey3,
|
||||
/* 6 */ WindowFunction.Tukey4 | WindowFunction.Tukey3 | WindowFunction.Tukey,
|
||||
/* 7 */ WindowFunction.Tukey4 | WindowFunction.Tukey3 | WindowFunction.Tukey2 | WindowFunction.Tukey,
|
||||
/* 8 */ WindowFunction.Tukey4 | WindowFunction.Tukey3 | WindowFunction.Tukey2 | WindowFunction.Tukey,
|
||||
/* 9 */ WindowFunction.Tukey3 | WindowFunction.Tukey2 | WindowFunction.Tukey,
|
||||
/* 10 */ WindowFunction.Tukey3 | WindowFunction.Tukey2 | WindowFunction.Tukey,
|
||||
/* 11 */ WindowFunction.Tukey3 | WindowFunction.Tukey2 | WindowFunction.Tukey)]
|
||||
[Browsable(false)]
|
||||
[DisplayName("WindowFunctions")]
|
||||
[SRDescription(typeof(Properties.Resources), "WindowFunctionsDescription")]
|
||||
public WindowFunction WindowFunctions { get; set; }
|
||||
|
||||
[DefaultValue(0)]
|
||||
[DefaultValueForMode(0, 0, 1, 1, 1, 1, 1, 1, 3, 1, 1, 5)]
|
||||
[Browsable(false)]
|
||||
public int EstimationDepth { get; set; }
|
||||
|
||||
[DefaultValue(-1)]
|
||||
[DefaultValueForMode(1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1)]
|
||||
[Browsable(false)]
|
||||
public int MinPrecisionSearch { get; set; }
|
||||
|
||||
[DefaultValue(-1)]
|
||||
[DefaultValueForMode(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)]
|
||||
[Browsable(false)]
|
||||
public int MaxPrecisionSearch { get; set; }
|
||||
|
||||
[DefaultValue(0)]
|
||||
[Browsable(false)]
|
||||
public int TukeyParts { get; set; }
|
||||
|
||||
[DefaultValue(1.0)]
|
||||
[Browsable(false)]
|
||||
public double TukeyOverlap { get; set; }
|
||||
|
||||
[DefaultValue(1.0)]
|
||||
[Browsable(false)]
|
||||
public double TukeyP { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public string[] Tags { get; set; }
|
||||
}
|
||||
|
||||
public class AudioEncoder : IAudioDest
|
||||
{
|
||||
Stream _IO = null;
|
||||
@@ -383,7 +147,7 @@ namespace CUETools.Codecs.FLAKE
|
||||
|
||||
EncoderSettings m_settings;
|
||||
|
||||
public AudioEncoderSettings Settings => m_settings;
|
||||
public IAudioEncoderSettings Settings => m_settings;
|
||||
|
||||
#if INTEROP
|
||||
[DllImport("kernel32.dll")]
|
||||
@@ -2629,7 +2393,7 @@ new int[] { // 30
|
||||
do_seektable = true;
|
||||
development_mode = -1;
|
||||
|
||||
if (settings.EncoderModeIndex == 11)
|
||||
if (settings.GetEncoderModeIndex() == 11)
|
||||
variable_block_size = 4;
|
||||
|
||||
return 0;
|
||||
36
CUETools.Codecs.Flake/DecoderSettings.cs
Normal file
36
CUETools.Codecs.Flake/DecoderSettings.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class DecoderSettings : IAudioDecoderSettings
|
||||
{
|
||||
#region IAudioDecoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "flac";
|
||||
|
||||
[Browsable(false)]
|
||||
public string Name => "cuetools";
|
||||
|
||||
[Browsable(false)]
|
||||
public Type DecoderType => typeof(AudioDecoder);
|
||||
|
||||
[Browsable(false)]
|
||||
public int Priority => 2;
|
||||
|
||||
public IAudioDecoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioDecoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public DecoderSettings()
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
271
CUETools.Codecs.Flake/EncoderSettings.cs
Normal file
271
CUETools.Codecs.Flake/EncoderSettings.cs
Normal file
@@ -0,0 +1,271 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace CUETools.Codecs.Flake
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class EncoderSettings : IAudioEncoderSettings
|
||||
{
|
||||
#region IAudioEncoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "flac";
|
||||
|
||||
[Browsable(false)]
|
||||
public string Name => "cuetools";
|
||||
|
||||
[Browsable(false)]
|
||||
public Type EncoderType => typeof(AudioEncoder);
|
||||
|
||||
[Browsable(false)]
|
||||
public bool Lossless => true;
|
||||
|
||||
[Browsable(false)]
|
||||
public int Priority => 4;
|
||||
|
||||
[Browsable(false)]
|
||||
public string SupportedModes => this.AllowNonSubset || (this.PCM != null && this.PCM.SampleRate > 48000) ? "0 1 2 3 4 5 6 7 8 9 10 11" : "0 1 2 3 4 5 6 7 8";
|
||||
|
||||
[Browsable(false)]
|
||||
public string DefaultMode => "5";
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string EncoderMode { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public AudioPCMConfig PCM { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int BlockSize { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue(4096)]
|
||||
public int Padding { get; set; }
|
||||
|
||||
public IAudioEncoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioEncoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public EncoderSettings()
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
|
||||
public bool IsSubset()
|
||||
{
|
||||
return (BlockSize == 0 || (BlockSize <= 16384 && (PCM.SampleRate > 48000 || BlockSize <= 4608)))
|
||||
&& (PCM.SampleRate > 48000 || MaxLPCOrder <= 12)
|
||||
&& MaxPartitionOrder <= 8
|
||||
;
|
||||
//The blocksize bits in the frame header must be 0001-1110. The blocksize must be <=16384; if the sample rate is <= 48000Hz, the blocksize must be <=4608.
|
||||
//The sample rate bits in the frame header must be 0001-1110.
|
||||
//The bits-per-sample bits in the frame header must be 001-111.
|
||||
//If the sample rate is <= 48000Hz, the filter order in LPC subframes must be less than or equal to 12, i.e. the subframe type bits in the subframe header may not be 101100-111111.
|
||||
//The Rice partition order in a Rice-coded residual section must be less than or equal to 8.
|
||||
}
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (this.GetEncoderModeIndex() < 0)
|
||||
throw new Exception("unsupported encoder mode");
|
||||
this.SetDefaultValuesForMode();
|
||||
if (Padding < 0)
|
||||
throw new Exception("unsupported padding value " + Padding.ToString());
|
||||
if (BlockSize != 0 && (BlockSize < 256 || BlockSize >= FlakeConstants.MAX_BLOCKSIZE))
|
||||
throw new Exception("unsupported block size " + BlockSize.ToString());
|
||||
if (MinLPCOrder > MaxLPCOrder || MaxLPCOrder > lpc.MAX_LPC_ORDER)
|
||||
throw new Exception("invalid MaxLPCOrder " + MaxLPCOrder.ToString());
|
||||
if (MinFixedOrder < 0 || MinFixedOrder > 4)
|
||||
throw new Exception("invalid MinFixedOrder " + MinFixedOrder.ToString());
|
||||
if (MaxFixedOrder < 0 || MaxFixedOrder > 4)
|
||||
throw new Exception("invalid MaxFixedOrder " + MaxFixedOrder.ToString());
|
||||
if (MinPartitionOrder < 0)
|
||||
throw new Exception("invalid MinPartitionOrder " + MinPartitionOrder.ToString());
|
||||
if (MinPartitionOrder > MaxPartitionOrder || MaxPartitionOrder > 8)
|
||||
throw new Exception("invalid MaxPartitionOrder " + MaxPartitionOrder.ToString());
|
||||
if (PredictionType == PredictionType.None)
|
||||
throw new Exception("invalid PredictionType " + PredictionType.ToString());
|
||||
if (PredictionType != PredictionType.Fixed)
|
||||
{
|
||||
if (WindowMethod == WindowMethod.Invalid)
|
||||
throw new InvalidOperationException("invalid WindowMethod " + WindowMethod.ToString());
|
||||
if (WindowFunctions == WindowFunction.None)
|
||||
throw new InvalidOperationException("invalid WindowFunctions " + WindowFunctions.ToString());
|
||||
if (EstimationDepth > 32 || EstimationDepth < 1)
|
||||
throw new InvalidOperationException("invalid EstimationDepth " + EstimationDepth.ToString());
|
||||
if (MinPrecisionSearch < 0 || MinPrecisionSearch >= lpc.MAX_LPC_PRECISIONS)
|
||||
throw new Exception("unsupported MinPrecisionSearch value");
|
||||
if (MaxPrecisionSearch < 0 || MaxPrecisionSearch >= lpc.MAX_LPC_PRECISIONS)
|
||||
throw new Exception("unsupported MaxPrecisionSearch value");
|
||||
if (MaxPrecisionSearch < MinPrecisionSearch)
|
||||
throw new Exception("unsupported MaxPrecisionSearch value");
|
||||
}
|
||||
if (!AllowNonSubset && !IsSubset())
|
||||
throw new Exception("the encoding parameters specified do not conform to the FLAC Subset");
|
||||
}
|
||||
|
||||
[DefaultValue(-1)]
|
||||
[DefaultValueForMode(2, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0)]
|
||||
[Browsable(false)]
|
||||
[DisplayName("MinFixedOrder")]
|
||||
[SRDescription(typeof(Properties.Resources), "MinFixedOrderDescription")]
|
||||
public int MinFixedOrder { get; set; }
|
||||
|
||||
[DefaultValue(-1)]
|
||||
[DefaultValueForMode(2, 4, 4, 4, 2, 2, 4, 4, 4, 4, 4, 4)]
|
||||
[Browsable(false)]
|
||||
[DisplayName("MaxFixedOrder")]
|
||||
[SRDescription(typeof(Properties.Resources), "MaxFixedOrderDescription")]
|
||||
public int MaxFixedOrder { get; set; }
|
||||
|
||||
[DefaultValue(1)]
|
||||
[Browsable(false)]
|
||||
[DisplayName("MinLPCOrder")]
|
||||
[SRDescription(typeof(Properties.Resources), "MinLPCOrderDescription")]
|
||||
public int MinLPCOrder { get; set; }
|
||||
|
||||
[DefaultValue(-1)]
|
||||
[DefaultValueForMode(8, 8, 8, 12, 12, 12, 12, 12, 12, 32, 32, 32)]
|
||||
[Browsable(false)]
|
||||
[DisplayName("MaxLPCOrder")]
|
||||
[SRDescription(typeof(Properties.Resources), "MaxLPCOrderDescription")]
|
||||
public int MaxLPCOrder { get; set; }
|
||||
|
||||
[DefaultValue(0)]
|
||||
[DisplayName("MinPartitionOrder")]
|
||||
[Browsable(false)]
|
||||
[SRDescription(typeof(Properties.Resources), "MinPartitionOrderDescription")]
|
||||
public int MinPartitionOrder { get; set; }
|
||||
|
||||
[DefaultValue(-1)]
|
||||
[DefaultValueForMode(6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 8)]
|
||||
[DisplayName("MaxPartitionOrder")]
|
||||
[Browsable(false)]
|
||||
[SRDescription(typeof(Properties.Resources), "MaxPartitionOrderDescription")]
|
||||
public int MaxPartitionOrder { get; set; }
|
||||
|
||||
[DefaultValue(false)]
|
||||
[DisplayName("Verify")]
|
||||
[SRDescription(typeof(Properties.Resources), "DoVerifyDescription")]
|
||||
[JsonProperty]
|
||||
public bool DoVerify { get; set; }
|
||||
|
||||
[DefaultValue(true)]
|
||||
[DisplayName("MD5")]
|
||||
[SRDescription(typeof(Properties.Resources), "DoMD5Description")]
|
||||
[JsonProperty]
|
||||
public bool DoMD5 { get; set; }
|
||||
|
||||
[DefaultValue(false)]
|
||||
[DisplayName("Allow Non-subset")]
|
||||
[SRDescription(typeof(Properties.Resources), "AllowNonSubsetDescription")]
|
||||
[JsonProperty]
|
||||
public bool AllowNonSubset { get; set; }
|
||||
|
||||
[DefaultValue(StereoMethod.Invalid)]
|
||||
[DefaultValueForMode(
|
||||
/* 0 */ StereoMethod.Independent,
|
||||
/* 1 */ StereoMethod.EstimateFixed,
|
||||
/* 2 */ StereoMethod.Estimate,
|
||||
/* 3 */ StereoMethod.Estimate,
|
||||
/* 4 */ StereoMethod.Evaluate,
|
||||
/* 5 */ StereoMethod.Evaluate,
|
||||
/* 6 */ StereoMethod.Evaluate,
|
||||
/* 7 */ StereoMethod.Evaluate,
|
||||
/* 8 */ StereoMethod.Evaluate,
|
||||
/* 9 */ StereoMethod.Evaluate,
|
||||
/* 10 */ StereoMethod.Evaluate,
|
||||
/* 11 */ StereoMethod.Evaluate)]
|
||||
[Browsable(false)]
|
||||
public StereoMethod StereoMethod { get; set; }
|
||||
|
||||
[DefaultValue(PredictionType.None)]
|
||||
[DefaultValueForMode(
|
||||
/* 0 */ PredictionType.Fixed,
|
||||
/* 1 */ PredictionType.Fixed,
|
||||
/* 2 */ PredictionType.Levinson,
|
||||
/* 3 */ PredictionType.Levinson,
|
||||
/* 4 */ PredictionType.Search,
|
||||
/* 5 */ PredictionType.Search,
|
||||
/* 6 */ PredictionType.Search,
|
||||
/* 7 */ PredictionType.Search,
|
||||
/* 8 */ PredictionType.Search,
|
||||
/* 9 */ PredictionType.Levinson,
|
||||
/* 10 */ PredictionType.Search,
|
||||
/* 11 */ PredictionType.Search)]
|
||||
[Browsable(false)]
|
||||
public PredictionType PredictionType { get; set; }
|
||||
|
||||
[DefaultValue(WindowMethod.Invalid)]
|
||||
[DefaultValueForMode(
|
||||
/* 0 */ WindowMethod.Invalid,
|
||||
/* 1 */ WindowMethod.Invalid,
|
||||
/* 2 */ WindowMethod.Estimate,
|
||||
/* 3 */ WindowMethod.Estimate,
|
||||
/* 4 */ WindowMethod.Estimate,
|
||||
/* 5 */ WindowMethod.EvaluateN,
|
||||
/* 6 */ WindowMethod.EvaluateN,
|
||||
/* 7 */ WindowMethod.EvaluateN,
|
||||
/* 8 */ WindowMethod.EvaluateN,
|
||||
/* 9 */ WindowMethod.EvaluateN,
|
||||
/* 10 */ WindowMethod.EvaluateN,
|
||||
/* 11 */ WindowMethod.EvaluateN)]
|
||||
[Browsable(false)]
|
||||
public WindowMethod WindowMethod { get; set; }
|
||||
|
||||
[DefaultValue(WindowFunction.None)]
|
||||
[DefaultValueForMode(
|
||||
/* 0 */ WindowFunction.None,
|
||||
/* 1 */ WindowFunction.None,
|
||||
/* 2 */ WindowFunction.Tukey3,
|
||||
/* 3 */ WindowFunction.Tukey4,
|
||||
/* 4 */ WindowFunction.Tukey4,
|
||||
/* 5 */ WindowFunction.Tukey4 | WindowFunction.Tukey3,
|
||||
/* 6 */ WindowFunction.Tukey4 | WindowFunction.Tukey3 | WindowFunction.Tukey,
|
||||
/* 7 */ WindowFunction.Tukey4 | WindowFunction.Tukey3 | WindowFunction.Tukey2 | WindowFunction.Tukey,
|
||||
/* 8 */ WindowFunction.Tukey4 | WindowFunction.Tukey3 | WindowFunction.Tukey2 | WindowFunction.Tukey,
|
||||
/* 9 */ WindowFunction.Tukey3 | WindowFunction.Tukey2 | WindowFunction.Tukey,
|
||||
/* 10 */ WindowFunction.Tukey3 | WindowFunction.Tukey2 | WindowFunction.Tukey,
|
||||
/* 11 */ WindowFunction.Tukey3 | WindowFunction.Tukey2 | WindowFunction.Tukey)]
|
||||
[Browsable(false)]
|
||||
[DisplayName("WindowFunctions")]
|
||||
[SRDescription(typeof(Properties.Resources), "WindowFunctionsDescription")]
|
||||
public WindowFunction WindowFunctions { get; set; }
|
||||
|
||||
[DefaultValue(0)]
|
||||
[DefaultValueForMode(0, 0, 1, 1, 1, 1, 1, 1, 3, 1, 1, 5)]
|
||||
[Browsable(false)]
|
||||
public int EstimationDepth { get; set; }
|
||||
|
||||
[DefaultValue(-1)]
|
||||
[DefaultValueForMode(1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1)]
|
||||
[Browsable(false)]
|
||||
public int MinPrecisionSearch { get; set; }
|
||||
|
||||
[DefaultValue(-1)]
|
||||
[DefaultValueForMode(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)]
|
||||
[Browsable(false)]
|
||||
public int MaxPrecisionSearch { get; set; }
|
||||
|
||||
[DefaultValue(0)]
|
||||
[Browsable(false)]
|
||||
public int TukeyParts { get; set; }
|
||||
|
||||
[DefaultValue(1.0)]
|
||||
[Browsable(false)]
|
||||
public double TukeyOverlap { get; set; }
|
||||
|
||||
[DefaultValue(1.0)]
|
||||
[Browsable(false)]
|
||||
public double TukeyP { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public string[] Tags { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ namespace CUETools.Codecs.HDCD
|
||||
get { throw new Exception("unsupported"); }
|
||||
}
|
||||
|
||||
public AudioEncoderSettings Settings
|
||||
public IAudioEncoderSettings Settings
|
||||
{
|
||||
get { throw new Exception("unsupported"); }
|
||||
set { throw new Exception("unsupported"); }
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace CUETools.Codecs.Icecast
|
||||
public class IcecastWriter: IAudioDest
|
||||
{
|
||||
private long _sampleOffset = 0;
|
||||
private AudioEncoderSettings m_settings;
|
||||
private Codecs.WAV.EncoderSettings m_settings;
|
||||
private libmp3lame.AudioEncoder encoder = null;
|
||||
private HttpWebRequest req = null;
|
||||
private HttpWebResponse resp = null;
|
||||
@@ -28,7 +28,7 @@ namespace CUETools.Codecs.Icecast
|
||||
|
||||
public IcecastWriter(AudioPCMConfig pcm, IcecastSettingsData settings)
|
||||
{
|
||||
this.m_settings = new AudioEncoderSettings(pcm);
|
||||
this.m_settings = new Codecs.WAV.EncoderSettings(pcm);
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@@ -194,28 +194,16 @@ namespace CUETools.Codecs.Icecast
|
||||
encoder.Write(tmp);
|
||||
}
|
||||
|
||||
public long Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return _sampleOffset;
|
||||
}
|
||||
}
|
||||
public long Position => _sampleOffset;
|
||||
|
||||
public long FinalSampleCount
|
||||
{
|
||||
set { ; }
|
||||
}
|
||||
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
}
|
||||
public IAudioEncoderSettings Settings => m_settings;
|
||||
|
||||
public string Path { get { return null; } }
|
||||
public string Path => null;
|
||||
#endregion
|
||||
|
||||
public long BytesWritten
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace CUETools.Codecs.LossyWAV
|
||||
private AudioBuffer lwcdfBuffer;
|
||||
private double scaling_factor;
|
||||
|
||||
public AudioDecoderSettings Settings { get { return null; } }
|
||||
public IAudioDecoderSettings Settings => null;
|
||||
|
||||
public long Length
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace CUETools.Codecs.LossyWAV
|
||||
public const string version_string = "1.1.1#";
|
||||
|
||||
private IAudioDest _audioDest, _lwcdfDest;
|
||||
private AudioEncoderSettings m_settings;
|
||||
private Codecs.WAV.EncoderSettings m_settings;
|
||||
private AudioBuffer _audioBuffer;
|
||||
private short[] fft_bit_length;
|
||||
private float[] frequency_limits;
|
||||
@@ -71,13 +71,7 @@ namespace CUETools.Codecs.LossyWAV
|
||||
}
|
||||
}
|
||||
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
}
|
||||
public IAudioEncoderSettings Settings => m_settings;
|
||||
|
||||
public int OverallBitsRemoved
|
||||
{
|
||||
@@ -154,7 +148,7 @@ namespace CUETools.Codecs.LossyWAV
|
||||
|
||||
#region Constructor
|
||||
|
||||
public LossyWAVWriter(IAudioDest audioDest, IAudioDest lwcdfDest, double quality, AudioEncoderSettings settings)
|
||||
public LossyWAVWriter(IAudioDest audioDest, IAudioDest lwcdfDest, double quality, Codecs.WAV.EncoderSettings settings)
|
||||
{
|
||||
_audioDest = audioDest;
|
||||
_lwcdfDest = lwcdfDest;
|
||||
|
||||
@@ -29,32 +29,41 @@ namespace TTA {
|
||||
|
||||
ref class AudioDecoder;
|
||||
|
||||
public ref class DecoderSettings : public AudioDecoderSettings
|
||||
[Newtonsoft::Json::JsonObject(Newtonsoft::Json::MemberSerialization::OptIn)]
|
||||
public ref class DecoderSettings : public IAudioDecoderSettings
|
||||
{
|
||||
public:
|
||||
DecoderSettings()
|
||||
: AudioDecoderSettings()
|
||||
{
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property String^ Name
|
||||
{
|
||||
String^ get() override { return "ttalib"; }
|
||||
String^ get() { return "ttalib"; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property String^ Extension
|
||||
{
|
||||
String^ get() override { return "tta"; }
|
||||
String^ get() { return "tta"; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property Type^ DecoderType
|
||||
{
|
||||
Type^ get() override { return AudioDecoder::typeid; }
|
||||
Type^ get() { return AudioDecoder::typeid; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property int Priority
|
||||
{
|
||||
int get() override { return 1; }
|
||||
int get() { return 1; }
|
||||
}
|
||||
|
||||
virtual IAudioDecoderSettings^ Clone()
|
||||
{
|
||||
return (IAudioDecoderSettings^)MemberwiseClone();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -218,8 +227,8 @@ namespace TTA {
|
||||
return buff->Length;
|
||||
}
|
||||
|
||||
virtual property AudioDecoderSettings^ Settings {
|
||||
AudioDecoderSettings^ get(void) {
|
||||
virtual property IAudioDecoderSettings^ Settings {
|
||||
IAudioDecoderSettings^ get(void) {
|
||||
return m_settings;
|
||||
}
|
||||
}
|
||||
@@ -245,37 +254,95 @@ namespace TTA {
|
||||
|
||||
ref class AudioEncoder;
|
||||
|
||||
public ref class EncoderSettings : public AudioEncoderSettings
|
||||
[Newtonsoft::Json::JsonObject(Newtonsoft::Json::MemberSerialization::OptIn)]
|
||||
public ref class EncoderSettings : public IAudioEncoderSettings
|
||||
{
|
||||
public:
|
||||
EncoderSettings() : AudioEncoderSettings()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property String^ Name
|
||||
{
|
||||
String^ get() override { return "ttalib"; }
|
||||
String^ get() { return "ttalib"; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property String^ Extension
|
||||
{
|
||||
String^ get() override { return "tta"; }
|
||||
String^ get() { return "tta"; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property Type^ EncoderType
|
||||
{
|
||||
Type^ get() override { return AudioEncoder::typeid; }
|
||||
Type^ get() { return AudioEncoder::typeid; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property bool Lossless
|
||||
{
|
||||
bool get() override { return true; }
|
||||
bool get() { return true; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property int Priority
|
||||
{
|
||||
int get() override { return 1; }
|
||||
int get() { return 1; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property String^ SupportedModes
|
||||
{
|
||||
String^ get() { return ""; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property String^ DefaultMode
|
||||
{
|
||||
String^ get() { return ""; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property String^ EncoderMode
|
||||
{
|
||||
String^ get() { return encoderMode; }
|
||||
void set(String^ value) { encoderMode = value; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property AudioPCMConfig^ PCM
|
||||
{
|
||||
AudioPCMConfig^ get() { return pcm; }
|
||||
void set(AudioPCMConfig^ value) { pcm = value; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property int BlockSize
|
||||
{
|
||||
int get() { return blockSize; }
|
||||
void set(int value) { blockSize = value; }
|
||||
}
|
||||
|
||||
[System::ComponentModel::Browsable(false)]
|
||||
virtual property int Padding
|
||||
{
|
||||
int get() { return padding; }
|
||||
void set(int value) { padding = value; }
|
||||
}
|
||||
|
||||
virtual IAudioEncoderSettings^ Clone()
|
||||
{
|
||||
return (IAudioEncoderSettings^)MemberwiseClone();
|
||||
}
|
||||
|
||||
EncoderSettings()
|
||||
{
|
||||
IAudioEncoderSettingsExtensions::Init(this, nullptr);
|
||||
}
|
||||
|
||||
private:
|
||||
String ^ encoderMode;
|
||||
AudioPCMConfig^ pcm;
|
||||
int blockSize;
|
||||
int padding;
|
||||
};
|
||||
|
||||
public ref class AudioEncoder : public IAudioDest
|
||||
@@ -373,9 +440,9 @@ namespace TTA {
|
||||
_samplesWritten += sampleBuffer->Length;
|
||||
}
|
||||
|
||||
virtual property AudioEncoderSettings^ Settings
|
||||
virtual property IAudioEncoderSettings^ Settings
|
||||
{
|
||||
AudioEncoderSettings^ get()
|
||||
IAudioEncoderSettings^ get()
|
||||
{
|
||||
return _settings;
|
||||
}
|
||||
@@ -388,7 +455,7 @@ namespace TTA {
|
||||
bool _initialized;
|
||||
String^ _path;
|
||||
Int64 _finalSampleCount, _samplesWritten;
|
||||
AudioEncoderSettings^ _settings;
|
||||
EncoderSettings^ _settings;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
|
||||
@@ -178,6 +178,12 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\bin\Release\net40\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
|
||||
@@ -18,28 +18,14 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using WindowsMediaLib;
|
||||
using WindowsMediaLib.Defs;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace CUETools.Codecs.WMA
|
||||
{
|
||||
public class DecoderSettings : AudioDecoderSettings
|
||||
{
|
||||
public override string Extension => "wma";
|
||||
|
||||
public override string Name => "windows";
|
||||
|
||||
public override Type DecoderType => typeof(AudioDecoder);
|
||||
|
||||
public override int Priority => 2;
|
||||
|
||||
public DecoderSettings() : base() { }
|
||||
}
|
||||
|
||||
public class AudioDecoder : IAudioSource
|
||||
{
|
||||
IWMSyncReader m_syncReader;
|
||||
@@ -233,7 +219,7 @@ namespace CUETools.Codecs.WMA
|
||||
//m_syncReader.GetMaxOutputSampleSize(m_dwAudioOutputNum, out cbMax);
|
||||
}
|
||||
|
||||
public AudioDecoderSettings Settings { get { return null; } }
|
||||
public IAudioDecoderSettings Settings => null;
|
||||
|
||||
public void isValid(string filename)
|
||||
{
|
||||
160
CUETools.Codecs.WMA/AudioEncoder.cs
Normal file
160
CUETools.Codecs.WMA/AudioEncoder.cs
Normal file
@@ -0,0 +1,160 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using WindowsMediaLib;
|
||||
using WindowsMediaLib.Defs;
|
||||
|
||||
namespace CUETools.Codecs.WMA
|
||||
{
|
||||
public class AudioEncoder : IAudioDest
|
||||
{
|
||||
IWMWriter m_pEncoder;
|
||||
private string outputPath;
|
||||
private bool closed = false;
|
||||
private bool fileCreated = false;
|
||||
private bool writingBegan = false;
|
||||
private long sampleCount, finalSampleCount;
|
||||
|
||||
public long FinalSampleCount
|
||||
{
|
||||
set
|
||||
{
|
||||
this.finalSampleCount = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get { return this.outputPath; }
|
||||
}
|
||||
|
||||
EncoderSettings m_settings;
|
||||
|
||||
public IAudioEncoderSettings Settings => m_settings;
|
||||
|
||||
public AudioEncoder(string path, EncoderSettings settings)
|
||||
{
|
||||
this.m_settings = settings;
|
||||
this.outputPath = path;
|
||||
|
||||
try
|
||||
{
|
||||
m_pEncoder = settings.GetWriter();
|
||||
int cInputs;
|
||||
m_pEncoder.GetInputCount(out cInputs);
|
||||
if (cInputs < 1) throw new InvalidOperationException();
|
||||
IWMInputMediaProps pInput;
|
||||
m_pEncoder.GetInputProps(0, out pInput);
|
||||
try
|
||||
{
|
||||
int cbType = 0;
|
||||
AMMediaType pMediaType = null;
|
||||
pInput.GetMediaType(pMediaType, ref cbType);
|
||||
pMediaType = new AMMediaType();
|
||||
pMediaType.formatSize = cbType - Marshal.SizeOf(typeof(AMMediaType));
|
||||
pInput.GetMediaType(pMediaType, ref cbType);
|
||||
try
|
||||
{
|
||||
var wfe = new WaveFormatExtensible(m_settings.PCM);
|
||||
Marshal.FreeCoTaskMem(pMediaType.formatPtr);
|
||||
pMediaType.formatPtr = IntPtr.Zero;
|
||||
pMediaType.formatSize = 0;
|
||||
pMediaType.formatPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(wfe));
|
||||
pMediaType.formatSize = Marshal.SizeOf(wfe);
|
||||
Marshal.StructureToPtr(wfe, pMediaType.formatPtr, false);
|
||||
pInput.SetMediaType(pMediaType);
|
||||
m_pEncoder.SetInputProps(0, pInput);
|
||||
}
|
||||
finally
|
||||
{
|
||||
WMUtils.FreeWMMediaType(pMediaType);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.ReleaseComObject(pInput);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (m_pEncoder != null)
|
||||
{
|
||||
Marshal.ReleaseComObject(m_pEncoder);
|
||||
m_pEncoder = null;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (!this.closed)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.writingBegan)
|
||||
{
|
||||
m_pEncoder.EndWriting();
|
||||
this.writingBegan = false;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (m_pEncoder != null)
|
||||
{
|
||||
Marshal.ReleaseComObject(m_pEncoder);
|
||||
m_pEncoder = null;
|
||||
}
|
||||
}
|
||||
|
||||
this.closed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
if (this.outputPath == null)
|
||||
throw new InvalidOperationException("This writer was not created from file.");
|
||||
|
||||
if (!this.closed)
|
||||
{
|
||||
this.Close();
|
||||
|
||||
if (this.fileCreated)
|
||||
{
|
||||
File.Delete(this.outputPath);
|
||||
this.fileCreated = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(AudioBuffer buffer)
|
||||
{
|
||||
if (this.closed)
|
||||
throw new InvalidOperationException("Writer already closed.");
|
||||
|
||||
if (!this.fileCreated)
|
||||
{
|
||||
this.m_pEncoder.SetOutputFilename(outputPath);
|
||||
this.fileCreated = true;
|
||||
}
|
||||
if (!this.writingBegan)
|
||||
{
|
||||
this.m_pEncoder.BeginWriting();
|
||||
this.writingBegan = true;
|
||||
}
|
||||
|
||||
buffer.Prepare(this);
|
||||
INSSBuffer pSample;
|
||||
m_pEncoder.AllocateSample(buffer.ByteLength, out pSample);
|
||||
IntPtr pdwBuffer;
|
||||
pSample.GetBuffer(out pdwBuffer);
|
||||
pSample.SetLength(buffer.ByteLength);
|
||||
Marshal.Copy(buffer.Bytes, 0, pdwBuffer, buffer.ByteLength);
|
||||
long cnsSampleTime = sampleCount * 10000000L / Settings.PCM.SampleRate;
|
||||
m_pEncoder.WriteSample(0, cnsSampleTime, SampleFlag.CleanPoint, pSample);
|
||||
Marshal.ReleaseComObject(pSample);
|
||||
sampleCount += buffer.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
CUETools.Codecs.WMA/DecoderSettings.cs
Normal file
34
CUETools.Codecs.WMA/DecoderSettings.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace CUETools.Codecs.WMA
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class DecoderSettings : IAudioDecoderSettings
|
||||
{
|
||||
#region IAudioDecoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "wma";
|
||||
|
||||
[Browsable(false)]
|
||||
public string Name => "windows";
|
||||
|
||||
[Browsable(false)]
|
||||
public Type DecoderType => typeof(AudioDecoder);
|
||||
|
||||
[Browsable(false)]
|
||||
public int Priority => 2;
|
||||
|
||||
public IAudioDecoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioDecoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public DecoderSettings()
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,65 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using CUETools.Codecs;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using WindowsMediaLib;
|
||||
using WindowsMediaLib.Defs;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace CUETools.Codecs.WMA
|
||||
{
|
||||
public abstract class EncoderSettings : AudioEncoderSettings
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public abstract class EncoderSettings : IAudioEncoderSettings
|
||||
{
|
||||
public override Type EncoderType => typeof(AudioEncoder);
|
||||
#region IAudioEncoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "wma";
|
||||
|
||||
public override bool Lossless => true;
|
||||
[Browsable(false)]
|
||||
public abstract string Name { get; }
|
||||
|
||||
[Browsable(false)]
|
||||
public Type EncoderType => typeof(AudioEncoder);
|
||||
|
||||
[Browsable(false)]
|
||||
public abstract bool Lossless { get; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int Priority => 1;
|
||||
|
||||
[Browsable(false)]
|
||||
public string SupportedModes =>
|
||||
string.Join(" ", GetFormats(null).ConvertAll(s => s.modeName).ToArray());
|
||||
|
||||
[Browsable(false)]
|
||||
public string DefaultMode =>
|
||||
GetFormats(null).ConvertAll(s => s.modeName).FindLast(x => true) ?? "";
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string EncoderMode { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public AudioPCMConfig PCM { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int BlockSize { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue(4096)]
|
||||
public int Padding { get; set; }
|
||||
|
||||
public IAudioEncoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioEncoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public EncoderSettings()
|
||||
: base()
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
|
||||
protected Guid m_subType;
|
||||
@@ -190,13 +230,6 @@ namespace CUETools.Codecs.WMA
|
||||
formats.Sort((Comparison<WMAFormatInfo>)((x, y) => int.TryParse(x.modeName, out ix) && int.TryParse(y.modeName, out iy) ? ix - iy : x.modeName.CompareTo(y.modeName)));
|
||||
return formats;
|
||||
}
|
||||
|
||||
public override string GetSupportedModes(out string defaultMode)
|
||||
{
|
||||
var fmts = GetFormats(null);
|
||||
defaultMode = fmts.Count > 0 ? fmts[fmts.Count - 1].modeName : "";
|
||||
return string.Join(" ", fmts.ConvertAll(s => s.modeName).ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
internal class WMAFormatInfo
|
||||
@@ -212,12 +245,8 @@ namespace CUETools.Codecs.WMA
|
||||
|
||||
public class LosslessEncoderSettings : EncoderSettings
|
||||
{
|
||||
public override string Extension => "wma";
|
||||
|
||||
public override string Name => "wma lossless";
|
||||
|
||||
public override int Priority => 1;
|
||||
|
||||
public override bool Lossless => true;
|
||||
|
||||
public LosslessEncoderSettings()
|
||||
@@ -229,11 +258,9 @@ namespace CUETools.Codecs.WMA
|
||||
|
||||
public class LossyEncoderSettings : EncoderSettings
|
||||
{
|
||||
public override string Extension => "wma";
|
||||
|
||||
public override string Name => "wma lossy";
|
||||
|
||||
public override int Priority => 1;
|
||||
public override bool Lossless => false;
|
||||
|
||||
public LossyEncoderSettings()
|
||||
: base()
|
||||
@@ -275,162 +302,4 @@ namespace CUETools.Codecs.WMA
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AudioEncoder : IAudioDest
|
||||
{
|
||||
IWMWriter m_pEncoder;
|
||||
private string outputPath;
|
||||
private bool closed = false;
|
||||
private bool fileCreated = false;
|
||||
private bool writingBegan = false;
|
||||
private long sampleCount, finalSampleCount;
|
||||
|
||||
public long FinalSampleCount
|
||||
{
|
||||
set
|
||||
{
|
||||
this.finalSampleCount = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get { return this.outputPath; }
|
||||
}
|
||||
|
||||
EncoderSettings m_settings;
|
||||
|
||||
public virtual AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
}
|
||||
|
||||
public AudioEncoder(string path, EncoderSettings settings)
|
||||
{
|
||||
this.m_settings = settings;
|
||||
this.outputPath = path;
|
||||
|
||||
try
|
||||
{
|
||||
m_pEncoder = settings.GetWriter();
|
||||
int cInputs;
|
||||
m_pEncoder.GetInputCount(out cInputs);
|
||||
if (cInputs < 1) throw new InvalidOperationException();
|
||||
IWMInputMediaProps pInput;
|
||||
m_pEncoder.GetInputProps(0, out pInput);
|
||||
try
|
||||
{
|
||||
int cbType = 0;
|
||||
AMMediaType pMediaType = null;
|
||||
pInput.GetMediaType(pMediaType, ref cbType);
|
||||
pMediaType = new AMMediaType();
|
||||
pMediaType.formatSize = cbType - Marshal.SizeOf(typeof(AMMediaType));
|
||||
pInput.GetMediaType(pMediaType, ref cbType);
|
||||
try
|
||||
{
|
||||
var wfe = new WaveFormatExtensible(m_settings.PCM);
|
||||
Marshal.FreeCoTaskMem(pMediaType.formatPtr);
|
||||
pMediaType.formatPtr = IntPtr.Zero;
|
||||
pMediaType.formatSize = 0;
|
||||
pMediaType.formatPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(wfe));
|
||||
pMediaType.formatSize = Marshal.SizeOf(wfe);
|
||||
Marshal.StructureToPtr(wfe, pMediaType.formatPtr, false);
|
||||
pInput.SetMediaType(pMediaType);
|
||||
m_pEncoder.SetInputProps(0, pInput);
|
||||
}
|
||||
finally
|
||||
{
|
||||
WMUtils.FreeWMMediaType(pMediaType);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.ReleaseComObject(pInput);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (m_pEncoder != null)
|
||||
{
|
||||
Marshal.ReleaseComObject(m_pEncoder);
|
||||
m_pEncoder = null;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (!this.closed)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.writingBegan)
|
||||
{
|
||||
m_pEncoder.EndWriting();
|
||||
this.writingBegan = false;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (m_pEncoder != null)
|
||||
{
|
||||
Marshal.ReleaseComObject(m_pEncoder);
|
||||
m_pEncoder = null;
|
||||
}
|
||||
}
|
||||
|
||||
this.closed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
if (this.outputPath == null)
|
||||
throw new InvalidOperationException("This writer was not created from file.");
|
||||
|
||||
if (!this.closed)
|
||||
{
|
||||
this.Close();
|
||||
|
||||
if (this.fileCreated)
|
||||
{
|
||||
File.Delete(this.outputPath);
|
||||
this.fileCreated = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(AudioBuffer buffer)
|
||||
{
|
||||
if (this.closed)
|
||||
throw new InvalidOperationException("Writer already closed.");
|
||||
|
||||
if (!this.fileCreated)
|
||||
{
|
||||
this.m_pEncoder.SetOutputFilename(outputPath);
|
||||
this.fileCreated = true;
|
||||
}
|
||||
if (!this.writingBegan)
|
||||
{
|
||||
this.m_pEncoder.BeginWriting();
|
||||
this.writingBegan = true;
|
||||
}
|
||||
|
||||
buffer.Prepare(this);
|
||||
INSSBuffer pSample;
|
||||
m_pEncoder.AllocateSample(buffer.ByteLength, out pSample);
|
||||
IntPtr pdwBuffer;
|
||||
pSample.GetBuffer(out pdwBuffer);
|
||||
pSample.SetLength(buffer.ByteLength);
|
||||
Marshal.Copy(buffer.Bytes, 0, pdwBuffer, buffer.ByteLength);
|
||||
long cnsSampleTime = sampleCount * 10000000L / Settings.PCM.SampleRate;
|
||||
m_pEncoder.WriteSample(0, cnsSampleTime, SampleFlag.CleanPoint, pSample);
|
||||
Marshal.ReleaseComObject(pSample);
|
||||
sampleCount += buffer.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,20 +5,36 @@ using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using CUETools.Codecs;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace CUETools.Codecs.libFLAC
|
||||
{
|
||||
public class Settings : AudioDecoderSettings
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class DecoderSettings : IAudioDecoderSettings
|
||||
{
|
||||
public override string Extension => "flac";
|
||||
#region IAudioDecoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "flac";
|
||||
|
||||
public override string Name => "libFLAC";
|
||||
[Browsable(false)]
|
||||
public string Name => "libFLAC";
|
||||
|
||||
public override Type DecoderType => typeof(Reader);
|
||||
[Browsable(false)]
|
||||
public Type DecoderType => typeof(Reader);
|
||||
|
||||
public override int Priority => 1;
|
||||
[Browsable(false)]
|
||||
public int Priority => 1;
|
||||
|
||||
public Settings() : base() { }
|
||||
public IAudioDecoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioDecoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public DecoderSettings()
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe class Reader : IAudioSource
|
||||
@@ -282,7 +298,7 @@ namespace CUETools.Codecs.libFLAC
|
||||
return m_stream.Position == m_stream.Length ? 1 : 0;
|
||||
}
|
||||
|
||||
public AudioDecoderSettings Settings => null;
|
||||
public IAudioDecoderSettings Settings => null;
|
||||
|
||||
public AudioPCMConfig PCM => m_pcm;
|
||||
|
||||
|
||||
@@ -10,21 +10,54 @@ using Newtonsoft.Json;
|
||||
namespace CUETools.Codecs.libFLAC
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class EncoderSettings : AudioEncoderSettings
|
||||
public class EncoderSettings : IAudioEncoderSettings
|
||||
{
|
||||
public override string Extension => "flac";
|
||||
#region IAudioEncoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "flac";
|
||||
|
||||
public override string Name => "libFLAC";
|
||||
[Browsable(false)]
|
||||
public string Name => "libFLAC";
|
||||
|
||||
public override Type EncoderType => typeof(Encoder);
|
||||
[Browsable(false)]
|
||||
public Type EncoderType => typeof(Encoder);
|
||||
|
||||
public override int Priority => 2;
|
||||
[Browsable(false)]
|
||||
public bool Lossless => true;
|
||||
|
||||
public override bool Lossless => true;
|
||||
[Browsable(false)]
|
||||
public int Priority => 2;
|
||||
|
||||
[Browsable(false)]
|
||||
public string SupportedModes => "0 1 2 3 4 5 6 7 8";
|
||||
|
||||
[Browsable(false)]
|
||||
public string DefaultMode => "5";
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string EncoderMode { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public AudioPCMConfig PCM { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int BlockSize { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue(4096)]
|
||||
public int Padding { get; set; }
|
||||
|
||||
public IAudioEncoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioEncoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public EncoderSettings()
|
||||
: base("0 1 2 3 4 5 6 7 8", "5")
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
|
||||
[DefaultValue(false)]
|
||||
@@ -74,7 +107,7 @@ namespace CUETools.Codecs.libFLAC
|
||||
{
|
||||
}
|
||||
|
||||
public AudioEncoderSettings Settings => m_settings;
|
||||
public IAudioEncoderSettings Settings => m_settings;
|
||||
|
||||
public string Path { get => m_path; }
|
||||
|
||||
@@ -239,7 +272,7 @@ namespace CUETools.Codecs.libFLAC
|
||||
FLACDLL.FLAC__stream_encoder_set_metadata(m_encoder, metadata, metadataCount);
|
||||
FLACDLL.FLAC__stream_encoder_set_verify(m_encoder, m_settings.Verify ? 1 : 0);
|
||||
FLACDLL.FLAC__stream_encoder_set_do_md5(m_encoder, m_settings.MD5Sum ? 1 : 0);
|
||||
FLACDLL.FLAC__stream_encoder_set_compression_level(m_encoder, m_settings.EncoderModeIndex);
|
||||
FLACDLL.FLAC__stream_encoder_set_compression_level(m_encoder, m_settings.GetEncoderModeIndex());
|
||||
if (m_finalSampleCount != 0)
|
||||
FLACDLL.FLAC__stream_encoder_set_total_samples_estimate(m_encoder, m_finalSampleCount);
|
||||
if (m_settings.BlockSize > 0)
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace CUETools.Codecs.libmp3lame
|
||||
|
||||
private LameEncoderSettings m_settings;
|
||||
|
||||
public virtual AudioEncoderSettings Settings
|
||||
public IAudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
@@ -9,12 +9,14 @@ namespace CUETools.Codecs.libmp3lame
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class CBREncoderSettings : LameEncoderSettings
|
||||
{
|
||||
public override string Extension => "mp3";
|
||||
|
||||
public override string Name => "libmp3lame-CBR";
|
||||
|
||||
public override int Priority => 1;
|
||||
|
||||
public override string SupportedModes => "96 128 192 256 320";
|
||||
|
||||
public override string DefaultMode => "256";
|
||||
|
||||
public static readonly int[] bps_table = new int[] { 96, 128, 192, 256, 320 };
|
||||
|
||||
[JsonProperty]
|
||||
@@ -22,14 +24,14 @@ namespace CUETools.Codecs.libmp3lame
|
||||
public LameQuality Quality { get; set; }
|
||||
|
||||
public CBREncoderSettings()
|
||||
: base("96 128 192 256 320", "256")
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Apply(IntPtr lame)
|
||||
{
|
||||
libmp3lamedll.lame_set_VBR(lame, (int)LameVbrMode.Off);
|
||||
libmp3lamedll.lame_set_brate(lame, CBREncoderSettings.bps_table[this.EncoderModeIndex]);
|
||||
libmp3lamedll.lame_set_brate(lame, CBREncoderSettings.bps_table[this.GetEncoderModeIndex()]);
|
||||
libmp3lamedll.lame_set_quality(lame, (int)this.Quality);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,61 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace CUETools.Codecs.libmp3lame
|
||||
{
|
||||
public class LameEncoderSettings : AudioEncoderSettings
|
||||
public abstract class LameEncoderSettings : IAudioEncoderSettings
|
||||
{
|
||||
public override Type EncoderType => typeof(AudioEncoder);
|
||||
#region IAudioEncoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "mp3";
|
||||
|
||||
public LameEncoderSettings(string modes, string defaultMode)
|
||||
: base(modes, defaultMode)
|
||||
[Browsable(false)]
|
||||
public abstract string Name { get; }
|
||||
|
||||
[Browsable(false)]
|
||||
public Type EncoderType => typeof(AudioEncoder);
|
||||
|
||||
[Browsable(false)]
|
||||
public bool Lossless => false;
|
||||
|
||||
[Browsable(false)]
|
||||
public abstract int Priority { get; }
|
||||
|
||||
[Browsable(false)]
|
||||
public abstract string SupportedModes { get; }
|
||||
|
||||
[Browsable(false)]
|
||||
public abstract string DefaultMode { get; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string EncoderMode { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public AudioPCMConfig PCM { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int BlockSize { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue(4096)]
|
||||
public int Padding { get; set; }
|
||||
|
||||
public IAudioEncoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioEncoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public LameEncoderSettings()
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
|
||||
public virtual void Apply(IntPtr lame)
|
||||
{
|
||||
throw new MethodAccessException();
|
||||
}
|
||||
public abstract void Apply(IntPtr lame);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,25 +9,27 @@ namespace CUETools.Codecs.libmp3lame
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class VBREncoderSettings : LameEncoderSettings
|
||||
{
|
||||
public override string Extension => "mp3";
|
||||
|
||||
public override string Name => "libmp3lame-VBR";
|
||||
|
||||
public override int Priority => 2;
|
||||
|
||||
public override string SupportedModes => "V9 V8 V7 V6 V5 V4 V3 V2 V1 V0";
|
||||
|
||||
public override string DefaultMode => "V2";
|
||||
|
||||
[JsonProperty]
|
||||
[DefaultValue(LameQuality.High)]
|
||||
public LameQuality Quality { get; set; }
|
||||
|
||||
public VBREncoderSettings()
|
||||
: base("V9 V8 V7 V6 V5 V4 V3 V2 V1 V0", "V2")
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Apply(IntPtr lame)
|
||||
{
|
||||
libmp3lamedll.lame_set_VBR(lame, (int)LameVbrMode.Default);
|
||||
libmp3lamedll.lame_set_VBR_quality(lame, 9 - this.EncoderModeIndex);
|
||||
libmp3lamedll.lame_set_VBR_quality(lame, 9 - this.GetEncoderModeIndex());
|
||||
libmp3lamedll.lame_set_quality(lame, (int)this.Quality);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,20 +5,36 @@ using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using CUETools.Codecs;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace CUETools.Codecs.libwavpack
|
||||
{
|
||||
public class DecoderSettings : AudioDecoderSettings
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class DecoderSettings : IAudioDecoderSettings
|
||||
{
|
||||
public override string Extension => "wv";
|
||||
#region IAudioDecoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "wv";
|
||||
|
||||
public override string Name => "libwavpack";
|
||||
[Browsable(false)]
|
||||
public string Name => "libwavpack";
|
||||
|
||||
public override Type DecoderType => typeof(AudioDecoder);
|
||||
[Browsable(false)]
|
||||
public Type DecoderType => typeof(AudioDecoder);
|
||||
|
||||
public override int Priority => 1;
|
||||
[Browsable(false)]
|
||||
public int Priority => 1;
|
||||
|
||||
public DecoderSettings() : base() { }
|
||||
public IAudioDecoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioDecoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public DecoderSettings()
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe class AudioDecoder : IAudioSource
|
||||
@@ -77,7 +93,7 @@ namespace CUETools.Codecs.libwavpack
|
||||
|
||||
private DecoderSettings m_settings;
|
||||
|
||||
public AudioDecoderSettings Settings => m_settings;
|
||||
public IAudioDecoderSettings Settings => m_settings;
|
||||
|
||||
public AudioPCMConfig PCM => pcm;
|
||||
|
||||
|
||||
@@ -11,21 +11,54 @@ using Newtonsoft.Json;
|
||||
namespace CUETools.Codecs.libwavpack
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class EncoderSettings : AudioEncoderSettings
|
||||
public class EncoderSettings : IAudioEncoderSettings
|
||||
{
|
||||
public override string Extension => "wv";
|
||||
#region IAudioEncoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "wv";
|
||||
|
||||
public override string Name => "libwavpack";
|
||||
[Browsable(false)]
|
||||
public string Name => "libwavpack";
|
||||
|
||||
public override Type EncoderType => typeof(AudioEncoder);
|
||||
[Browsable(false)]
|
||||
public Type EncoderType => typeof(AudioEncoder);
|
||||
|
||||
public override int Priority => 1;
|
||||
[Browsable(false)]
|
||||
public bool Lossless => true;
|
||||
|
||||
public override bool Lossless => true;
|
||||
[Browsable(false)]
|
||||
public int Priority => 1;
|
||||
|
||||
[Browsable(false)]
|
||||
public string SupportedModes => "fast normal high high+";
|
||||
|
||||
[Browsable(false)]
|
||||
public string DefaultMode => "normal";
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string EncoderMode { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public AudioPCMConfig PCM { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int BlockSize { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue(4096)]
|
||||
public int Padding { get; set; }
|
||||
|
||||
public IAudioEncoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioEncoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public EncoderSettings()
|
||||
: base("fast normal high high+", "normal")
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
|
||||
[DefaultValue(0)]
|
||||
@@ -70,7 +103,7 @@ namespace CUETools.Codecs.libwavpack
|
||||
throw new Exception("bits per sample must be 16..24");
|
||||
}
|
||||
|
||||
public AudioEncoderSettings Settings => m_settings;
|
||||
public IAudioEncoderSettings Settings => m_settings;
|
||||
|
||||
public string Path { get => m_path; }
|
||||
|
||||
@@ -186,7 +219,7 @@ namespace CUETools.Codecs.libwavpack
|
||||
config.channel_mask = (int)m_settings.PCM.ChannelMask;
|
||||
config.sample_rate = m_settings.PCM.SampleRate;
|
||||
config.flags = ConfigFlags.CONFIG_COMPATIBLE_WRITE;
|
||||
Int32 _compressionMode = m_settings.EncoderModeIndex;
|
||||
Int32 _compressionMode = m_settings.GetEncoderModeIndex();
|
||||
if (_compressionMode == 0) config.flags |= ConfigFlags.CONFIG_FAST_FLAG;
|
||||
if (_compressionMode == 2) config.flags |= ConfigFlags.CONFIG_HIGH_FLAG;
|
||||
if (_compressionMode == 3) config.flags |= ConfigFlags.CONFIG_HIGH_FLAG | ConfigFlags.CONFIG_VERY_HIGH_FLAG;
|
||||
|
||||
@@ -15,45 +15,17 @@ namespace CUETools.Codecs
|
||||
|
||||
Type DecoderType { get; }
|
||||
|
||||
bool Lossless { get; }
|
||||
|
||||
int Priority { get; }
|
||||
|
||||
IAudioDecoderSettings Clone();
|
||||
}
|
||||
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class AudioDecoderSettings: IAudioDecoderSettings
|
||||
public static class IAudioDecoderSettingsExtensions
|
||||
{
|
||||
[Browsable(false)]
|
||||
public virtual string Name => null;
|
||||
|
||||
[Browsable(false)]
|
||||
public virtual string Extension => null;
|
||||
|
||||
[Browsable(false)]
|
||||
public virtual Type DecoderType => null;
|
||||
|
||||
[Browsable(false)]
|
||||
public virtual bool Lossless => true;
|
||||
|
||||
[Browsable(false)]
|
||||
public virtual int Priority => 0;
|
||||
|
||||
public AudioDecoderSettings()
|
||||
{
|
||||
// Iterate through each property and call ResetValue()
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this))
|
||||
property.ResetValue(this);
|
||||
}
|
||||
|
||||
public AudioDecoderSettings Clone()
|
||||
{
|
||||
return this.MemberwiseClone() as AudioDecoderSettings;
|
||||
}
|
||||
|
||||
public bool HasBrowsableAttributes()
|
||||
public static bool HasBrowsableAttributes(this IAudioDecoderSettings settings)
|
||||
{
|
||||
bool hasBrowsable = false;
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this))
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(settings))
|
||||
{
|
||||
bool isBrowsable = true;
|
||||
foreach (var attribute in property.Attributes)
|
||||
@@ -65,5 +37,12 @@ namespace CUETools.Codecs
|
||||
}
|
||||
return hasBrowsable;
|
||||
}
|
||||
|
||||
public static void Init(this IAudioDecoderSettings settings)
|
||||
{
|
||||
// Iterate through each property and call ResetValue()
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(settings))
|
||||
property.ResetValue(settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,15 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
#if NET20
|
||||
namespace System.Runtime.CompilerServices
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class
|
||||
| AttributeTargets.Method)]
|
||||
public sealed class ExtensionAttribute : Attribute { }
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace CUETools.Codecs
|
||||
{
|
||||
public interface IAudioEncoderSettings
|
||||
@@ -17,67 +26,28 @@ namespace CUETools.Codecs
|
||||
bool Lossless { get; }
|
||||
|
||||
int Priority { get; }
|
||||
|
||||
string SupportedModes { get; }
|
||||
|
||||
string DefaultMode { get; }
|
||||
|
||||
string EncoderMode { get; set; }
|
||||
|
||||
AudioPCMConfig PCM { get; set; }
|
||||
|
||||
int BlockSize { get; set; }
|
||||
|
||||
int Padding { get; set; }
|
||||
|
||||
IAudioEncoderSettings Clone();
|
||||
}
|
||||
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class AudioEncoderSettings : IAudioEncoderSettings
|
||||
public static class IAudioEncoderSettingsExtensions
|
||||
{
|
||||
[Browsable(false)]
|
||||
public virtual string Name => null;
|
||||
|
||||
[Browsable(false)]
|
||||
public virtual string Extension => null;
|
||||
|
||||
[Browsable(false)]
|
||||
public virtual Type EncoderType => null;
|
||||
|
||||
[Browsable(false)]
|
||||
public virtual bool Lossless => false;
|
||||
|
||||
[Browsable(false)]
|
||||
public virtual int Priority => 0;
|
||||
|
||||
public AudioEncoderSettings()
|
||||
: this("", "")
|
||||
{
|
||||
}
|
||||
|
||||
public AudioEncoderSettings(AudioPCMConfig pcm)
|
||||
: this("", "")
|
||||
{
|
||||
this.PCM = pcm;
|
||||
}
|
||||
|
||||
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.m_supported_modes = supported_modes;
|
||||
this.m_default_mode = default_mode;
|
||||
if (default_mode == "")
|
||||
GetSupportedModes(out default_mode);
|
||||
this.EncoderMode = default_mode;
|
||||
}
|
||||
|
||||
protected string m_supported_modes;
|
||||
protected string m_default_mode;
|
||||
|
||||
public virtual string GetSupportedModes(out string defaultMode)
|
||||
{
|
||||
defaultMode = m_default_mode;
|
||||
return this.m_supported_modes;
|
||||
}
|
||||
|
||||
public AudioEncoderSettings Clone()
|
||||
{
|
||||
return this.MemberwiseClone() as AudioEncoderSettings;
|
||||
}
|
||||
|
||||
public bool HasBrowsableAttributes()
|
||||
public static bool HasBrowsableAttributes(this IAudioEncoderSettings settings)
|
||||
{
|
||||
bool hasBrowsable = false;
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this))
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(settings))
|
||||
{
|
||||
bool isBrowsable = true;
|
||||
foreach (var attribute in property.Attributes)
|
||||
@@ -90,101 +60,65 @@ namespace CUETools.Codecs
|
||||
return hasBrowsable;
|
||||
}
|
||||
|
||||
protected void SetDefaultValuesForMode()
|
||||
public static int GetEncoderModeIndex(this IAudioEncoderSettings settings)
|
||||
{
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this))
|
||||
if (!property.CanResetValue(this))
|
||||
return new List<string>(settings.SupportedModes.Split(' ')).FindIndex(m => m == settings.EncoderMode);
|
||||
}
|
||||
|
||||
public static void SetEncoderModeIndex(this IAudioEncoderSettings settings, int value)
|
||||
{
|
||||
string[] modes = settings.SupportedModes.Split(' ');
|
||||
if (modes.Length == 0 && value < 0)
|
||||
return;
|
||||
if (value < 0 || value >= modes.Length)
|
||||
throw new IndexOutOfRangeException();
|
||||
settings.EncoderMode = modes[value];
|
||||
}
|
||||
|
||||
public static void SetDefaultValuesForMode(this IAudioEncoderSettings settings)
|
||||
{
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(settings))
|
||||
if (!property.CanResetValue(settings))
|
||||
foreach (var attribute in property.Attributes)
|
||||
if (attribute is DefaultValueForModeAttribute)
|
||||
{
|
||||
var defaultValueForMode = attribute as DefaultValueForModeAttribute;
|
||||
property.SetValue(this, defaultValueForMode.m_values[EncoderModeIndex]);
|
||||
property.SetValue(settings, defaultValueForMode.m_values[settings.GetEncoderModeIndex()]);
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasDefaultValuesForMode(int index)
|
||||
public static bool HasDefaultValuesForMode(this IAudioEncoderSettings settings, int index)
|
||||
{
|
||||
bool res = true;
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this))
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(settings))
|
||||
foreach (var attribute in property.Attributes)
|
||||
if (attribute is DefaultValueForModeAttribute)
|
||||
{
|
||||
var defaultValueForMode = attribute as DefaultValueForModeAttribute;
|
||||
res &= property.GetValue(this).Equals(defaultValueForMode.m_values[index]);
|
||||
res &= property.GetValue(settings).Equals(defaultValueForMode.m_values[index]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public int GuessEncoderMode()
|
||||
public static int GuessEncoderMode(this IAudioEncoderSettings settings)
|
||||
{
|
||||
string defaultMode;
|
||||
string[] modes = this.GetSupportedModes(out defaultMode).Split(' ');
|
||||
// return new List<string>(settings.SupportedModes.Split(' ')).FindIndex(m => settings.HasDefaultValuesForMode(m));
|
||||
string[] modes = settings.SupportedModes.Split(' ');
|
||||
if (modes == null || modes.Length < 1)
|
||||
return -1;
|
||||
for (int i = 0; i < modes.Length; i++)
|
||||
if (HasDefaultValuesForMode(i))
|
||||
if (settings.HasDefaultValuesForMode(i))
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public AudioPCMConfig PCM
|
||||
public static void Init(this IAudioEncoderSettings settings, AudioPCMConfig pcm = null)
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue(0)]
|
||||
public int BlockSize
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue(4096)]
|
||||
public int Padding
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string EncoderMode
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public int EncoderModeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
string defaultMode;
|
||||
string[] modes = this.GetSupportedModes(out defaultMode).Split(' ');
|
||||
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 defaultMode;
|
||||
string[] modes = this.GetSupportedModes(out defaultMode).Split(' ');
|
||||
if (modes.Length == 0 && value < 0)
|
||||
return;
|
||||
if (value < 0 || value >= modes.Length)
|
||||
throw new IndexOutOfRangeException();
|
||||
this.EncoderMode = modes[value];
|
||||
}
|
||||
// Iterate through each property and call ResetValue()
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(settings))
|
||||
property.ResetValue(settings);
|
||||
settings.EncoderMode = settings.DefaultMode;
|
||||
settings.PCM = pcm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace CUETools.Codecs
|
||||
private bool own;
|
||||
private ThreadPriority priority;
|
||||
|
||||
public AudioDecoderSettings Settings { get { return null; } }
|
||||
public IAudioDecoderSettings Settings => null;
|
||||
|
||||
public long Position
|
||||
{
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace CUETools.Codecs
|
||||
{
|
||||
[JsonIgnore]
|
||||
public Dictionary<string, CUEToolsFormat> formats;
|
||||
public List<AudioEncoderSettings> encoders;
|
||||
public List<AudioDecoderSettings> decoders;
|
||||
public List<IAudioEncoderSettings> encoders;
|
||||
public List<IAudioDecoderSettings> decoders;
|
||||
[JsonIgnore]
|
||||
public EncoderListViewModel encodersViewModel;
|
||||
[JsonIgnore]
|
||||
@@ -23,8 +23,8 @@ namespace CUETools.Codecs
|
||||
|
||||
public CUEToolsCodecsConfig()
|
||||
{
|
||||
encoders = new List<AudioEncoderSettings>();
|
||||
decoders = new List<AudioDecoderSettings>();
|
||||
encoders = new List<IAudioEncoderSettings>();
|
||||
decoders = new List<IAudioDecoderSettings>();
|
||||
encodersViewModel = new EncoderListViewModel(encoders);
|
||||
decodersViewModel = new DecoderListViewModel(decoders);
|
||||
formats = new Dictionary<string, CUEToolsFormat>();
|
||||
@@ -32,8 +32,8 @@ namespace CUETools.Codecs
|
||||
|
||||
public CUEToolsCodecsConfig(CUEToolsCodecsConfig src)
|
||||
{
|
||||
encoders = new List<AudioEncoderSettings>();
|
||||
decoders = new List<AudioDecoderSettings>();
|
||||
encoders = new List<IAudioEncoderSettings>();
|
||||
decoders = new List<IAudioDecoderSettings>();
|
||||
src.encoders.ForEach(item => encoders.Add(item.Clone()));
|
||||
src.decoders.ForEach(item => decoders.Add(item.Clone()));
|
||||
encodersViewModel = new EncoderListViewModel(encoders);
|
||||
@@ -43,10 +43,10 @@ namespace CUETools.Codecs
|
||||
formats.Add(fmt.Key, fmt.Value.Clone(this));
|
||||
}
|
||||
|
||||
public void Init(List<AudioEncoderSettings> src_encoders, List<AudioDecoderSettings> src_decoders)
|
||||
public void Init(List<IAudioEncoderSettings> src_encoders, List<IAudioDecoderSettings> src_decoders)
|
||||
{
|
||||
encoders = new List<AudioEncoderSettings>();
|
||||
decoders = new List<AudioDecoderSettings>();
|
||||
encoders = new List<IAudioEncoderSettings>();
|
||||
decoders = new List<IAudioDecoderSettings>();
|
||||
src_encoders.ForEach(item => encoders.Add(item.Clone()));
|
||||
src_decoders.ForEach(item => decoders.Add(item.Clone()));
|
||||
|
||||
@@ -74,16 +74,16 @@ namespace CUETools.Codecs
|
||||
decodersViewModel = new DecoderListViewModel(decoders);
|
||||
|
||||
formats = new Dictionary<string, CUEToolsFormat>();
|
||||
formats.Add("flac", new CUEToolsFormat("flac", CUEToolsTagger.TagLibSharp, true, false, true, true, encodersViewModel.GetDefault("flac", true), null, decodersViewModel.GetDefault("flac", true)));
|
||||
formats.Add("wv", new CUEToolsFormat("wv", CUEToolsTagger.TagLibSharp, true, false, true, true, encodersViewModel.GetDefault("wv", true), null, decodersViewModel.GetDefault("wv", true)));
|
||||
formats.Add("ape", new CUEToolsFormat("ape", CUEToolsTagger.TagLibSharp, true, false, true, true, encodersViewModel.GetDefault("ape", true), null, decodersViewModel.GetDefault("ape", true)));
|
||||
formats.Add("tta", new CUEToolsFormat("tta", CUEToolsTagger.APEv2, true, false, false, true, encodersViewModel.GetDefault("tta", true), null, decodersViewModel.GetDefault("tta", true)));
|
||||
formats.Add("m2ts", new CUEToolsFormat("m2ts", CUEToolsTagger.APEv2, true, false, false, true, null, null, decodersViewModel.GetDefault("m2ts", true)));
|
||||
formats.Add("mpls", new CUEToolsFormat("mpls", CUEToolsTagger.APEv2, true, false, false, true, null, null, decodersViewModel.GetDefault("mpls", true)));
|
||||
formats.Add("wav", new CUEToolsFormat("wav", CUEToolsTagger.TagLibSharp, true, false, false, true, encodersViewModel.GetDefault("wav", true), null, decodersViewModel.GetDefault("wav", true)));
|
||||
formats.Add("m4a", new CUEToolsFormat("m4a", CUEToolsTagger.TagLibSharp, true, true, false, true, encodersViewModel.GetDefault("m4a", true), encodersViewModel.GetDefault("m4a", false), decodersViewModel.GetDefault("m4a", true)));
|
||||
formats.Add("tak", new CUEToolsFormat("tak", CUEToolsTagger.APEv2, true, false, true, true, encodersViewModel.GetDefault("tak", true), null, decodersViewModel.GetDefault("tak", true)));
|
||||
formats.Add("wma", new CUEToolsFormat("wma", CUEToolsTagger.TagLibSharp, true, true, false, true, encodersViewModel.GetDefault("wma", true), encodersViewModel.GetDefault("wma", false), decodersViewModel.GetDefault("wma", true)));
|
||||
formats.Add("flac", new CUEToolsFormat("flac", CUEToolsTagger.TagLibSharp, true, false, true, true, encodersViewModel.GetDefault("flac", true), null, decodersViewModel.GetDefault("flac")));
|
||||
formats.Add("wv", new CUEToolsFormat("wv", CUEToolsTagger.TagLibSharp, true, false, true, true, encodersViewModel.GetDefault("wv", true), null, decodersViewModel.GetDefault("wv")));
|
||||
formats.Add("ape", new CUEToolsFormat("ape", CUEToolsTagger.TagLibSharp, true, false, true, true, encodersViewModel.GetDefault("ape", true), null, decodersViewModel.GetDefault("ape")));
|
||||
formats.Add("tta", new CUEToolsFormat("tta", CUEToolsTagger.APEv2, true, false, false, true, encodersViewModel.GetDefault("tta", true), null, decodersViewModel.GetDefault("tta")));
|
||||
formats.Add("m2ts", new CUEToolsFormat("m2ts", CUEToolsTagger.APEv2, true, false, false, true, null, null, decodersViewModel.GetDefault("m2ts")));
|
||||
formats.Add("mpls", new CUEToolsFormat("mpls", CUEToolsTagger.APEv2, true, false, false, true, null, null, decodersViewModel.GetDefault("mpls")));
|
||||
formats.Add("wav", new CUEToolsFormat("wav", CUEToolsTagger.TagLibSharp, true, false, false, true, encodersViewModel.GetDefault("wav", true), null, decodersViewModel.GetDefault("wav")));
|
||||
formats.Add("m4a", new CUEToolsFormat("m4a", CUEToolsTagger.TagLibSharp, true, true, false, true, encodersViewModel.GetDefault("m4a", true), encodersViewModel.GetDefault("m4a", false), decodersViewModel.GetDefault("m4a")));
|
||||
formats.Add("tak", new CUEToolsFormat("tak", CUEToolsTagger.APEv2, true, false, true, true, encodersViewModel.GetDefault("tak", true), null, decodersViewModel.GetDefault("tak")));
|
||||
formats.Add("wma", new CUEToolsFormat("wma", CUEToolsTagger.TagLibSharp, true, true, false, true, encodersViewModel.GetDefault("wma", true), encodersViewModel.GetDefault("wma", false), decodersViewModel.GetDefault("wma")));
|
||||
formats.Add("mp3", new CUEToolsFormat("mp3", CUEToolsTagger.TagLibSharp, false, true, false, true, null, encodersViewModel.GetDefault("mp3", false), null));
|
||||
formats.Add("ogg", new CUEToolsFormat("ogg", CUEToolsTagger.TagLibSharp, false, true, false, true, null, encodersViewModel.GetDefault("ogg", false), null));
|
||||
formats.Add("opus", new CUEToolsFormat("opus", CUEToolsTagger.TagLibSharp, false, true, false, true, null, encodersViewModel.GetDefault("opus", false), null));
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
public CUEToolsFormat Clone(CUEToolsCodecsConfig cfg)
|
||||
{
|
||||
var res = this.MemberwiseClone() as CUEToolsFormat;
|
||||
if (decoder != null) cfg.decodersViewModel.TryGetValue(decoder.Settings.Extension, decoder.Lossless, decoder.Settings.Name, out res.decoder);
|
||||
if (decoder != null) cfg.decodersViewModel.TryGetValue(decoder.Settings.Extension, decoder.Settings.Name, out res.decoder);
|
||||
if (encoderLossy != null) cfg.encodersViewModel.TryGetValue(encoderLossy.Settings.Extension, encoderLossy.Lossless, encoderLossy.Settings.Name, out res.encoderLossy);
|
||||
if (encoderLossless != null) cfg.encodersViewModel.TryGetValue(encoderLossless.Settings.Extension, encoderLossless.Lossless, encoderLossless.Settings.Name, out res.encoderLossless);
|
||||
return res;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace CUETools.Codecs.CommandLine
|
||||
WAV.AudioDecoder rdr;
|
||||
|
||||
private DecoderSettings m_settings;
|
||||
public AudioDecoderSettings Settings => m_settings;
|
||||
public IAudioDecoderSettings Settings => m_settings;
|
||||
|
||||
public long Position
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace CUETools.Codecs.CommandLine
|
||||
|
||||
// !!!! Must not start the process in constructor, so that we can set CompressionLevel via Settings!
|
||||
private EncoderSettings m_settings;
|
||||
public AudioEncoderSettings Settings => m_settings;
|
||||
public IAudioEncoderSettings Settings => m_settings;
|
||||
|
||||
public string Path { get { return _path; } }
|
||||
|
||||
|
||||
@@ -7,37 +7,48 @@ using Newtonsoft.Json;
|
||||
namespace CUETools.Codecs.CommandLine
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class DecoderSettings : AudioDecoderSettings
|
||||
public class DecoderSettings : IAudioDecoderSettings
|
||||
{
|
||||
public override string Name => name;
|
||||
#region IAudioDecoderSettings implementation
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string Name { get; set; }
|
||||
|
||||
public override string Extension => extension;
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string Extension { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public Type DecoderType => typeof(AudioDecoder);
|
||||
|
||||
[Browsable(false)]
|
||||
public int Priority => 2;
|
||||
|
||||
public IAudioDecoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioDecoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public DecoderSettings()
|
||||
: base()
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
|
||||
public DecoderSettings(
|
||||
string _name,
|
||||
string _extension,
|
||||
string _path,
|
||||
string _parameters)
|
||||
string name,
|
||||
string extension,
|
||||
string path,
|
||||
string parameters)
|
||||
: base()
|
||||
{
|
||||
name = _name;
|
||||
extension = _extension;
|
||||
Path = _path;
|
||||
Parameters = _parameters;
|
||||
Name = name;
|
||||
Extension = extension;
|
||||
Path = path;
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
[JsonProperty]
|
||||
public string name;
|
||||
|
||||
[JsonProperty]
|
||||
public string extension;
|
||||
|
||||
[DefaultValue(null)]
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string Path
|
||||
{
|
||||
@@ -45,7 +56,7 @@ namespace CUETools.Codecs.CommandLine
|
||||
set;
|
||||
}
|
||||
|
||||
[DefaultValue(null)]
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string Parameters
|
||||
{
|
||||
|
||||
@@ -7,50 +7,79 @@ using Newtonsoft.Json;
|
||||
namespace CUETools.Codecs.CommandLine
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class EncoderSettings : AudioEncoderSettings
|
||||
public class EncoderSettings : IAudioEncoderSettings
|
||||
{
|
||||
public override string Name => name;
|
||||
#region IAudioEncoderSettings implementation
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string Name { get; set; }
|
||||
|
||||
public override string Extension => extension;
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string Extension { get; set; }
|
||||
|
||||
public override Type EncoderType => typeof(AudioEncoder);
|
||||
[Browsable(false)]
|
||||
public Type EncoderType => typeof(AudioEncoder);
|
||||
|
||||
public override bool Lossless => lossless;
|
||||
[JsonProperty]
|
||||
public bool Lossless { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int Priority => 0;
|
||||
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string SupportedModes { get; set; }
|
||||
|
||||
public string DefaultMode => EncoderMode;
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string EncoderMode { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public AudioPCMConfig PCM { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int BlockSize { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue(4096)]
|
||||
public int Padding { get; set; }
|
||||
|
||||
public IAudioEncoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioEncoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public EncoderSettings()
|
||||
: base()
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
|
||||
public EncoderSettings(
|
||||
string _name,
|
||||
string _extension,
|
||||
bool _lossless,
|
||||
string _supported_modes,
|
||||
string _default_mode,
|
||||
string _path,
|
||||
string _parameters
|
||||
string name,
|
||||
string extension,
|
||||
bool lossless,
|
||||
string supportedModes,
|
||||
string defaultMode,
|
||||
string path,
|
||||
string parameters
|
||||
)
|
||||
{
|
||||
name = _name;
|
||||
extension = _extension;
|
||||
lossless = _lossless;
|
||||
SupportedModes = _supported_modes;
|
||||
EncoderMode = _default_mode;
|
||||
Path = _path;
|
||||
Parameters = _parameters;
|
||||
this.Init();
|
||||
Name = name;
|
||||
Extension = extension;
|
||||
Lossless = lossless;
|
||||
SupportedModes = supportedModes;
|
||||
Path = path;
|
||||
EncoderMode = defaultMode;
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
[JsonProperty]
|
||||
public string name;
|
||||
|
||||
[JsonProperty]
|
||||
public string extension;
|
||||
|
||||
[JsonProperty]
|
||||
public bool lossless;
|
||||
|
||||
[DefaultValue(null)]
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string Path
|
||||
{
|
||||
@@ -58,25 +87,12 @@ namespace CUETools.Codecs.CommandLine
|
||||
set;
|
||||
}
|
||||
|
||||
[DefaultValue(null)]
|
||||
[DefaultValue("")]
|
||||
[JsonProperty]
|
||||
public string Parameters
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonProperty]
|
||||
public string SupportedModes
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_supported_modes;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_supported_modes = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
public interface IAudioDest
|
||||
{
|
||||
AudioEncoderSettings Settings { get; }
|
||||
IAudioEncoderSettings Settings { get; }
|
||||
|
||||
string Path { get; }
|
||||
long FinalSampleCount { set; }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
public interface IAudioSource
|
||||
{
|
||||
AudioDecoderSettings Settings { get; }
|
||||
IAudioDecoderSettings Settings { get; }
|
||||
|
||||
AudioPCMConfig PCM { get; }
|
||||
string Path { get; }
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
private AudioPCMConfig pcm;
|
||||
private int _sampleVal;
|
||||
|
||||
public AudioDecoderSettings Settings { get { return null; } }
|
||||
public IAudioDecoderSettings Settings => null;
|
||||
|
||||
public long Length
|
||||
{
|
||||
|
||||
@@ -4,9 +4,9 @@ namespace CUETools.Codecs.NULL
|
||||
{
|
||||
public class AudioEncoder : IAudioDest
|
||||
{
|
||||
AudioEncoderSettings m_settings;
|
||||
IAudioEncoderSettings m_settings;
|
||||
|
||||
public AudioEncoder(string path, AudioEncoderSettings settings)
|
||||
public AudioEncoder(string path, IAudioEncoderSettings settings)
|
||||
{
|
||||
m_settings = settings;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ namespace CUETools.Codecs.NULL
|
||||
set { }
|
||||
}
|
||||
|
||||
public AudioEncoderSettings Settings => m_settings;
|
||||
public IAudioEncoderSettings Settings => m_settings;
|
||||
|
||||
public void Write(AudioBuffer buff)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace CUETools.Codecs
|
||||
public class AudioDecoderSettingsViewModel : INotifyPropertyChanged
|
||||
{
|
||||
[JsonProperty]
|
||||
public AudioDecoderSettings Settings = null;
|
||||
public IAudioDecoderSettings Settings = null;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace CUETools.Codecs
|
||||
{
|
||||
}
|
||||
|
||||
public AudioDecoderSettingsViewModel(AudioDecoderSettings settings)
|
||||
public AudioDecoderSettingsViewModel(IAudioDecoderSettings settings)
|
||||
{
|
||||
this.Settings = settings;
|
||||
}
|
||||
@@ -62,21 +62,13 @@ namespace CUETools.Codecs
|
||||
}
|
||||
}
|
||||
|
||||
public bool Lossless
|
||||
{
|
||||
get => true;
|
||||
set {
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => Settings.Name;
|
||||
set
|
||||
{
|
||||
if (Settings is CommandLine.DecoderSettings)
|
||||
(Settings as CommandLine.DecoderSettings).name = value;
|
||||
(Settings as CommandLine.DecoderSettings).Name = value;
|
||||
else throw new InvalidOperationException();
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Name"));
|
||||
}
|
||||
@@ -88,7 +80,7 @@ namespace CUETools.Codecs
|
||||
set
|
||||
{
|
||||
if (Settings is CommandLine.DecoderSettings)
|
||||
(Settings as CommandLine.DecoderSettings).extension = value;
|
||||
(Settings as CommandLine.DecoderSettings).Extension = value;
|
||||
else throw new InvalidOperationException();
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Extension"));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace CUETools.Codecs
|
||||
public class AudioEncoderSettingsViewModel : INotifyPropertyChanged
|
||||
{
|
||||
[JsonProperty]
|
||||
public AudioEncoderSettings Settings = null;
|
||||
public IAudioEncoderSettings Settings = null;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace CUETools.Codecs
|
||||
{
|
||||
}
|
||||
|
||||
public AudioEncoderSettingsViewModel(AudioEncoderSettings settings)
|
||||
public AudioEncoderSettingsViewModel(IAudioEncoderSettings settings)
|
||||
{
|
||||
this.Settings = settings;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ namespace CUETools.Codecs
|
||||
{
|
||||
var settings = this.Settings as CommandLine.EncoderSettings;
|
||||
if (settings == null) throw new InvalidOperationException();
|
||||
settings.lossless = value;
|
||||
settings.Lossless = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Lossless"));
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ namespace CUETools.Codecs
|
||||
{
|
||||
var settings = this.Settings as CommandLine.EncoderSettings;
|
||||
if (settings == null) throw new InvalidOperationException();
|
||||
settings.name = value;
|
||||
settings.Name = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Name"));
|
||||
}
|
||||
}
|
||||
@@ -95,36 +95,30 @@ namespace CUETools.Codecs
|
||||
{
|
||||
var settings = this.Settings as CommandLine.EncoderSettings;
|
||||
if (settings == null) throw new InvalidOperationException();
|
||||
settings.extension = value;
|
||||
settings.Extension = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Extension"));
|
||||
}
|
||||
}
|
||||
|
||||
public string DotExtension => "." + Extension;
|
||||
|
||||
public string SupportedModesStr
|
||||
public string SupportedModes
|
||||
{
|
||||
get
|
||||
{
|
||||
string defaultMode;
|
||||
return this.Settings.GetSupportedModes(out defaultMode);
|
||||
}
|
||||
get => Settings.SupportedModes;
|
||||
set
|
||||
{
|
||||
var settings = this.Settings as CommandLine.EncoderSettings;
|
||||
if (settings == null) throw new InvalidOperationException();
|
||||
settings.SupportedModes = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SupportedModesStr"));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SupportedModes"));
|
||||
}
|
||||
}
|
||||
|
||||
public string[] SupportedModes => this.SupportedModesStr.Split(' ');
|
||||
|
||||
public int EncoderModeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
string[] modes = this.SupportedModes;
|
||||
string[] modes = this.SupportedModes.Split(' ');
|
||||
if (modes == null || modes.Length < 2)
|
||||
return -1;
|
||||
for (int i = 0; i < modes.Length; i++)
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace CUETools.Codecs
|
||||
{
|
||||
public class DecoderListViewModel : BindingList<AudioDecoderSettingsViewModel>
|
||||
{
|
||||
private List<AudioDecoderSettings> model;
|
||||
private List<IAudioDecoderSettings> model;
|
||||
|
||||
public DecoderListViewModel(List<AudioDecoderSettings> model)
|
||||
public DecoderListViewModel(List<IAudioDecoderSettings> model)
|
||||
: base()
|
||||
{
|
||||
this.model = model;
|
||||
@@ -23,11 +23,11 @@ namespace CUETools.Codecs
|
||||
e.NewObject = new AudioDecoderSettingsViewModel(item);
|
||||
}
|
||||
|
||||
public bool TryGetValue(string extension, bool lossless, string name, out AudioDecoderSettingsViewModel result)
|
||||
public bool TryGetValue(string extension, string name, out AudioDecoderSettingsViewModel result)
|
||||
{
|
||||
foreach (AudioDecoderSettingsViewModel udc in this)
|
||||
{
|
||||
if (udc.Settings.Extension == extension && udc.Settings.Lossless == lossless && udc.Settings.Name == name)
|
||||
if (udc.Settings.Extension == extension && udc.Settings.Name == name)
|
||||
{
|
||||
result = udc;
|
||||
return true;
|
||||
@@ -37,12 +37,12 @@ namespace CUETools.Codecs
|
||||
return false;
|
||||
}
|
||||
|
||||
public AudioDecoderSettingsViewModel GetDefault(string extension, bool lossless)
|
||||
public AudioDecoderSettingsViewModel GetDefault(string extension)
|
||||
{
|
||||
AudioDecoderSettingsViewModel result = null;
|
||||
foreach (AudioDecoderSettingsViewModel udc in this)
|
||||
{
|
||||
if (udc.Settings.Extension == extension && udc.Settings.Lossless == lossless && (result == null || result.Settings.Priority < udc.Settings.Priority))
|
||||
if (udc.Settings.Extension == extension && (result == null || result.Settings.Priority < udc.Settings.Priority))
|
||||
{
|
||||
result = udc;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace CUETools.Codecs
|
||||
{
|
||||
public class EncoderListViewModel : BindingList<AudioEncoderSettingsViewModel>
|
||||
{
|
||||
private List<AudioEncoderSettings> model;
|
||||
private List<IAudioEncoderSettings> model;
|
||||
|
||||
public EncoderListViewModel(List<AudioEncoderSettings> model)
|
||||
public EncoderListViewModel(List<IAudioEncoderSettings> model)
|
||||
: base()
|
||||
{
|
||||
this.model = model;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace CUETools.Codecs.WAV
|
||||
string _path;
|
||||
|
||||
private DecoderSettings m_settings;
|
||||
public AudioDecoderSettings Settings => m_settings;
|
||||
public IAudioDecoderSettings Settings => m_settings;
|
||||
|
||||
public long Position
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace CUETools.Codecs.WAV
|
||||
}
|
||||
|
||||
private EncoderSettings m_settings;
|
||||
public AudioEncoderSettings Settings => m_settings;
|
||||
public IAudioEncoderSettings Settings => m_settings;
|
||||
|
||||
public string Path { get { return _path; } }
|
||||
|
||||
|
||||
@@ -1,19 +1,36 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace CUETools.Codecs.WAV
|
||||
{
|
||||
public class DecoderSettings : AudioDecoderSettings
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class DecoderSettings : IAudioDecoderSettings
|
||||
{
|
||||
public override string Name => "cuetools";
|
||||
#region IAudioDecoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "wav";
|
||||
|
||||
public override string Extension => "wav";
|
||||
[Browsable(false)]
|
||||
public string Name => "cuetools";
|
||||
|
||||
public override Type DecoderType => typeof(AudioDecoder);
|
||||
[Browsable(false)]
|
||||
public Type DecoderType => typeof(AudioDecoder);
|
||||
|
||||
public override int Priority => 2;
|
||||
[Browsable(false)]
|
||||
public int Priority => 2;
|
||||
|
||||
public DecoderSettings() : base() { }
|
||||
public IAudioDecoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioDecoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public bool IgnoreChunkSizes;
|
||||
public DecoderSettings()
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
|
||||
public bool IgnoreChunkSizes { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,64 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace CUETools.Codecs.WAV
|
||||
{
|
||||
public class EncoderSettings : AudioEncoderSettings
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class EncoderSettings : IAudioEncoderSettings
|
||||
{
|
||||
public override string Extension => "wav";
|
||||
#region IAudioEncoderSettings implementation
|
||||
[Browsable(false)]
|
||||
public string Extension => "wav";
|
||||
|
||||
public override string Name => "cuetools";
|
||||
[Browsable(false)]
|
||||
public string Name => "cuetools";
|
||||
|
||||
public override Type EncoderType => typeof(WAV.AudioEncoder);
|
||||
[Browsable(false)]
|
||||
public Type EncoderType => typeof(WAV.AudioEncoder);
|
||||
|
||||
public override int Priority => 10;
|
||||
[Browsable(false)]
|
||||
public bool Lossless => true;
|
||||
|
||||
public override bool Lossless => true;
|
||||
[Browsable(false)]
|
||||
public int Priority => 10;
|
||||
|
||||
[Browsable(false)]
|
||||
public string SupportedModes => "";
|
||||
|
||||
[Browsable(false)]
|
||||
public string DefaultMode => "";
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue("")]
|
||||
public string EncoderMode { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public AudioPCMConfig PCM { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int BlockSize { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DefaultValue(4096)]
|
||||
public int Padding { get; set; }
|
||||
|
||||
public IAudioEncoderSettings Clone()
|
||||
{
|
||||
return MemberwiseClone() as IAudioEncoderSettings;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public EncoderSettings()
|
||||
: this(null)
|
||||
{
|
||||
this.Init();
|
||||
}
|
||||
|
||||
public EncoderSettings(AudioPCMConfig pcm)
|
||||
: base(pcm)
|
||||
{
|
||||
this.Init(pcm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace CUETools.Converter
|
||||
throw new Exception("Unsupported audio type: " + path);
|
||||
|
||||
var decoder = fmt.decoder;
|
||||
if (chosenDecoder != null && !config.decodersViewModel.TryGetValue(fmt.extension, true, chosenDecoder, out decoder))
|
||||
if (chosenDecoder != null && !config.decodersViewModel.TryGetValue(fmt.extension, chosenDecoder, out decoder))
|
||||
throw new Exception("Unknown audio decoder " + chosenDecoder + " or unsupported audio type " + fmt.extension);
|
||||
if (decoder == null)
|
||||
throw new Exception("Unsupported audio type: " + path);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace CUETools.DSP.Mixer
|
||||
private int mixoffs = 0;
|
||||
private int current = 0;
|
||||
|
||||
public AudioDecoderSettings Settings { get { return null; } }
|
||||
public IAudioDecoderSettings Settings => null;
|
||||
|
||||
public void Close()
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace CUETools.DSP.Mixer
|
||||
private long samplePos;
|
||||
private MixingBuffer mixbuff;
|
||||
private float volume;
|
||||
private AudioEncoderSettings m_settings;
|
||||
private Codecs.WAV.EncoderSettings m_settings;
|
||||
|
||||
public long Position
|
||||
{
|
||||
@@ -23,13 +23,7 @@ namespace CUETools.DSP.Mixer
|
||||
set { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public AudioEncoderSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
}
|
||||
public IAudioEncoderSettings Settings => m_settings;
|
||||
|
||||
public float Volume
|
||||
{
|
||||
@@ -41,7 +35,7 @@ namespace CUETools.DSP.Mixer
|
||||
|
||||
public MixingWriter(MixingSource mixer, int iSource)
|
||||
{
|
||||
this.m_settings = new AudioEncoderSettings(mixer.PCM);
|
||||
this.m_settings = new Codecs.WAV.EncoderSettings(mixer.PCM);
|
||||
this.mixer = mixer;
|
||||
this.iSource = iSource;
|
||||
this.samplePos = 0;
|
||||
|
||||
@@ -67,9 +67,9 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CUETools.Codecs.FLAKE\CUETools.Codecs.FLAKE.csproj">
|
||||
<ProjectReference Include="..\CUETools.Codecs.Flake\CUETools.Codecs.Flake.csproj">
|
||||
<Project>{082D6B9E-326E-4D15-9798-EDAE9EDE70A6}</Project>
|
||||
<Name>CUETools.Codecs.FLAKE</Name>
|
||||
<Name>CUETools.Codecs.Flake</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\CUETools.Codecs\CUETools.Codecs.csproj">
|
||||
|
||||
@@ -22,7 +22,7 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using CUETools.Codecs;
|
||||
using CUETools.Codecs.FLAKE;
|
||||
using CUETools.Codecs.Flake;
|
||||
using CUETools.Codecs.FLACCL;
|
||||
|
||||
namespace CUETools.FLACCL.cmd
|
||||
@@ -209,7 +209,7 @@ namespace CUETools.FLACCL.cmd
|
||||
else if (args[arg] != "-" && args[arg][0] == '-' && int.TryParse(args[arg].Substring(1), out level))
|
||||
{
|
||||
ok = level >= 0 && level <= 11;
|
||||
settings.EncoderModeIndex = level;
|
||||
settings.SetEncoderModeIndex(level);
|
||||
}
|
||||
else if ((args[arg][0] != '-' || args[arg] == "-") && input_file == null)
|
||||
input_file = args[arg];
|
||||
|
||||
@@ -62,9 +62,9 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CUETools.Codecs.FLAKE\CUETools.Codecs.FLAKE.csproj">
|
||||
<ProjectReference Include="..\CUETools.Codecs.Flake\CUETools.Codecs.Flake.csproj">
|
||||
<Project>{082D6B9E-326E-4D15-9798-EDAE9EDE70A6}</Project>
|
||||
<Name>CUETools.Codecs.FLAKE</Name>
|
||||
<Name>CUETools.Codecs.Flake</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\CUETools.Codecs\CUETools.Codecs.csproj">
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CUETools.Codecs.FLAKE\CUETools.Codecs.FLAKE.csproj" />
|
||||
<ProjectReference Include="..\CUETools.Codecs.Flake\CUETools.Codecs.Flake.csproj" />
|
||||
<ProjectReference Include="..\CUETools.Codecs\CUETools.Codecs.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using CUETools.Codecs;
|
||||
using CUETools.Codecs.FLAKE;
|
||||
using CUETools.Codecs.Flake;
|
||||
|
||||
namespace CUETools.FlakeExe
|
||||
{
|
||||
@@ -144,7 +144,7 @@ namespace CUETools.FlakeExe
|
||||
bool do_seektable = true;
|
||||
bool buffered = false;
|
||||
string coeffs = null;
|
||||
var settings = new Codecs.FLAKE.EncoderSettings() { AllowNonSubset = true };
|
||||
var settings = new Codecs.Flake.EncoderSettings() { AllowNonSubset = true };
|
||||
bool allowNonSubset = false;
|
||||
bool ignore_chunk_sizes = false;
|
||||
bool force = false;
|
||||
@@ -272,7 +272,7 @@ namespace CUETools.FlakeExe
|
||||
else if (args[arg] != "-" && args[arg][0] == '-' && int.TryParse(args[arg].Substring(1), out intarg))
|
||||
{
|
||||
ok = intarg >= 0 && intarg <= 11;
|
||||
settings.EncoderModeIndex = intarg;
|
||||
settings.SetEncoderModeIndex(intarg);
|
||||
}
|
||||
else if ((args[arg][0] != '-' || args[arg] == "-") && input_file == null)
|
||||
input_file = args[arg];
|
||||
@@ -357,7 +357,7 @@ namespace CUETools.FlakeExe
|
||||
else if (File.Exists(input_file) && Path.GetExtension(input_file) == ".wav")
|
||||
audioSource = new Codecs.WAV.AudioDecoder(new Codecs.WAV.DecoderSettings(), input_file);
|
||||
else if (File.Exists(input_file) && Path.GetExtension(input_file) == ".flac")
|
||||
audioSource = new Codecs.FLAKE.AudioDecoder(new Codecs.FLAKE.DecoderSettings(), input_file);
|
||||
audioSource = new Codecs.Flake.AudioDecoder(new Codecs.Flake.DecoderSettings(), input_file);
|
||||
else
|
||||
{
|
||||
Usage();
|
||||
@@ -495,7 +495,7 @@ namespace CUETools.FlakeExe
|
||||
|
||||
if (debug)
|
||||
{
|
||||
settings = flake.Settings as Codecs.FLAKE.EncoderSettings;
|
||||
settings = flake.Settings as Codecs.Flake.EncoderSettings;
|
||||
Console.SetOut(stdout);
|
||||
Console.Out.WriteLine("{17}\t{0}\t{1:0.000}\t{2}\t{3}\t{4}\t{5}\t{6}..{7}\t{8}..{9}\t{10}..{11}\t{12}..{13}\t{14}\t{15}\t{16}\t{18}",
|
||||
flake.TotalSize,
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace CUETools.LossyWAVSharp
|
||||
AudioPCMConfig pcm = outputBPS == 0 ? audioSource.PCM : new AudioPCMConfig(outputBPS, audioSource.PCM.ChannelCount, audioSource.PCM.SampleRate, audioSource.PCM.ChannelMask);
|
||||
Codecs.WAV.AudioEncoder audioDest = new Codecs.WAV.AudioEncoder(new Codecs.WAV.EncoderSettings(pcm), Path.ChangeExtension(sourceFile, ".lossy.wav"), toStdout ? Console.OpenStandardOutput() : null);
|
||||
Codecs.WAV.AudioEncoder lwcdfDest = createCorrection ? new Codecs.WAV.AudioEncoder(new Codecs.WAV.EncoderSettings(audioSource.PCM), Path.ChangeExtension(sourceFile, ".lwcdf.wav")) : null;
|
||||
LossyWAVWriter lossyWAV = new LossyWAVWriter(audioDest, lwcdfDest, quality, new AudioEncoderSettings(audioSource.PCM));
|
||||
LossyWAVWriter lossyWAV = new LossyWAVWriter(audioDest, lwcdfDest, quality, new Codecs.WAV.EncoderSettings(audioSource.PCM));
|
||||
AudioBuffer buff = new AudioBuffer(audioSource, 0x10000);
|
||||
|
||||
Console.WriteLine("Filename : {0}", sourceFile);
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace CUETools.Processor
|
||||
{
|
||||
IAudioDest dest;
|
||||
if (audioEncoderType == AudioEncoderType.NoAudio || extension == ".dummy")
|
||||
return new Codecs.NULL.AudioEncoder(path, new AudioEncoderSettings(pcm)) { FinalSampleCount = finalSampleCount };
|
||||
return new Codecs.NULL.AudioEncoder(path, new Codecs.WAV.EncoderSettings(pcm)) { FinalSampleCount = finalSampleCount };
|
||||
CUEToolsFormat fmt;
|
||||
if (!extension.StartsWith(".") || !config.formats.TryGetValue(extension.Substring(1), out fmt))
|
||||
throw new Exception("Unsupported audio type: " + path);
|
||||
|
||||
@@ -422,7 +422,7 @@ namespace CUETools.Processor
|
||||
.FindAll(y => y.Extension == x.Extension && y.Lossless == x.Lossless && y.Name == x.Name).Count == 0)
|
||||
.ToList().ForEach(x => advanced.encoders.Add(x));
|
||||
backup.decoders.Where(x => advanced.decoders
|
||||
.FindAll(y => y.Extension == x.Extension && y.Lossless == x.Lossless && y.Name == x.Name).Count == 0)
|
||||
.FindAll(y => y.Extension == x.Extension && y.Name == x.Name).Count == 0)
|
||||
.ToList().ForEach(x => advanced.decoders.Add(x));
|
||||
|
||||
// Reset the ViewModel
|
||||
@@ -439,8 +439,8 @@ namespace CUETools.Processor
|
||||
encoderLossless = Encoders.GetDefault(extension, true);
|
||||
if (format.encoderLossy == null || !Encoders.TryGetValue(extension, false, format.encoderLossy.Name, out encoderLossy))
|
||||
encoderLossy = Encoders.GetDefault(extension, false);
|
||||
if (format.decoder == null || !Decoders.TryGetValue(extension, true, format.decoder.Name, out decoder))
|
||||
decoder = Decoders.GetDefault(extension, true);
|
||||
if (format.decoder == null || !Decoders.TryGetValue(extension, format.decoder.Name, out decoder))
|
||||
decoder = Decoders.GetDefault(extension);
|
||||
format.encoderLossless = encoderLossless;
|
||||
format.encoderLossy = encoderLossy;
|
||||
format.decoder = decoder;
|
||||
@@ -471,8 +471,8 @@ namespace CUETools.Processor
|
||||
udcLossless = Encoders.GetDefault(extension, true);
|
||||
if (encoderLossy == "" || !Encoders.TryGetValue(extension, false, encoderLossy, out udcLossy))
|
||||
udcLossy = Encoders.GetDefault(extension, false);
|
||||
if (decoder == "" || !Decoders.TryGetValue(extension, true, decoder, out udcDecoder))
|
||||
udcDecoder = Decoders.GetDefault(extension, true);
|
||||
if (decoder == "" || !Decoders.TryGetValue(extension, decoder, out udcDecoder))
|
||||
udcDecoder = Decoders.GetDefault(extension);
|
||||
if (!formats.TryGetValue(extension, out format))
|
||||
formats.Add(extension, new CUEToolsFormat(extension, tagger, allowLossless, allowLossy, allowEmbed, false, udcLossless, udcLossy, udcDecoder));
|
||||
else
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace CUETools.Processor
|
||||
{
|
||||
public static class CUEProcessorPlugins
|
||||
{
|
||||
public static List<AudioEncoderSettings> encs;
|
||||
public static List<AudioDecoderSettings> decs;
|
||||
public static List<IAudioEncoderSettings> encs;
|
||||
public static List<IAudioDecoderSettings> decs;
|
||||
public static List<Type> arcp;
|
||||
public static List<string> arcp_fmt;
|
||||
public static Type hdcd;
|
||||
@@ -20,8 +20,8 @@ namespace CUETools.Processor
|
||||
|
||||
static CUEProcessorPlugins()
|
||||
{
|
||||
encs = new List<AudioEncoderSettings>();
|
||||
decs = new List<AudioDecoderSettings>();
|
||||
encs = new List<IAudioEncoderSettings>();
|
||||
decs = new List<IAudioDecoderSettings>();
|
||||
arcp = new List<Type>();
|
||||
arcp_fmt = new List<string>();
|
||||
|
||||
@@ -68,13 +68,13 @@ namespace CUETools.Processor
|
||||
try
|
||||
{
|
||||
if (!type.IsClass || type.IsAbstract) continue;
|
||||
if (type.GetInterface(typeof(IAudioDecoderSettings).Name) != null && type != typeof(AudioDecoderSettings))
|
||||
if (type.GetInterface(typeof(IAudioDecoderSettings).Name) != null)
|
||||
{
|
||||
decs.Add(Activator.CreateInstance(type) as AudioDecoderSettings);
|
||||
decs.Add(Activator.CreateInstance(type) as IAudioDecoderSettings);
|
||||
}
|
||||
if (type.GetInterface(typeof(IAudioEncoderSettings).Name) != null && type != typeof(AudioEncoderSettings))
|
||||
if (type.GetInterface(typeof(IAudioEncoderSettings).Name) != null)
|
||||
{
|
||||
encs.Add(Activator.CreateInstance(type) as AudioEncoderSettings);
|
||||
encs.Add(Activator.CreateInstance(type) as IAudioEncoderSettings);
|
||||
}
|
||||
CompressionProviderClass archclass = Attribute.GetCustomAttribute(type, typeof(CompressionProviderClass)) as CompressionProviderClass;
|
||||
if (archclass != null)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace CUETools.Processor
|
||||
private long nextPos;
|
||||
private long _samplePos, _sampleLen;
|
||||
|
||||
public AudioDecoderSettings Settings { get { return null; } }
|
||||
public IAudioDecoderSettings Settings => null;
|
||||
|
||||
public long Length
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace CUETools.Ripper.SCSI
|
||||
private ReadProgressArgs progressArgs = new ReadProgressArgs();
|
||||
public event EventHandler<ReadProgressArgs> ReadProgress;
|
||||
|
||||
public AudioDecoderSettings Settings { get { return null; } }
|
||||
public IAudioDecoderSettings Settings => null;
|
||||
|
||||
public CDImageLayout TOC
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace CUETools.TestHelpers
|
||||
this.nextError = 0;
|
||||
}
|
||||
|
||||
public AudioDecoderSettings Settings { get { return null; } }
|
||||
public IAudioDecoderSettings Settings => null;
|
||||
|
||||
public NoiseAndErrorsGenerator(long sampleCount)
|
||||
: this(AudioPCMConfig.RedBook, sampleCount, 0, 0, 0)
|
||||
|
||||
@@ -110,9 +110,9 @@
|
||||
<Name>CUETools.Codecs.BDLPCM</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\CUETools.Codecs.FLAKE\CUETools.Codecs.FLAKE.csproj">
|
||||
<ProjectReference Include="..\CUETools.Codecs.Flake\CUETools.Codecs.Flake.csproj">
|
||||
<Project>{082d6b9e-326e-4d15-9798-edae9ede70a6}</Project>
|
||||
<Name>CUETools.Codecs.FLAKE</Name>
|
||||
<Name>CUETools.Codecs.Flake</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\CUETools.Codecs\CUETools.Codecs.csproj">
|
||||
|
||||
@@ -19,7 +19,7 @@ using CUETools.CTDB;
|
||||
using System.ComponentModel;
|
||||
using Krystalware.UploadHelper;
|
||||
using CUETools.Codecs;
|
||||
using CUETools.Codecs.FLAKE;
|
||||
//using CUETools.Codecs.Flake;
|
||||
using CUETools.Processor;
|
||||
using System.Collections.ObjectModel;
|
||||
//using Microsoft.Win32;
|
||||
@@ -247,7 +247,7 @@ namespace BluTools
|
||||
if (File.Exists(outputCuePath)) throw new Exception(string.Format("File \"{0}\" already exists", outputCuePath));
|
||||
if (File.Exists(outputAudioPath)) throw new Exception(string.Format("File \"{0}\" already exists", outputAudioPath));
|
||||
AudioBuffer buff = new AudioBuffer(reader, 0x10000);
|
||||
EncoderSettings settings = new EncoderSettings()
|
||||
CUETools.Codecs.Flake.EncoderSettings settings = new CUETools.Codecs.Flake.EncoderSettings()
|
||||
{
|
||||
PCM = reader.PCM,
|
||||
Padding = 16536,
|
||||
@@ -297,7 +297,7 @@ namespace BluTools
|
||||
}
|
||||
var start = DateTime.Now;
|
||||
TimeSpan lastPrint = TimeSpan.FromMilliseconds(0);
|
||||
var writer = new AudioEncoder(settings, outputAudioPath);
|
||||
var writer = new CUETools.Codecs.Flake.AudioEncoder(settings, outputAudioPath);
|
||||
try
|
||||
{
|
||||
while (reader.Read(buff, -1) != 0)
|
||||
|
||||
@@ -91,9 +91,9 @@
|
||||
<Name>CUETools.Codecs.ALAC</Name>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\CUETools.Codecs.FLAKE\CUETools.Codecs.FLAKE.csproj">
|
||||
<ProjectReference Include="..\..\CUETools.Codecs.Flake\CUETools.Codecs.Flake.csproj">
|
||||
<Project>{082D6B9E-326E-4D15-9798-EDAE9EDE70A6}</Project>
|
||||
<Name>CUETools.Codecs.FLAKE</Name>
|
||||
<Name>CUETools.Codecs.Flake</Name>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\CUETools.Codecs.libFLAC\CUETools.Codecs.libFLAC.csproj">
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using CUETools.Codecs;
|
||||
using CUETools.Codecs.FLAKE;
|
||||
using CUETools.Codecs.Flake;
|
||||
namespace CUETools.TestCodecs
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -103,7 +103,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CUETools.Converter", "..\CU
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CUEControls", "..\CUEControls\CUEControls.csproj", "{CA4D64E6-6544-4A29-8BA5-7DB08D50D072}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CUETools.Codecs.FLAKE", "..\CUETools.Codecs.FLAKE\CUETools.Codecs.FLAKE.csproj", "{082D6B9E-326E-4D15-9798-EDAE9EDE70A6}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CUETools.Codecs.Flake", "..\CUETools.Codecs.Flake\CUETools.Codecs.Flake.csproj", "{082D6B9E-326E-4D15-9798-EDAE9EDE70A6}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CUETools.Flake", "..\CUETools.Flake\CUETools.Flake.csproj", "{2379BAAF-A406-4477-BF53-2D6A326C24C8}"
|
||||
EndProject
|
||||
|
||||
@@ -2411,7 +2411,7 @@ namespace JDP
|
||||
// TODO: something cleverer than this hack...
|
||||
encoder.Settings.PCM = AudioPCMConfig.RedBook;
|
||||
buttonEncoderSettings.Visible = encoder.Settings.HasBrowsableAttributes();
|
||||
string[] modes = encoder.SupportedModes;
|
||||
string[] modes = encoder.SupportedModes.Split(' ');
|
||||
if (modes == null || modes.Length < 2)
|
||||
{
|
||||
trackBarEncoderMode.Visible = false;
|
||||
@@ -2423,9 +2423,7 @@ namespace JDP
|
||||
{
|
||||
if (encoder.EncoderModeIndex == -1)
|
||||
{
|
||||
string defaultMode;
|
||||
encoder.Settings.GetSupportedModes(out defaultMode);
|
||||
encoder.Settings.EncoderMode = defaultMode;
|
||||
encoder.Settings.EncoderMode = encoder.Settings.DefaultMode;
|
||||
}
|
||||
trackBarEncoderMode.Maximum = modes.Length - 1;
|
||||
trackBarEncoderMode.Value = encoder.EncoderModeIndex == -1 ? modes.Length - 1 : encoder.EncoderModeIndex;
|
||||
@@ -2460,7 +2458,7 @@ namespace JDP
|
||||
private void trackBarEncoderMode_Scroll(object sender, EventArgs e)
|
||||
{
|
||||
var encoder = comboBoxEncoder.SelectedItem as AudioEncoderSettingsViewModel;
|
||||
string[] modes = encoder.SupportedModes;
|
||||
string[] modes = encoder.SupportedModes.Split(' ');
|
||||
encoder.Settings.EncoderMode = modes[trackBarEncoderMode.Value];
|
||||
labelEncoderMode.Text = encoder.Settings.EncoderMode;
|
||||
}
|
||||
|
||||
2
CUETools/frmSettings.Designer.cs
generated
2
CUETools/frmSettings.Designer.cs
generated
@@ -513,7 +513,7 @@ namespace JDP
|
||||
// textBoxEncoderModes
|
||||
//
|
||||
resources.ApplyResources(this.textBoxEncoderModes, "textBoxEncoderModes");
|
||||
this.textBoxEncoderModes.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.encodersBindingSource, "SupportedModesStr", true));
|
||||
this.textBoxEncoderModes.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.encodersBindingSource, "SupportedModes", true));
|
||||
this.textBoxEncoderModes.Name = "textBoxEncoderModes";
|
||||
this.toolTip1.SetToolTip(this.textBoxEncoderModes, resources.GetString("textBoxEncoderModes.ToolTip"));
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user