Skip to content

Commit

Permalink
Avoid short HTOA files
Browse files Browse the repository at this point in the history
If track one pregap is longer than 5 seconds, use Gaps Appended + HTOA.
In case of shorter pregaps, switch to Gaps Appended.
The user does no longer have to deal with all those 32, 33, 37, etc.
silent (or inaudible) frames saved as an HTOA file just to be able to
catch a real hidden track before track one.

- Add setting `UseHTOALengthThreshold`
  Default: `true`
- Add GUI setting for `UseHTOALengthThreshold`
  - Add CheckBox `chkUseHTOALengthThreshold` labeled "HTOA > 5s" to:
    Advanced Settings - CUETools - Gaps Handling
  - Add German translation for `chkUseHTOALengthThreshold`
- Resolves https://hydrogenaud.io/index.php?topic=118915.0#post_General
  • Loading branch information
c72578 committed Feb 23, 2024
1 parent 5004df7 commit 1ea8a57
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CUETools.Processor/CUEConfig.cs
Expand Up @@ -28,6 +28,7 @@ public class CUEConfig
public bool autoCorrectFilenames;
public bool detectGaps;
public bool preserveHTOA;
public bool useHTOALengthThreshold;
public bool ejectAfterRip;
public bool disableEjectDisc;
public bool keepOriginalFilenames;
Expand Down Expand Up @@ -96,6 +97,7 @@ public CUEConfig()

autoCorrectFilenames = true;
preserveHTOA = true;
useHTOALengthThreshold = true;
ejectAfterRip = false;
disableEjectDisc = false;
detectGaps = true;
Expand Down Expand Up @@ -182,6 +184,7 @@ public CUEConfig(CUEConfig src)

autoCorrectFilenames = src.autoCorrectFilenames;
preserveHTOA = src.preserveHTOA;
useHTOALengthThreshold = src.useHTOALengthThreshold;
ejectAfterRip = src.ejectAfterRip;
disableEjectDisc = src.disableEjectDisc;
detectGaps = src.detectGaps;
Expand Down Expand Up @@ -268,6 +271,7 @@ public void Save(SettingsWriter sw)
sw.Save("ArWriteLogOnVerify", writeArLogOnVerify);

sw.Save("PreserveHTOA", preserveHTOA);
sw.Save("UseHTOALengthThreshold", useHTOALengthThreshold);
sw.Save("EjectAfterRip", ejectAfterRip);
sw.Save("DisableEjectDisc", disableEjectDisc);
sw.Save("DetectGaps", detectGaps);
Expand Down Expand Up @@ -373,6 +377,7 @@ public void Load(SettingsReader sr)
writeArLogOnVerify = sr.LoadBoolean("ArWriteLogOnVerify") ?? false;

preserveHTOA = sr.LoadBoolean("PreserveHTOA") ?? true;
useHTOALengthThreshold = sr.LoadBoolean("UseHTOALengthThreshold") ?? true;
ejectAfterRip = sr.LoadBoolean("EjectAfterRip") ?? false;
disableEjectDisc = sr.LoadBoolean("DisableEjectDisc") ?? false;
detectGaps = sr.LoadBoolean("DetectGaps") ?? true;
Expand Down
10 changes: 5 additions & 5 deletions CUETools.Processor/CUESheet.cs
Expand Up @@ -2299,7 +2299,7 @@ public void GenerateFilenames(AudioEncoderType audioEncoderType, string format,
else
{
bool htoaToFile = ((OutputStyle == CUEStyle.GapsAppended) && _config.preserveHTOA &&
(_toc.Pregap != 0));
(_toc.Pregap > 75 * (_config.useHTOALengthThreshold ? 5 : 0)));
_destPaths = new string[TrackCount + (htoaToFile ? 1 : 0)];
if (htoaToFile)
_destPaths[0] = Path.Combine(OutputDir, _htoaFilename);
Expand Down Expand Up @@ -2455,7 +2455,7 @@ public void CreateRipperLOG()
public string GetM3UContents(CUEStyle style)
{
StringWriter sw = new StringWriter();
if (style == CUEStyle.GapsAppended && _config.preserveHTOA && _toc.Pregap != 0)
if (style == CUEStyle.GapsAppended && _config.preserveHTOA && _toc.Pregap > 75 * (_config.useHTOALengthThreshold ? 5 : 0))
WriteLine(sw, 0, _htoaFilename);
for (int iTrack = 0; iTrack < TrackCount; iTrack++)
WriteLine(sw, 0, _trackFilenames[iTrack]);
Expand All @@ -2474,7 +2474,7 @@ public string GetCUESheetContents()

public string GetCUESheetContents(CUEStyle style)
{
return GetCUESheetContents(style, (style == CUEStyle.GapsAppended && _config.preserveHTOA && _toc.Pregap != 0));
return GetCUESheetContents(style, (style == CUEStyle.GapsAppended && _config.preserveHTOA && _toc.Pregap > 75 * (_config.useHTOALengthThreshold ? 5 : 0)));
}

public string GetCUESheetContents(CUEStyle style, bool htoaToFile)
Expand Down Expand Up @@ -2720,7 +2720,7 @@ public string Go()
{
int[] destLengths;
bool htoaToFile = ((OutputStyle == CUEStyle.GapsAppended) && _config.preserveHTOA &&
(_toc.Pregap != 0));
(_toc.Pregap > 75 * (_config.useHTOALengthThreshold ? 5 : 0)));

if (_isCD)
DetectGaps();
Expand Down Expand Up @@ -4067,7 +4067,7 @@ private int[] CalculateAudioFileLengths(CUEStyle style)
{
int iTrack, iIndex, iFile;
int[] fileLengths;
bool htoaToFile = (style == CUEStyle.GapsAppended && _config.preserveHTOA && _toc.Pregap != 0);
bool htoaToFile = (style == CUEStyle.GapsAppended && _config.preserveHTOA && _toc.Pregap > 75 * (_config.useHTOALengthThreshold ? 5 : 0));
bool discardOutput;

if (style == CUEStyle.SingleFile || style == CUEStyle.SingleFileWithCUE)
Expand Down
2 changes: 1 addition & 1 deletion CUETools.Processor/CUESheetLogWriter.cs
Expand Up @@ -143,7 +143,7 @@ public static string GetExactAudioCopyLog(CUESheet sheet)
logWriter.WriteLine();

bool htoaToFile = ((sheet.OutputStyle == CUEStyle.GapsAppended) && sheet.Config.preserveHTOA &&
(sheet.TOC.Pregap != 0));
(sheet.TOC.Pregap > 75 * (sheet.Config.useHTOALengthThreshold ? 5 : 0)));
int accurateTracks = 0, knownTracks = 0;
bool wereErrors = false;
if (sheet.OutputStyle != CUEStyle.SingleFile && sheet.OutputStyle != CUEStyle.SingleFileWithCUE)
Expand Down
10 changes: 10 additions & 0 deletions CUETools/frmSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions CUETools/frmSettings.cs
Expand Up @@ -91,6 +91,7 @@ private void frmSettings_Load(object sender, EventArgs e)
//textBoxARLogExtension.Text = _config.arLogFilenameFormat;
numericUpDownMaxResolution.Value = _config.maxAlbumArtSize;
checkBoxSeparateDecodingThread.Checked = _config.separateDecodingThread;
chkUseHTOALengthThreshold.Checked = _config.useHTOALengthThreshold;

switch (_config.gapsHandling)
{
Expand Down Expand Up @@ -191,6 +192,7 @@ private void btnOK_Click(object sender, EventArgs e)
_reducePriority = chkReducePriority.Checked;
_config.checkForUpdates = checkBoxCheckForUpdates.Checked;
_config.preserveHTOA = rbGapsPlusHTOA.Checked;
_config.useHTOALengthThreshold = chkUseHTOALengthThreshold.Checked;
_config.gapsHandling = rbGapsPrepended.Checked ? CUEStyle.GapsPrepended :
rbGapsLeftOut.Checked ? CUEStyle.GapsLeftOut :
CUEStyle.GapsAppended;
Expand Down
6 changes: 6 additions & 0 deletions CUETools/frmSettings.de-DE.resx
Expand Up @@ -492,4 +492,10 @@ Sie können foobar2000 dazu bringen, die Werte anzuzeigen, und sehen, ob Ihre Mu
<data name="chkAlwaysWriteUTF8CUEFile.ToolTip" xml:space="preserve">
<value>Standardmäßig UTF-8-Kodierung zum Schreiben von CUE-Sheets verwenden</value>
</data>
<data name="chkUseHTOALengthThreshold.Text" xml:space="preserve">
<value>HTOA &gt; 5s</value>
</data>
<data name="chkUseHTOALengthThreshold.ToolTip" xml:space="preserve">
<value>HTOA-Datei wird nur gespeichert, wenn sie länger als 5 Sekunden ist</value>
</data>
</root>
39 changes: 36 additions & 3 deletions CUETools/frmSettings.resx
Expand Up @@ -381,7 +381,7 @@
<data name="&gt;&gt;chkCreateCUEFileWhenEmbedded.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="chkAlwaysWriteUTF8CUEFile.AutoSize" type="System.Boolean, mscorlib">
<data name="chkAlwaysWriteUTF8CUEFile.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="chkAlwaysWriteUTF8CUEFile.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
Expand Down Expand Up @@ -413,7 +413,7 @@
</data>
<data name="&gt;&gt;chkAlwaysWriteUTF8CUEFile.ZOrder" xml:space="preserve">
<value>9</value>
</data>
</data>
<data name="chkCreateM3U.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
Expand Down Expand Up @@ -1347,7 +1347,7 @@ You can set up foobar2000 to show those values, and see if your music was ripped
<value>groupBoxGaps</value>
</data>
<data name="&gt;&gt;rbGapsLeftOut.ZOrder" xml:space="preserve">
<value>2</value>
<value>4</value>
</data>
<data name="rbGapsPrepended.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand Down Expand Up @@ -1413,6 +1413,39 @@ You can set up foobar2000 to show those values, and see if your music was ripped
<value>groupBoxGaps</value>
</data>
<data name="&gt;&gt;rbGapsAppended.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="chkUseHTOALengthThreshold.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="chkUseHTOALengthThreshold.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="chkUseHTOALengthThreshold.Location" type="System.Drawing.Point, System.Drawing">
<value>165, 20</value>
</data>
<data name="chkUseHTOALengthThreshold.Size" type="System.Drawing.Size, System.Drawing">
<value>79, 17</value>
</data>
<data name="chkUseHTOALengthThreshold.TabIndex" type="System.Int32, mscorlib">
<value>17</value>
</data>
<data name="chkUseHTOALengthThreshold.Text" xml:space="preserve">
<value>HTOA &gt; 5s</value>
</data>
<data name="chkUseHTOALengthThreshold.ToolTip" xml:space="preserve">
<value>Save HTOA file only if longer than 5 seconds</value>
</data>
<data name="&gt;&gt;chkUseHTOALengthThreshold.Name" xml:space="preserve">
<value>chkUseHTOALengthThreshold</value>
</data>
<data name="&gt;&gt;chkUseHTOALengthThreshold.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;chkUseHTOALengthThreshold.Parent" xml:space="preserve">
<value>groupBoxGaps</value>
</data>
<data name="&gt;&gt;chkUseHTOALengthThreshold.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="rbGapsPlusHTOA.AutoSize" type="System.Boolean, mscorlib">
Expand Down

0 comments on commit 1ea8a57

Please sign in to comment.