Skip to content

Commit

Permalink
change chromaprint offset, reorder analyzers, improve prompt timing (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rlauuzo authored and AbandonedCart committed May 17, 2024
1 parent e451a21 commit 57249bf
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public BlackFrameAnalyzer(ILogger<BlackFrameAnalyzer> logger)
if (frames.Length == 0)
{
// Since no black frames were found, slide the range closer to the end
start = midpoint;
start = midpoint - TimeSpan.FromSeconds(2);

if (midpoint - TimeSpan.FromSeconds(lowerLimit) < _maximumError)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer
/// Seconds of audio in one fingerprint point.
/// This value is defined by the Chromaprint library and should not be changed.
/// </summary>
private const double SamplesToSeconds = 0.128;
private const double SamplesToSeconds = 0.1238;

private int minimumIntroDuration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,14 +555,14 @@ <h3>Fingerprint Visualizer</h3>
<tr>
<td>Up arrow</td>
<td>
Shift the left episode up by 0.128 seconds.
Shift the left episode up by 0.1238 seconds.
Holding control will shift the episode by 10 seconds.
</td>
</tr>
<tr>
<td>Down arrow</td>
<td>
Shift the left episode down by 0.128 seconds.
Shift the left episode down by 0.1238 seconds.
Holding control will shift the episode by 10 seconds.
</td>
</tr>
Expand Down Expand Up @@ -957,13 +957,13 @@ <h3>Fingerprint Visualizer</h3>
case "ArrowDown":
if (timestampError.value != "") {
// if the control key is pressed, shift LHS by 10s. Otherwise, shift by 1.
offsetDelta = e.ctrlKey ? 10 / 0.128 : 1;
offsetDelta = e.ctrlKey ? 10 / 0.1238 : 1;
}
break;

case "ArrowUp":
if (timestampError.value != "") {
offsetDelta = e.ctrlKey ? -10 / 0.128 : -1;
offsetDelta = e.ctrlKey ? -10 / 0.1238 : -1;
}
break;

Expand Down Expand Up @@ -1147,12 +1147,12 @@ <h3>Fingerprint Visualizer</h3>

let lTime, rTime, diffPos;
if (shift < 0) {
lTime = y * 0.128;
rTime = (y + shift) * 0.128;
lTime = y * 0.1238;
rTime = (y + shift) * 0.1238;
diffPos = y + shift;
} else {
lTime = (y - shift) * 0.128;
rTime = y * 0.128;
lTime = (y - shift) * 0.1238;
rTime = y * 0.1238;
diffPos = y - shift;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ public SkipIntroController()
segment.IntroEnd -= config.SecondsOfIntroToPlay;
if (config.PersistSkipButton)
{
segment.ShowSkipPromptAt = segment.IntroStart;
segment.HideSkipPromptAt = segment.IntroEnd;
segment.ShowSkipPromptAt = segment.IntroStart;
segment.HideSkipPromptAt = segment.IntroEnd - 1;
}
else
{
segment.ShowSkipPromptAt = Math.Max(0, segment.IntroStart - config.ShowPromptAdjustment);
segment.HideSkipPromptAt = Math.Min(
segment.IntroStart + config.HidePromptAdjustment,
segment.IntroEnd);
segment.ShowSkipPromptAt = Math.Max(0, segment.IntroStart - config.ShowPromptAdjustment);
segment.HideSkipPromptAt = Math.Min(
segment.IntroStart + config.HidePromptAdjustment,
segment.IntroEnd - 1);
}

return segment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ public class BaseItemAnalyzerTask
var analyzers = new Collection<IMediaFileAnalyzer>();

analyzers.Add(new ChapterAnalyzer(_loggerFactory.CreateLogger<ChapterAnalyzer>()));
if (Plugin.Instance!.Configuration.UseChromaprint)
if (mode == AnalysisMode.Credits)
{
analyzers.Add(new ChromaprintAnalyzer(_loggerFactory.CreateLogger<ChromaprintAnalyzer>()));
analyzers.Add(new BlackFrameAnalyzer(_loggerFactory.CreateLogger<BlackFrameAnalyzer>()));
}

if (mode == AnalysisMode.Credits)
if (Plugin.Instance!.Configuration.UseChromaprint)
{
analyzers.Add(new BlackFrameAnalyzer(_loggerFactory.CreateLogger<BlackFrameAnalyzer>()));
analyzers.Add(new ChromaprintAnalyzer(_loggerFactory.CreateLogger<ChromaprintAnalyzer>()));
}

// Use each analyzer to find skippable ranges in all media files, removing successfully
Expand Down

0 comments on commit 57249bf

Please sign in to comment.