-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
150 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
Cavern.QuickEQ.Format/FilterSet/BaseClasses/LimitedEqualizerFilterSet.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System.IO; | ||
using System.Text; | ||
|
||
using Cavern.Channels; | ||
using Cavern.QuickEQ.Equalization; | ||
using Cavern.Utilities; | ||
|
||
namespace Cavern.Format.FilterSet.BaseClasses { | ||
/// <summary> | ||
/// A fixed set of bands to sample from an <see cref="Equalizer"/> for export into a single file. This is the recommended and fastest | ||
/// approach of getting a filter set for incoherent fixed EQ bands, such as the <see cref="SonyESSeriesFilterSet"/>. | ||
/// </summary> | ||
public abstract class LimitedEqualizerFilterSet : EqualizerFilterSet { | ||
/// <summary> | ||
/// All frequency bands that need to be set. | ||
/// </summary> | ||
protected abstract float[] Frequencies { get; } | ||
|
||
/// <summary> | ||
/// Frequency bands for the LFE channel. | ||
/// </summary> | ||
protected abstract float[] LFEFrequencies { get; } | ||
|
||
/// <summary> | ||
/// How much smoothing in octaves shall be applied on the results to have a precise enough averaged value at each used frequency. | ||
/// </summary> | ||
protected abstract float Smoothing { get; } | ||
|
||
/// <summary> | ||
/// A fixed set of bands to sample from an <see cref="Equalizer"/> for export into a single file. | ||
/// </summary> | ||
protected LimitedEqualizerFilterSet(int sampleRate) : base(sampleRate) { } | ||
|
||
/// <summary> | ||
/// A fixed set of bands to sample from an <see cref="Equalizer"/> for export into a single file. | ||
/// </summary> | ||
protected LimitedEqualizerFilterSet(int channels, int sampleRate) : base(channels, sampleRate) { } | ||
|
||
/// <summary> | ||
/// A fixed set of bands to sample from an <see cref="Equalizer"/> for export into a single file. | ||
/// </summary> | ||
protected LimitedEqualizerFilterSet(ReferenceChannel[] channels, int sampleRate) : base(channels, sampleRate) { } | ||
|
||
/// <summary> | ||
/// Save the results of each channel to a single file. | ||
/// </summary> | ||
public override void Export(string path) { | ||
StringBuilder result = new StringBuilder("Set up the channels according to this configuration.").AppendLine(); | ||
for (int i = 0; i < Channels.Length; i++) { | ||
RootFileChannelHeader(i, result); | ||
Equalizer curve = (Equalizer)((EqualizerChannelData)Channels[i]).curve.Clone(); | ||
curve.Smooth(Smoothing); | ||
float[] freqs = Channels[i].reference != ReferenceChannel.ScreenLFE ? Frequencies : LFEFrequencies; | ||
for (int j = 0; j < freqs.Length; j++) { | ||
string gain = QMath.ToStringLimitDecimals(curve[freqs[j]], 2); | ||
result.AppendLine($"{RangeDependentDecimals(freqs[j])} Hz:\t{gain} dB"); | ||
} | ||
} | ||
File.WriteAllText(path, result.ToString()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Cavern.Channels; | ||
using Cavern.Format.FilterSet.BaseClasses; | ||
|
||
namespace Cavern.Format.FilterSet { | ||
/// <summary> | ||
/// Banded filter set for Sony ES-series receivers. | ||
/// </summary> | ||
public class SonyESSeriesFilterSet : LimitedEqualizerFilterSet { | ||
/// <inheritdoc/> | ||
protected override float[] Frequencies => frequencies; | ||
|
||
/// <inheritdoc/> | ||
protected override float[] LFEFrequencies => lfeFrequencies; | ||
|
||
/// <inheritdoc/> | ||
protected override float Smoothing => 1; | ||
|
||
/// <summary> | ||
/// Banded filter set for Sony ES-series receivers. | ||
/// </summary> | ||
public SonyESSeriesFilterSet(int channels, int sampleRate) : base(channels, sampleRate) { } | ||
|
||
/// <summary> | ||
/// Banded filter set for Sony ES-series receivers. | ||
/// </summary> | ||
public SonyESSeriesFilterSet(ReferenceChannel[] channels, int sampleRate) : base(channels, sampleRate) { } | ||
|
||
/// <summary> | ||
/// All frequency bands that need to be set. | ||
/// </summary> | ||
static readonly float[] frequencies = { 47, 230, 470, 840, 1300, 2300, 3800, 5800, 9000, 14000 }; | ||
|
||
/// <summary> | ||
/// All LFE frequency bands that need to be set. | ||
/// </summary> | ||
static readonly float[] lfeFrequencies = { 40, 60, 80, 90, 100, 120 }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters