Wideband autonomous SDR analysis engine forked from sdr-visual-suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 line
571B

  1. package demod
  2. import "math"
  3. type CW struct{}
  4. func (CW) Name() string { return "CW" }
  5. func (CW) OutputSampleRate() int { return 48000 }
  6. func (CW) Channels() int { return 1 }
  7. func (CW) Demod(iq []complex64, sampleRate int) []float32 {
  8. if len(iq) == 0 {
  9. return nil
  10. }
  11. out := make([]float32, len(iq))
  12. bfo := 700.0
  13. phase := 0.0
  14. inc := 2 * math.Pi * bfo / float64(sampleRate)
  15. for i := 0; i < len(iq); i++ {
  16. phase += inc
  17. c := math.Cos(phase)
  18. v := iq[i]
  19. out[i] = float32(float64(real(v)) * c)
  20. }
  21. return out
  22. }
  23. func init() { Register(CW{}) }