-
Notifications
You must be signed in to change notification settings - Fork 15
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
21 changed files
with
168 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,45 @@ | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
|
||
using Cavern.QuickEQ.Equalization; | ||
|
||
namespace Cavern.QuickEQ.Crossover { | ||
/// <summary> | ||
/// A FIR brickwall crossover, first introduced in Cavern. | ||
/// </summary> | ||
internal class CavernCrossover : BasicCrossover { | ||
public class CavernCrossover : BasicCrossover { | ||
/// <summary> | ||
/// Creates a FIR brickwall crossover, first introduced in Cavern. | ||
/// </summary> | ||
/// <param name="frequencies">Crossover frequencies for each channel, only values over 0 mean crossovered channels</param> | ||
/// <param name="subs">Channels to route bass to</param> | ||
public CavernCrossover(float[] frequencies, bool[] subs) : base(frequencies, subs) { } | ||
|
||
/// <summary> | ||
/// Add the filter's interpretation of highpass to the previously selected channel in a WIP configuration file. | ||
/// </summary> | ||
/// <inheritdoc/> | ||
public override void AddHighpass(List<string> wipConfig, float frequency) { | ||
float offsetFreq = frequency * .967741875f; // Removes crossover notch caused by FIR resolution | ||
wipConfig.Add($"GraphicEQ: {(offsetFreq - 1).ToString(CultureInfo.InvariantCulture)} -48;" + | ||
$" {offsetFreq.ToString(CultureInfo.InvariantCulture)} 0"); | ||
} | ||
|
||
/// <summary> | ||
/// Add the filter's interpretation of lowpass to the previously selected channel in a WIP configuration file. | ||
/// </summary> | ||
/// <remarks>Don't forget to call AddExtraOperations, this is generally the best place for it.</remarks> | ||
/// <inheritdoc/> | ||
public override float[] GetHighpass(int sampleRate, float frequency, int length) => new Equalizer(new List<Band> { | ||
new Band(frequency * .967741875f, -48), // Removes crossover notch caused by FIR resolution | ||
new Band(frequency, 0) | ||
}, true).GetConvolution(sampleRate, length); | ||
|
||
/// <inheritdoc/> | ||
public override void AddLowpass(List<string> wipConfig, float frequency) { | ||
float offsetFreq = frequency * 1.032258f; // Removes crossover notch caused by FIR resolution | ||
wipConfig.Add($"GraphicEQ: {offsetFreq.ToString(CultureInfo.InvariantCulture)} 0;" + | ||
$" {(offsetFreq + 1).ToString(CultureInfo.InvariantCulture)} -48"); | ||
AddExtraOperations(wipConfig); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override float[] GetLowpass(int sampleRate, float frequency, int length) => new Equalizer(new List<Band> { | ||
new Band(frequency, 0), | ||
new Band(frequency * 1.032258f, -48) // Removes crossover notch caused by FIR resolution | ||
}, true).GetConvolution(sampleRate, length); | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Cavern.Filters { | ||
/// <summary> | ||
|
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
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
15 changes: 15 additions & 0 deletions
15
Tests/Test.Cavern.QuickEQ/Crossover/BasicCrossover_Tests.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,15 @@ | ||
using Cavern.QuickEQ.Crossover; | ||
|
||
namespace Test.Cavern.QuickEQ.Crossover { | ||
/// <summary> | ||
/// Tests the <see cref="BasicCrossover"/> class. | ||
/// </summary> | ||
[TestClass] | ||
public class BasicCrossover_Tests { | ||
/// <summary> | ||
/// Tests if <see cref="BasicCrossover"/> generates correct impulse responses. | ||
/// </summary> | ||
[TestMethod, Timeout(1000)] | ||
public void ImpulseResponse() => Utils.ImpulseResponse(new BasicCrossover(null, null), 0.49152157f, 0.50847834f); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Tests/Test.Cavern.QuickEQ/Crossover/CavernCrossover_Tests.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,15 @@ | ||
using Cavern.QuickEQ.Crossover; | ||
|
||
namespace Test.Cavern.QuickEQ.Crossover { | ||
/// <summary> | ||
/// Tests the <see cref="CavernCrossover"/> class. | ||
/// </summary> | ||
[TestClass] | ||
public class CavernCrossover_Tests { | ||
/// <summary> | ||
/// Tests if <see cref="CavernCrossover"/> generates correct impulse responses. | ||
/// </summary> | ||
[TestMethod, Timeout(1000)] | ||
public void ImpulseResponse() => Utils.ImpulseResponse(new CavernCrossover(null, null), 0.4130373f, 0.979050338f); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Tests/Test.Cavern.QuickEQ/Crossover/SyntheticBiquadCrossover_Tests.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,15 @@ | ||
using Cavern.QuickEQ.Crossover; | ||
|
||
namespace Test.Cavern.QuickEQ.Crossover { | ||
/// <summary> | ||
/// Tests the <see cref="SyntheticBiquadCrossover"/> class. | ||
/// </summary> | ||
[TestClass] | ||
public class SyntheticBiquadCrossover_Tests { | ||
/// <summary> | ||
/// Tests if <see cref="SyntheticBiquadCrossover"/> generates correct impulse responses. | ||
/// </summary> | ||
[TestMethod, Timeout(1000)] | ||
public void ImpulseResponse() => Utils.ImpulseResponse(new SyntheticBiquadCrossover(null, null), 0.47490564f, 0.5231629f); | ||
} | ||
} |
Oops, something went wrong.