Skip to content

Commit

Permalink
Add in revive; fix lint nits.
Browse files Browse the repository at this point in the history
  • Loading branch information
paultag committed May 26, 2023
1 parent 460fc81 commit 0d0b752
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ check: lint
clean:

lint:
golint ./...
revive ./...

.PHONY: all lint check

Expand Down
25 changes: 25 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// {{{ Copyright (c) Paul R. Tagliamonte <[email protected]>, 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
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
)
22 changes: 4 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
24 changes: 24 additions & 0 deletions internal/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// {{{ Copyright (c) Paul R. Tagliamonte <[email protected]>, 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
8 changes: 4 additions & 4 deletions modulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0d0b752

Please sign in to comment.