Skip to content

Commit

Permalink
[fft] Add in documentation that was missing from new functions
Browse files Browse the repository at this point in the history
  • Loading branch information
paultag committed May 15, 2023
1 parent b2c83a5 commit 9809d57
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fft/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,14 @@ func BinBandwidth(frequencyLen int, sampleRate uint) rf.Hz {
return rf.Hz(float32(sampleRate) / float32(frequencyLen))
}

// Nyquest will return the Nyquest frequency of the IQ stream with the
// provided Sample Rate.
func Nyquest(sampleRate uint) rf.Hz {
return rf.Hz(sampleRate) / 2
}

// BinsByRange will return the bins that contain frequencies bounded by the
// range 'rng'.
func BinsByRange(frequencyLen int, sampleRate uint, order Order, rng rf.Range) ([]int, error) {
nyquest := Nyquest(sampleRate)
if rng[1] > nyquest || rng[1] < -nyquest {
Expand Down Expand Up @@ -172,6 +176,8 @@ func BinsByRange(frequencyLen int, sampleRate uint, order Order, rng rf.Range) (
return ret, nil
}

// FreqByBin will return the center frequency of the provided fft bin, provided
// with information on the fft size, sample rate and bin layout.
func FreqByBin(frequencyLen int, sampleRate uint, order Order, bin int) (rf.Hz, error) {
if bin < 0 || bin > frequencyLen {
return rf.Hz(0), ErrFrequencyOutOfSamplingRange
Expand Down

0 comments on commit 9809d57

Please sign in to comment.