Wideband autonomous SDR analysis engine forked from sdr-visual-suite
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

58 строки
1.4KB

  1. package dsp
  2. import (
  3. "math/cmplx"
  4. "testing"
  5. )
  6. func TestStatefulDecimatingFIRComplexStreamContinuity(t *testing.T) {
  7. taps := LowpassFIR(90000, 512000, 101)
  8. factor := 2
  9. input := make([]complex64, 8192)
  10. for i := range input {
  11. input[i] = complex(float32((i%17)-8)/8.0, float32((i%11)-5)/8.0)
  12. }
  13. one := NewStatefulDecimatingFIRComplex(taps, factor)
  14. whole := one.Process(input)
  15. chunkedProc := NewStatefulDecimatingFIRComplex(taps, factor)
  16. var chunked []complex64
  17. for i := 0; i < len(input); i += 733 {
  18. end := i + 733
  19. if end > len(input) {
  20. end = len(input)
  21. }
  22. chunked = append(chunked, chunkedProc.Process(input[i:end])...)
  23. }
  24. if len(whole) != len(chunked) {
  25. t.Fatalf("length mismatch whole=%d chunked=%d", len(whole), len(chunked))
  26. }
  27. for i := range whole {
  28. if cmplx.Abs(complex128(whole[i]-chunked[i])) > 1e-5 {
  29. t.Fatalf("sample %d mismatch whole=%v chunked=%v", i, whole[i], chunked[i])
  30. }
  31. }
  32. }
  33. func TestStatefulDecimatingFIRComplexMatchesBlockPipelineLength(t *testing.T) {
  34. taps := LowpassFIR(90000, 512000, 101)
  35. factor := 2
  36. input := make([]complex64, 48640)
  37. for i := range input {
  38. input[i] = complex(float32((i%13)-6)/8.0, float32((i%7)-3)/8.0)
  39. }
  40. stateful := NewStatefulDecimatingFIRComplex(taps, factor)
  41. out := stateful.Process(input)
  42. filtered := ApplyFIR(input, taps)
  43. dec := Decimate(filtered, factor)
  44. if len(out) != len(dec) {
  45. t.Fatalf("unexpected output len got=%d want=%d", len(out), len(dec))
  46. }
  47. }