-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestContainer.cs
81 lines (63 loc) · 2.12 KB
/
TestContainer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
namespace BRRSuiteGUI;
/// <summary>
/// Holds an encoded audio sample, a preview audio file, and, optionally, the parameters these files were generated with.
/// </summary>
internal sealed class TestContainer {
/// <summary>
/// Gets a reference to the encoded BRR file associated with this test candidate.
/// </summary>
public BRRSample BRRFile { get; }
/// <summary>
/// Gets a reference to the wave audio associated with this test candidate.
/// </summary>
public WaveContainer WaveFile { get; }
/// <summary>
/// The name of this object as it should appear in the user interface.
/// </summary>
public string Name { get; }
/// <summary>
/// Gets the name this object should appear as in the user interface.
/// </summary>
public required string ListName { get; init; }
/// <summary>
/// Gets the preferred file name this container's members should use for export.
/// </summary>
public required string FileName { get; init; }
public required int EncodingFrequency { get; init; }
/// <summary>
/// The sample the source audio was trimmed to
/// </summary>
public int Trim { get; init; } = 0;
public decimal ResampleRatio { get; set; } = 1.0M;
/// <summary>
/// The attempted sample the source audio was looped at.
/// </summary>
public int? LoopSample { get; init; } = null;
/// <summary>
/// The number of blocks in the BRR file.
/// </summary>
public int BlockCount => BRRFile.BlockCount;
/// <summary>
/// The block number of the loop for the BRR file.
/// </summary>
public int LoopBlock => BRRFile.LoopBlock;
public double? EstimatedFrequency { get; set; } = null;
/// <summary>
/// ID for sorting, if necessary
/// </summary>
internal long ID { get; init; }
/// <summary>
/// TestContainer
/// </summary>
public TestContainer(string name, BRRSample brr, WaveContainer wav) {
Name = name;
BRRFile = brr;
WaveFile = wav;
}
/// <inheritdoc cref="object.ToString()"/>
public override string ToString() => ListName;
public void DoFrequencyEstimate() {
if (EstimatedFrequency is not null) return;
EstimatedFrequency = Aubio.Aubio.DetectPitch(WaveFile, PitchDetectionAlgorithm.YIN);
}
}