Wideband autonomous SDR analysis engine forked from sdr-visual-suite
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

41 líneas
887B

  1. package demod
  2. import "math"
  3. type NFM struct{}
  4. type WFM struct{}
  5. func (NFM) Name() string { return "NFM" }
  6. func (WFM) Name() string { return "WFM" }
  7. func (NFM) OutputSampleRate() int { return 48000 }
  8. func (WFM) OutputSampleRate() int { return 192000 }
  9. func (NFM) Demod(iq []complex64, sampleRate int) []float32 {
  10. return fmDiscrim(iq)
  11. }
  12. func (WFM) Demod(iq []complex64, sampleRate int) []float32 {
  13. return fmDiscrim(iq)
  14. }
  15. func fmDiscrim(iq []complex64) []float32 {
  16. if len(iq) < 2 {
  17. return nil
  18. }
  19. out := make([]float32, len(iq)-1)
  20. for i := 1; i < len(iq); i++ {
  21. p := iq[i-1]
  22. c := iq[i]
  23. num := float64(real(p))*float64(imag(c)) - float64(imag(p))*float64(real(c))
  24. den := float64(real(p))*float64(real(c)) + float64(imag(p))*float64(imag(c))
  25. out[i-1] = float32(math.Atan2(num, den))
  26. }
  27. return out
  28. }
  29. func init() {
  30. Register(NFM{})
  31. Register(WFM{})
  32. }