Wideband autonomous SDR analysis engine forked from sdr-visual-suite
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

52 lines
1.6KB

  1. package gpudemod
  2. import "math"
  3. type ExtractJob struct {
  4. OffsetHz float64
  5. BW float64
  6. OutRate int
  7. PhaseStart float64 // FreqShift starting phase (0 for stateless, carry over for streaming)
  8. }
  9. // ExtractResult holds the output of a batch extraction including the ending
  10. // phase of the FreqShift oscillator for phase-continuous streaming.
  11. type ExtractResult struct {
  12. IQ []complex64
  13. Rate int
  14. PhaseEnd float64 // FreqShift phase at end of this block — pass as PhaseStart next frame
  15. }
  16. func (e *Engine) ShiftFilterDecimateBatch(iq []complex64, jobs []ExtractJob) ([][]complex64, []int, error) {
  17. outs := make([][]complex64, len(jobs))
  18. rates := make([]int, len(jobs))
  19. for i, job := range jobs {
  20. out, rate, err := e.ShiftFilterDecimate(iq, job.OffsetHz, job.BW, job.OutRate)
  21. if err != nil {
  22. return nil, nil, err
  23. }
  24. outs[i] = out
  25. rates[i] = rate
  26. }
  27. return outs, rates, nil
  28. }
  29. // ShiftFilterDecimateBatchWithPhase is like ShiftFilterDecimateBatch but uses
  30. // per-job PhaseStart and returns per-job PhaseEnd for phase-continuous streaming.
  31. func (e *Engine) ShiftFilterDecimateBatchWithPhase(iq []complex64, jobs []ExtractJob) ([]ExtractResult, error) {
  32. results := make([]ExtractResult, len(jobs))
  33. for i, job := range jobs {
  34. out, rate, err := e.ShiftFilterDecimate(iq, job.OffsetHz, job.BW, job.OutRate)
  35. if err != nil {
  36. return nil, err
  37. }
  38. phaseInc := -2.0 * math.Pi * job.OffsetHz / float64(e.sampleRate)
  39. results[i] = ExtractResult{
  40. IQ: out,
  41. Rate: rate,
  42. PhaseEnd: job.PhaseStart + phaseInc*float64(len(iq)),
  43. }
  44. }
  45. return results, nil
  46. }