From 0d0b7523dfa30f494ea0fb9952331eb69506f599 Mon Sep 17 00:00:00 2001
From: "Paul R. Tagliamonte" <paultag@gmail.com>
Date: Fri, 26 May 2023 14:59:46 -0400
Subject: [PATCH] Add in revive; fix lint nits.

---
 Makefile        |  2 +-
 doc.go          | 25 +++++++++++++++++++++++++
 go.mod          |  5 ++---
 go.sum          | 22 ++++------------------
 internal/doc.go | 24 ++++++++++++++++++++++++
 modulator.go    |  8 ++++----
 6 files changed, 60 insertions(+), 26 deletions(-)
 create mode 100644 doc.go
 create mode 100644 internal/doc.go

diff --git a/Makefile b/Makefile
index 94d358f..dc6b00e 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ check: lint
 clean:
 
 lint:
-	golint ./...
+	revive ./...
 
 .PHONY: all lint check
 
diff --git a/doc.go b/doc.go
new file mode 100644
index 0000000..6201f56
--- /dev/null
+++ b/doc.go
@@ -0,0 +1,25 @@
+// {{{ Copyright (c) Paul R. Tagliamonte <paul@k3xec.com>, 2023
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE. }}}
+
+// Package fm contains a modulator and demodulator for FM encoded audio
+// streams.
+package fm
+
+// vim: foldmethod=marker
diff --git a/go.mod b/go.mod
index 4910056..82e70cf 100644
--- a/go.mod
+++ b/go.mod
@@ -1,9 +1,8 @@
 module hz.tools/fm
 
-go 1.15
+go 1.19
 
 require (
-	hz.tools/fftw v0.0.7
 	hz.tools/rf v0.0.7
-	hz.tools/sdr v0.0.0-20230503011412-b2c83a55e116
+	hz.tools/sdr v0.0.0-20230515012122-9809d5729f37
 )
diff --git a/go.sum b/go.sum
index ce4e0fe..5ea2ae8 100644
--- a/go.sum
+++ b/go.sum
@@ -1,36 +1,22 @@
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0=
 github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
 github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
-github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
+github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
 github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
 gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-hz.tools/fftw v0.0.6 h1:xuS3rHGxX62hutbbB8bU/D3tqxI8ZjsiJuq7zGpjnsU=
-hz.tools/fftw v0.0.6/go.mod h1:0VJKzw9OFm8jLzub4lv1qeGORSbGkI2ePZyNQoq2NCk=
-hz.tools/fftw v0.0.7 h1:dlGrDyplXQH1MxFY318zTZUSjmFaP1Yi8Oy7U2E/mak=
-hz.tools/fftw v0.0.7/go.mod h1:OD9JWxQJ+uBUDq7amio/juU94OgDTN6LQFATdaGv+Qg=
 hz.tools/rf v0.0.7 h1:jzIP+Q9We0B1lEZgQp7VTVAPtO/yuTwhNRxkCG/lWOg=
 hz.tools/rf v0.0.7/go.mod h1:wTwZ2xbRvTgaa5S7y34NPMg3YY5hYTlhpBbPlWYcMSE=
-hz.tools/sdr v0.0.0-20210302051927-c160b34a77ff/go.mod h1:e2HpOZNGv+DJCV9QxTwT/1vi+KoyX996WN3wx46WnB8=
-hz.tools/sdr v0.0.0-20210310010859-bcc7d6233524 h1:djy5y3XAX5YuxVEXE32RLcWLkxZoBRix2fVlk4mZ2Dc=
-hz.tools/sdr v0.0.0-20210310010859-bcc7d6233524/go.mod h1:YX83xRT5DRUT/ue1zeiCfEJhiEP23m83RSdSg1IotxU=
-hz.tools/sdr v0.0.0-20210312011121-a229cbc80266/go.mod h1:YX83xRT5DRUT/ue1zeiCfEJhiEP23m83RSdSg1IotxU=
-hz.tools/sdr v0.0.0-20210724143717-d5d8ec0435a8 h1:A1P8h+FwwH8YLaoCHZ04GzJaCMThvWHhZzzXBuxGcto=
-hz.tools/sdr v0.0.0-20210724143717-d5d8ec0435a8/go.mod h1:YX83xRT5DRUT/ue1zeiCfEJhiEP23m83RSdSg1IotxU=
-hz.tools/sdr v0.0.0-20230503011412-b2c83a55e116 h1:yBvN2Nz6hx5Roc0xWhlb88sGR5TSUgC0PALC9tJcCxA=
-hz.tools/sdr v0.0.0-20230503011412-b2c83a55e116/go.mod h1:+Ij3O1U19gJdoVV9HfY185w6ttLfsbfiaQGm5ap5FCU=
+hz.tools/sdr v0.0.0-20230515012122-9809d5729f37 h1:O1lk2DqOK9FCAeRqp1qRS4b3yWyzQrvTLH5EaXNMGks=
+hz.tools/sdr v0.0.0-20230515012122-9809d5729f37/go.mod h1:+Ij3O1U19gJdoVV9HfY185w6ttLfsbfiaQGm5ap5FCU=
diff --git a/internal/doc.go b/internal/doc.go
new file mode 100644
index 0000000..693388e
--- /dev/null
+++ b/internal/doc.go
@@ -0,0 +1,24 @@
+// {{{ Copyright (c) Paul R. Tagliamonte <paul@k3xec.com>, 2023
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE. }}}
+
+// Package internal contains package local helpers.
+package internal
+
+// vim: foldmethod=marker
diff --git a/modulator.go b/modulator.go
index bce1895..d46585a 100644
--- a/modulator.go
+++ b/modulator.go
@@ -116,7 +116,7 @@ func (m *Modulator) SampleRate() uint {
 func (m *Modulator) Write(audioSamples []float32) (int, error) {
 	iqBufLen := len(m.iqBuffer) / int(m.Config.IqSamplesPerAudioSample)
 
-	var fn int = 0
+	var fn int
 	for i := 0; i < len(audioSamples); i += iqBufLen {
 		audioEnd := i + iqBufLen
 		if audioEnd > len(audioSamples) {
@@ -156,9 +156,9 @@ func (m *Modulator) write(audioSamples []float32) (int, error) {
 
 		for iqStep := iqStepStart; iqStep < iqStepEnd; iqStep++ {
 			var (
-				now        float64 = timeOffset / float64(m.iqSampleRate)
-				realSample float64 = math.Cos(tau*float64(m.Config.CarrierFrequency)*now + beta*audioSample)
-				imagSample float64 = math.Sin(tau*float64(m.Config.CarrierFrequency)*now + beta*audioSample)
+				now        = timeOffset / float64(m.iqSampleRate)
+				realSample = math.Cos(tau*float64(m.Config.CarrierFrequency)*now + beta*audioSample)
+				imagSample = math.Sin(tau*float64(m.Config.CarrierFrequency)*now + beta*audioSample)
 			)
 			m.iqBuffer[iqStep] = complex(float32(realSample), float32(imagSample))
 			timeOffset = (timeOffset + 1)