Skip to content

Commit 41f7b4d

Browse files
committed
now for more
1 parent 1ad2342 commit 41f7b4d

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@ tavis
55
[![made-with-go][withgo]][go-dev]
66
[![betamax-was-a-thing][betamax]][betawhat]
77

8-
### terminal audio visualizer for linux/unix/macOS/windows*
9-
*windows needs work
8+
> terminal audio visualizer for linux/unix/macOS/windows*
9+
10+
<p align="center">
11+
<a href="https://www.youtube.com/watch?v=NGtCoEsgJww" target="_blank">
12+
<img src="../media/preview0.gif?raw=true"/>
13+
</a>
14+
</p>
1015

1116
## early development - expect things to change and break
1217

1318
we are working on this project all the time. its a sort of time filler for us at this point. expect lots of additions and changes at random times.
1419

20+
*windows needs work
21+
1522
## supported audio backends
1623
- PortAudio (linux/macOS/*windblows**)
1724
- PulseAudio (parec/FFmpeg)
@@ -88,7 +95,9 @@ COMMANDS:
8895
[go-dev]: https://go.dev
8996
[betawhat]: https://google.com/search?q=betamax
9097

98+
9199
<!-- Images -->
92100
[withlove]: https://forthebadge.com/images/badges/built-with-love.svg
93101
[withgo]: https://forthebadge.com/images/badges/made-with-go.svg
94102
[betamax]: https://forthebadge.com/images/badges/compatibility-betamax.svg
103+

dsp/spectrum.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (sp *Spectrum) Process(win window.Function) {
133133

134134
sf = math.Pow(sf, float64(sp.sampleSize)/sp.sampleRate)
135135

136-
var bassCut = sp.freqToIdx(Frequencies[2], math.Round)
136+
var bassCut = sp.freqToIdx(Frequencies[2], math.Ceil)
137137
var fBassCut = float64(bassCut)
138138

139139
for _, stream := range sp.streams {
@@ -233,11 +233,14 @@ func (sp *Spectrum) distributeLog(bins int) {
233233
var lo = (Frequencies[1])
234234
var hi = Frequencies[4]
235235

236-
var cF = math.Log10(lo/hi) / ((1 / float64(bins)) - 1)
236+
var loLog = math.Log10(lo)
237+
var hiLog = math.Log10(hi)
238+
239+
var cF = (hiLog - loLog) / float64(bins)
237240

238241
var getBinBase = func(b int) int {
239-
var vFreq = ((float64(b) / float64(bins)) * cF) - cF
240-
vFreq = math.Pow(10.0, vFreq) * hi
242+
var vFreq = ((float64(b) * cF) + loLog)
243+
vFreq = math.Pow(10.0, vFreq)
241244
return sp.freqToIdx(vFreq, math.Floor)
242245
}
243246

@@ -262,7 +265,7 @@ func (sp *Spectrum) distributeEqual(bins int) {
262265
var loF = Frequencies[0]
263266
var hiF = math.Min(Frequencies[4], sp.sampleRate/2)
264267
var minIdx = sp.freqToIdx(loF, math.Floor)
265-
var maxIdx = sp.freqToIdx(hiF, math.Ceil)
268+
var maxIdx = sp.freqToIdx(hiF, math.Round)
266269

267270
var size = maxIdx - minIdx
268271

0 commit comments

Comments
 (0)