Skip to content

Commit 9b9c9f0

Browse files
committed
make windowing the data optional
1 parent f223866 commit 9b9c9f0

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

cmd/catnip/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"sync"
88

99
"github.com/noriah/catnip/dsp"
10+
"github.com/noriah/catnip/dsp/window"
1011
"github.com/noriah/catnip/graphic"
1112
"github.com/noriah/catnip/input"
1213
"github.com/noriah/catnip/processor"
@@ -62,11 +63,12 @@ func catnip(cfg *config) error {
6263
SampleRate: cfg.sampleRate,
6364
SampleSize: cfg.sampleSize,
6465
}),
66+
Output: display,
6567
Smoother: dsp.NewSmoother(dsp.SmootherConfig{
6668
SampleSize: cfg.sampleSize,
6769
ChannelCount: cfg.channelCount,
6870
SmoothingFactor: cfg.smoothFactor}),
69-
Output: display,
71+
Windower: window.Lanczos,
7072
}
7173

7274
var vis processor.Processor

processor/processor.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ type Config struct {
3838
FrameRate int // target framerate
3939
Buffers [][]input.Sample // sample buffers
4040
Analyzer Analyzer // audio analyzer
41-
Smoother Smoother // time smoother
4241
Output Output // data output
42+
Smoother Smoother // time smoother
43+
Windower window.Function // data windower
4344
}
4445

4546
type processor struct {
@@ -57,9 +58,10 @@ type processor struct {
5758

5859
plans []*fft.Plan
5960

60-
anlz Analyzer
61-
smth Smoother
62-
out Output
61+
anlz Analyzer
62+
out Output
63+
smth Smoother
64+
wndwr window.Function
6365
}
6466

6567
func New(cfg Config) *processor {
@@ -72,8 +74,9 @@ func New(cfg Config) *processor {
7274
inputBufs: cfg.Buffers,
7375
plans: make([]*fft.Plan, cfg.ChannelCount),
7476
anlz: cfg.Analyzer,
75-
smth: cfg.Smoother,
7677
out: cfg.Output,
78+
smth: cfg.Smoother,
79+
wndwr: cfg.Windower,
7780
}
7881

7982
for idx := range vis.barBufs {
@@ -108,7 +111,9 @@ func (vis *processor) Process(ctx context.Context, kickChan chan bool, mu *sync.
108111
for {
109112
mu.Lock()
110113
for idx := range vis.barBufs {
111-
window.Lanczos(vis.inputBufs[idx])
114+
if vis.wndwr != nil {
115+
vis.wndwr(vis.inputBufs[idx])
116+
}
112117
vis.plans[idx].Execute()
113118
}
114119
mu.Unlock()

0 commit comments

Comments
 (0)