Easy setup for tak/ogg/mp3 external encoders

This commit is contained in:
chudov
2009-02-19 06:26:56 +00:00
parent f37d698f6a
commit 6fc7cdebe7
12 changed files with 595 additions and 222 deletions

View File

@@ -35,7 +35,7 @@ namespace CUETools.Processor
#endif
default:
if (extension == "." + config.udc1Extension && config.udc1Decoder != "")
return new UserDefinedReader(path, IO, config.udc1Decoder, config.udc1Params, config.udc1APEv2);
return new UserDefinedReader(path, IO, config.udc1Decoder, config.udc1Params);
throw new Exception("Unsupported audio type: " + path);
}
}

View File

@@ -273,7 +273,7 @@ namespace CUETools.Processor
public bool decodeHDCDtoLW16;
public bool decodeHDCDto24bit;
public string udc1Extension, udc1Decoder, udc1Params, udc1Encoder, udc1EncParams;
public bool udc1APEv2;
public bool udc1APEv2, udc1ID3v2;
public CUEConfig()
{
@@ -322,7 +322,7 @@ namespace CUETools.Processor
decodeHDCDto24bit = true;
udc1Extension = udc1Decoder = udc1Params = udc1Encoder = udc1EncParams = "";
udc1APEv2 = false;
udc1ID3v2 = udc1APEv2 = false;
}
public void Save (SettingsWriter sw)
@@ -378,6 +378,7 @@ namespace CUETools.Processor
sw.Save("UDC1Encoder", udc1Encoder);
sw.Save("UDC1EncParams", udc1EncParams);
sw.Save("UDC1APEv2", udc1APEv2);
sw.Save("UDC1ID3v2", udc1ID3v2);
}
}
@@ -433,6 +434,7 @@ namespace CUETools.Processor
udc1Encoder = sr.Load("UDC1Encoder") ?? "";
udc1EncParams = sr.Load("UDC1EncParams") ?? "";
udc1APEv2 = sr.LoadBoolean("UDC1APEv2") ?? false;
udc1ID3v2 = sr.LoadBoolean("UDC1ID3v2") ?? false;
}
public string CleanseString (string s)

View File

@@ -9,17 +9,22 @@ namespace CUETools.Processor
{
public static bool UpdateTags(TagLib.File fileInfo, NameValueCollection tags, CUEConfig config)
{
if (fileInfo is TagLib.Flac.File)
if (fileInfo is TagLib.Riff.File)
return false;
TagLib.Ogg.XiphComment xiph = (TagLib.Ogg.XiphComment)fileInfo.GetTag(TagLib.TagTypes.Xiph);
if (xiph != null)
{
TagLib.Ogg.XiphComment xiph = (TagLib.Ogg.XiphComment)fileInfo.GetTag(TagLib.TagTypes.Xiph);
foreach (string tag in tags.AllKeys)
xiph.SetField(tag, tags.GetValues(tag));
return true;
}
if (fileInfo is TagLib.Riff.File)
return false;
if (fileInfo is TagLib.UserDefined.File && !(fileInfo as TagLib.UserDefined.File).SupportsAPEv2)
return false;
{
if (!(fileInfo as TagLib.UserDefined.File).SupportsID3v2)
return false;
TagLib.Id3v2.Tag id3v2 = (TagLib.Id3v2.Tag)fileInfo.GetTag(TagLib.TagTypes.Id3v2, true);
return true;
}
TagLib.Ape.Tag ape = (TagLib.Ape.Tag)fileInfo.GetTag(TagLib.TagTypes.Ape, true);
foreach (string tag in tags.AllKeys)
ape.SetValue(XiphTagNameToApe(tag), tags.GetValues(tag));

View File

@@ -45,7 +45,9 @@ namespace TagLib.UserDefined {
{
#region Private Fields
private bool _supportsAPEv2 = true;
private bool _supportsAPEv2 = true;
private bool _supportsID3v2 = true;
#endregion
@@ -70,10 +72,17 @@ namespace TagLib.UserDefined {
/// <exception cref="ArgumentNullException">
/// <paramref name="path" /> is <see langword="null" />.
/// </exception>
public File (string path, ReadStyle propertiesStyle, bool supportsAPEv2)
public File (string path, ReadStyle propertiesStyle, bool supportsAPEv2, bool supportsID3v2)
: base (path, propertiesStyle)
{
_supportsAPEv2 = supportsAPEv2;
_supportsAPEv2 = supportsAPEv2;
_supportsID3v2 = supportsID3v2;
// Make sure we have an APE tag.
if (_supportsAPEv2)
GetTag(TagTypes.Ape, true);
else
if (_supportsID3v2)
GetTag(TagTypes.Id3v2, true);
}
/// <summary>
@@ -87,10 +96,18 @@ namespace TagLib.UserDefined {
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="path" /> is <see langword="null" />.
/// </exception>
public File (string path, bool supportsAPEv2) : base (path)
/// </exception>
public File(string path, bool supportsAPEv2, bool supportsID3v2)
: base(path)
{
_supportsAPEv2 = supportsAPEv2;
_supportsAPEv2 = supportsAPEv2;
_supportsID3v2 = supportsID3v2;
// Make sure we have an APE tag.
if (_supportsAPEv2)
GetTag(TagTypes.Ape, true);
else
if (_supportsID3v2)
GetTag(TagTypes.Id3v2, true);
}
/// <summary>
@@ -111,11 +128,18 @@ namespace TagLib.UserDefined {
/// <paramref name="abstraction" /> is <see langword="null"
/// />.
/// </exception>
public File (File.IFileAbstraction abstraction,
ReadStyle propertiesStyle, bool supportsAPEv2)
public File (File.IFileAbstraction abstraction,
ReadStyle propertiesStyle, bool supportsAPEv2, bool supportsID3v2)
: base (abstraction, propertiesStyle)
{
_supportsAPEv2 = supportsAPEv2;
_supportsAPEv2 = supportsAPEv2;
_supportsID3v2 = supportsID3v2;
// Make sure we have an APE tag.
if (_supportsAPEv2)
GetTag(TagTypes.Ape, true);
else
if (_supportsID3v2)
GetTag(TagTypes.Id3v2, true);
}
/// <summary>
@@ -130,11 +154,18 @@ namespace TagLib.UserDefined {
/// <exception cref="ArgumentNullException">
/// <paramref name="abstraction" /> is <see langword="null"
/// />.
/// </exception>
public File (File.IFileAbstraction abstraction, bool supportsAPEv2)
/// </exception>
public File(File.IFileAbstraction abstraction, bool supportsAPEv2, bool supportsID3v2)
: base (abstraction)
{
_supportsAPEv2 = supportsAPEv2;
_supportsAPEv2 = supportsAPEv2;
_supportsID3v2 = supportsID3v2;
// Make sure we have an APE tag.
if (_supportsAPEv2)
GetTag(TagTypes.Ape, true);
else
if (_supportsID3v2)
GetTag(TagTypes.Id3v2, true);
}
#endregion
@@ -149,6 +180,14 @@ namespace TagLib.UserDefined {
{
return _supportsAPEv2;
}
}
public bool SupportsID3v2
{
get
{
return _supportsID3v2;
}
}
@@ -240,9 +279,6 @@ namespace TagLib.UserDefined {
protected override void ReadEnd (long end,
ReadStyle propertiesStyle)
{
// Make sure we have an APE tag.
if (_supportsAPEv2)
GetTag (TagTypes.Ape, true);
}
/// <summary>
@@ -293,12 +329,12 @@ namespace TagLib.UserDefined {
private static TagLib.File UserDefinedResolver(TagLib.File.IFileAbstraction abstraction, string mimetype, TagLib.ReadStyle style)
{
if (mimetype == "taglib/flac" || mimetype == "taglib/wv" || mimetype == "taglib/ape" || mimetype == "taglib/wav")
if (mimetype == "taglib/flac" || mimetype == "taglib/wv" || mimetype == "taglib/ape" || mimetype == "taglib/wav" || mimetype == "taglib/ogg")
return null;
if (mimetype == "taglib/tta")
return new File(abstraction, style, true);
return new File(abstraction, style, true, false);
if (mimetype == "taglib/" + _config.udc1Extension)
return new File(abstraction, style, _config.udc1APEv2);
return new File(abstraction, style, _config.udc1APEv2, _config.udc1ID3v2);
return null;
}