dsp/window: add lookup table window functions

This commit is contained in:
Dan Kortschak
2020-02-20 11:15:43 +10:30
parent efc4dabf2a
commit c9a7355ed9
4 changed files with 125 additions and 18 deletions

View File

@@ -103,3 +103,18 @@ func ExampleHamming() {
// srcCpy: [0.092577 0.136714 0.220669 0.336222 0.472063 0.614894 0.750735 0.866288 0.950242 0.994379 0.994379 0.950242 0.866288 0.750735 0.614894 0.472063 0.336222 0.220669 0.136714 0.092577]
// dst: [0.092577 0.136714 0.220669 0.336222 0.472063 0.614894 0.750735 0.866288 0.950242 0.994379 0.994379 0.950242 0.866288 0.750735 0.614894 0.472063 0.336222 0.220669 0.136714 0.092577]
}
func ExampleValues() {
src := []float64{1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
// Create a Sine Window lookup table.
sine := window.NewValues(window.Sine, len(src))
// Apply the transformation to the src.
fmt.Printf("dst: %f\n", sine.Transform(src))
// Output:
//
// dst: [0.078459 0.233445 0.382683 0.522499 0.649448 0.760406 0.852640 0.923880 0.972370 0.996917 0.996917 0.972370 0.923880 0.852640 0.760406 0.649448 0.522499 0.382683 0.233445 0.078459]
}