fixed a bug in filename corrector, which would erroneously sort filenames alpabeticaly when it should not.

added an option to automaticly detect and remove extra 4206 samples, added by some erroneous flac coders.
This commit is contained in:
chudov
2008-11-08 14:59:50 +00:00
parent 9844a654ce
commit ad057576bc
5 changed files with 368 additions and 289 deletions

View File

@@ -27,6 +27,7 @@ namespace JDP {
System.Windows.Forms.Button btnCancel;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmSettings));
this.grpGeneral = new System.Windows.Forms.GroupBox();
this.chkTruncateExtra4206Samples = new System.Windows.Forms.CheckBox();
this.chkCreateCUEFileWhenEmbedded = new System.Windows.Forms.CheckBox();
this.chkCreateM3U = new System.Windows.Forms.CheckBox();
this.chkFillUpCUE = new System.Windows.Forms.CheckBox();
@@ -132,6 +133,7 @@ namespace JDP {
this.grpGeneral.AccessibleName = null;
resources.ApplyResources(this.grpGeneral, "grpGeneral");
this.grpGeneral.BackgroundImage = null;
this.grpGeneral.Controls.Add(this.chkTruncateExtra4206Samples);
this.grpGeneral.Controls.Add(this.chkCreateCUEFileWhenEmbedded);
this.grpGeneral.Controls.Add(this.chkCreateM3U);
this.grpGeneral.Controls.Add(this.chkFillUpCUE);
@@ -145,6 +147,17 @@ namespace JDP {
this.grpGeneral.TabStop = false;
this.toolTip1.SetToolTip(this.grpGeneral, resources.GetString("grpGeneral.ToolTip"));
//
// chkTruncateExtra4206Samples
//
this.chkTruncateExtra4206Samples.AccessibleDescription = null;
this.chkTruncateExtra4206Samples.AccessibleName = null;
resources.ApplyResources(this.chkTruncateExtra4206Samples, "chkTruncateExtra4206Samples");
this.chkTruncateExtra4206Samples.BackgroundImage = null;
this.chkTruncateExtra4206Samples.Font = null;
this.chkTruncateExtra4206Samples.Name = "chkTruncateExtra4206Samples";
this.toolTip1.SetToolTip(this.chkTruncateExtra4206Samples, resources.GetString("chkTruncateExtra4206Samples.ToolTip"));
this.chkTruncateExtra4206Samples.UseVisualStyleBackColor = true;
//
// chkCreateCUEFileWhenEmbedded
//
this.chkCreateCUEFileWhenEmbedded.AccessibleDescription = null;
@@ -1106,6 +1119,7 @@ namespace JDP {
private System.Windows.Forms.CheckBox chkHDCDStopLooking;
private System.Windows.Forms.CheckBox chkCreateM3U;
private System.Windows.Forms.CheckBox chkCreateCUEFileWhenEmbedded;
private System.Windows.Forms.CheckBox chkTruncateExtra4206Samples;
}
}

View File

@@ -62,6 +62,7 @@ namespace JDP {
chkHDCDStopLooking.Checked = _config.wait750FramesForHDCD;
chkCreateM3U.Checked = _config.createM3U;
chkCreateCUEFileWhenEmbedded.Checked = _config.createCUEFileWhenEmbedded;
chkTruncateExtra4206Samples.Checked = _config.truncate4608ExtraSamples;
}
private void frmSettings_FormClosing(object sender, FormClosingEventArgs e) {
@@ -125,6 +126,7 @@ namespace JDP {
_config.decodeHDCD = chkHDCDDecode.Checked;
_config.createM3U = chkCreateM3U.Checked;
_config.createCUEFileWhenEmbedded = chkCreateCUEFileWhenEmbedded.Checked;
_config.truncate4608ExtraSamples = chkTruncateExtra4206Samples.Checked;
}
private void chkArFixOffset_CheckedChanged(object sender, EventArgs e)

File diff suppressed because it is too large Load Diff

View File

@@ -124,6 +124,12 @@
<value>Общие</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="chkTruncateExtra4206Samples.Size" type="System.Drawing.Size, System.Drawing">
<value>202, 17</value>
</data>
<data name="chkTruncateExtra4206Samples.Text" xml:space="preserve">
<value>Выкидывать лишние 4206 сэмплов</value>
</data>
<data name="chkCreateCUEFileWhenEmbedded.Size" type="System.Drawing.Size, System.Drawing">
<value>224, 17</value>
</data>

View File

@@ -233,6 +233,7 @@ namespace CUEToolsLib
public bool wait750FramesForHDCD;
public bool createM3U;
public bool createCUEFileWhenEmbedded;
public bool truncate4608ExtraSamples;
public CUEConfig()
{
@@ -271,6 +272,7 @@ namespace CUEToolsLib
decodeHDCD = false;
createM3U = false;
createCUEFileWhenEmbedded = false;
truncate4608ExtraSamples = true;
}
public void Save (SettingsWriter sw)
@@ -310,6 +312,7 @@ namespace CUEToolsLib
sw.Save("DecodeHDCD", decodeHDCD);
sw.Save("CreateM3U", createM3U);
sw.Save("CreateCUEFileWhenEmbedded", createCUEFileWhenEmbedded);
sw.Save("Truncate4608ExtraSamples", truncate4608ExtraSamples);
}
public void Load(SettingsReader sr)
@@ -349,6 +352,7 @@ namespace CUEToolsLib
decodeHDCD = sr.LoadBoolean("DecodeHDCD") ?? false;
createM3U = sr.LoadBoolean("CreateM3U") ?? false;
createCUEFileWhenEmbedded = sr.LoadBoolean("CreateCUEFileWhenEmbedded") ?? false;
truncate4608ExtraSamples = sr.LoadBoolean("Truncate4608ExtraSamples") ?? true;
}
public string CleanseString (string s)
@@ -387,7 +391,7 @@ namespace CUEToolsLib
private string _htoaFilename, _singleFilename;
private bool _hasHTOAFilename, _hasTrackFilenames, _hasSingleFilename, _appliedWriteOffset;
private bool _hasEmbeddedCUESheet;
private bool _paddedToFrame, _usePregapForFirstTrackInSingleFile;
private bool _paddedToFrame, _truncated4608, _usePregapForFirstTrackInSingleFile;
private int _writeOffset;
private bool _accurateRip, _accurateOffset;
private uint? _dataTrackLength;
@@ -434,6 +438,7 @@ namespace CUEToolsLib
_sourcePaths = new List<string>();
_cuePath = null;
_paddedToFrame = false;
_truncated4608 = false;
_usePregapForFirstTrackInSingleFile = false;
_accurateRip = false;
_accurateOffset = false;
@@ -522,11 +527,16 @@ namespace CUEToolsLib
absoluteFileStartTime += fileTimeLengthFrames;
NameValueCollection tags;
fileTimeLengthSamples = GetSampleLength(pathAudio, out tags);
if ((fileTimeLengthSamples % 588) == 492 && _config.truncate4608ExtraSamples)
{
_truncated4608 = true;
fileTimeLengthSamples -= 4608;
}
fileTimeLengthFrames = (int)((fileTimeLengthSamples + 587) / 588);
if (_hasEmbeddedCUESheet)
_albumTags = tags;
else
_trackTags = tags;
fileTimeLengthFrames = (int)((fileTimeLengthSamples + 587) / 588);
seenFirstFileIndex = false;
}
}
@@ -753,6 +763,17 @@ namespace CUEToolsLib
if (_accurateRipId == null)
_accurateRipId = _accurateRipIdActual;
}
//if (!_dataTrackLength.HasValue && _cddbDiscIdTag != null)
//{
// uint cddbDiscIdNum = UInt32.Parse(_cddbDiscIdTag, NumberStyles.HexNumber);
// if ((cddbDiscIdNum & 0xff) == TrackCount)
// {
// _cutOneFrame = true;
// string cddbDiscIdTagCut = CalculateAccurateRipId().Split('-')[2];
// if (cddbDiscIdTagCut.ToUpper() != _cddbDiscIdTag.ToUpper())
// _cutOneFrame = false;
// }
//}
}
public static Encoding Encoding {
@@ -1334,6 +1355,10 @@ namespace CUEToolsLib
sw.WriteLine("Data track was probably present, length {0}-{1}.", General.TimeToString(_minDataTrackLength.Value), General.TimeToString(_minDataTrackLength.Value + 74));
if (_accurateRipIdActual != _accurateRipId)
sw.WriteLine("Using preserved id, actual id is {0}.", _accurateRipIdActual);
if (_truncated4608)
sw.WriteLine("Truncated 4608 extra samples in some input files.");
if (_paddedToFrame)
sw.WriteLine("Padded some input files to a frame boundary.");
}
if (hdcdDecoder != null && hdcdDecoder.Detected)
@@ -2077,6 +2102,7 @@ namespace CUEToolsLib
if (!foundAll || always)
{
foundAll = false;
for (i = 0; i < audioExts.Length; i++)
{
foundAll = true;
@@ -2092,22 +2118,23 @@ namespace CUEToolsLib
audioFiles = newFiles.ToArray();
break;
}
}
if (!foundAll)
for (i = 0; i < audioExts.Length; i++)
{
audioFiles = Directory.GetFiles(dir == "" ? "." : dir, audioExts[i]);
if (audioFiles.Length == filePos.Count)
{
Array.Sort(audioFiles);
foundAll = true;
break;
}
}
if (i == audioExts.Length)
{
if (!foundAll)
throw new Exception("Unable to locate the audio files.");
}
Array.Sort(audioFiles);
for (i = 0; i < filePos.Count; i++)
{
lines[filePos[i]] = "FILE \"" + Path.GetFileName(audioFiles[i]) + "\" WAVE";
}
}
using (StringWriter sw = new StringWriter()) {