Skip to content

Commit ee625b4

Browse files
authored
Cleanup (#12)
* use build tag listen for tests involving listening test infrastructure for listening isn't automatable by definition. this commit places sound/gen/gen_test under build tag listen, because it generates wavs for listening. This also cleans up some modules madness where somehow sound ended up indirectly depending on an earlier version of itself due to the fact that codec module depends on sound. * ChannelAlignmentError -> ErrChannelAlignment
1 parent f39ffae commit ee625b4

File tree

14 files changed

+29
-23
lines changed

14 files changed

+29
-23
lines changed

Diff for: cae.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package sound
55

66
import "errors"
77

8-
// ChannelAlignmentError is returned by sources and sinks
8+
// ErrChannelAlignment is returned by sources and sinks
99
// when the input/output slices aren't sized correctly
1010
// with respect to the number of channels
1111
// in the sink/source. More concretely this error is returned
@@ -17,4 +17,4 @@ import "errors"
1717
//
1818
// Because the buffers d don't contain a number of samples representing
1919
// one sample for all channels for all represented points in time.
20-
var ChannelAlignmentError = errors.New("Channels misaligned")
20+
var ErrChannelAlignment = errors.New("Channels misaligned")

Diff for: cil/t.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (t *T) Len() int {
6666
// for each channel.
6767
//
6868
// If len(raw) is not a multiple of the number of channels expected by t
69-
// (specified in the constructor), then Inter returns sound.ChannelAlignmentError.
69+
// (specified in the constructor), then Inter returns sound.ErrChannelAlignment
7070
//
7171
// raw's frame count may differ from that given in the constructor.
7272
//
@@ -76,7 +76,7 @@ func (t *T) Inter(raw []float64) error {
7676
}
7777
N := len(raw)
7878
if N%t.c != 0 {
79-
return sound.ChannelAlignmentError
79+
return sound.ErrChannelAlignment
8080
}
8181
orgF := t.f
8282
defer t.SetFrames(orgF)
@@ -107,15 +107,15 @@ func (t *T) Inter(raw []float64) error {
107107
//
108108
// raw's frame count may differ from that given in t's constructor.
109109
//
110-
// Deinter returns a sound.ChannelAlignmentError if len(raw)%nC != 0
110+
// Deinter returns a sound.ErrChannelAlignment if len(raw)%nC != 0
111111
// where nC is the number of channels given in the constructor.
112112
func (t *T) Deinter(raw []float64) error {
113113
if t.c == 1 {
114114
return nil
115115
}
116116
N := len(raw)
117117
if N%t.c != 0 {
118-
return sound.ChannelAlignmentError
118+
return sound.ErrChannelAlignment
119119
}
120120
orgF := t.f
121121
defer t.SetFrames(orgF)

Diff for: duplex.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ type Duplex interface {
1616
// SendReceive on a duplex connection will play out
1717
// and capture to in.
1818
//
19-
// SendReceive returns a ChannelAlignmentError if
19+
// SendReceive returns a ErrChannelAlignment if
2020
// len(in) is not a multiple of InChannels() and also
2121
// if len(out) is not a multiple of OutChannels().
2222
//
23-
// SendReceive returns a FrameAlignmentError if
23+
// SendReceive returns a ErrFrameAlignment if
2424
// the number of frames in out is not equal to the number
2525
// of frames in in.
2626
//
@@ -34,4 +34,4 @@ type Duplex interface {
3434
}
3535

3636
// See Duplex.SendReceive
37-
var FrameAlignmentError = errors.New("duplex frames misaligned.")
37+
var ErrFrameAlignment = errors.New("duplex frames misaligned.")

Diff for: gen/gen_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
// Copyright 2018 The ZikiChombo Authors. All rights reserved. Use of this source
22
// code is governed by a license that can be found in the License file.
33

4+
// +build listen
5+
6+
// this package introduces a dependency on the codec module, which
7+
// makes things confusing. It also doesn't really test anything
8+
// but rather just creates wav files for listening tests.
9+
//
10+
// so we've made it ignored by default with the build tag "listen".
411
package gen_test
512

613
import (
@@ -18,7 +25,6 @@ func TestNote(t *testing.T) {
1825
if e := wav.Save(a, "a3.wav"); e != nil {
1926
t.Fatal(e)
2027
}
21-
2228
}
2329

2430
func TestNotes(t *testing.T) {

Diff for: ops/add.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (a *sAdd) Receive(dst []float64) (int, error) {
6060
frms = n
6161
}
6262
if frms != n {
63-
return 0, sound.ChannelAlignmentError
63+
return 0, sound.ErrChannelAlignment
6464
}
6565
for i := 0; i < nC*frms; i++ {
6666
dst[i] += a.buf[i]
@@ -114,7 +114,7 @@ func (m *sMul) Receive(dst []float64) (int, error) {
114114
frms = n
115115
}
116116
if frms != n {
117-
return 0, sound.ChannelAlignmentError
117+
return 0, sound.ErrChannelAlignment
118118
}
119119
for i := 0; i < nC*frms; i++ {
120120
dst[i] *= m.buf[i]

Diff for: ops/dec.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (d *decimate) wFrames(f int) int {
4949
func (d *decimate) Receive(dst []float64) (int, error) {
5050
nC := d.Channels()
5151
if len(dst)%nC != 0 {
52-
return 0, sound.ChannelAlignmentError
52+
return 0, sound.ErrChannelAlignment
5353
}
5454
nF := len(dst) / nC
5555
rF := d.rFrames(nF)

Diff for: ops/env.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ type eSrc struct {
8282
func (e *eSrc) Receive(dst []float64) (int, error) {
8383
nC := e.Source.Channels()
8484
if len(dst)%nC != 0 {
85-
return 0, sound.ChannelAlignmentError
85+
return 0, sound.ErrChannelAlignment
8686
}
8787
n, err := e.Source.Receive(dst)
8888
if err != nil {

Diff for: ops/join.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (j *join) Channels() int {
2525

2626
func (j *join) Receive(dst []float64) (int, error) {
2727
if len(dst)%len(j.srcs) != 0 {
28-
return 0, sound.ChannelAlignmentError
28+
return 0, sound.ErrChannelAlignment
2929
}
3030
n := len(dst) / len(j.srcs)
3131
nf := -1

Diff for: ops/loop.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type loop struct {
1919
func (l *loop) Receive(dst []float64) (int, error) {
2020
nC := l.Channels()
2121
if len(dst)%nC != 0 {
22-
return 0, sound.ChannelAlignmentError
22+
return 0, sound.ErrChannelAlignment
2323
}
2424
if l.n == 0 {
2525
return 0, io.EOF

Diff for: ops/up.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type up struct {
1818
func (u *up) Receive(dst []float64) (int, error) {
1919
nC := u.Channels()
2020
if len(dst)%nC != 0 {
21-
return 0, sound.ChannelAlignmentError
21+
return 0, sound.ErrChannelAlignment
2222
}
2323
nF := len(dst) / nC
2424
rnF := (nF - u.i) / u.n

Diff for: pipe.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type packet struct {
3838
func (p *pipe) Send(d []float64) error {
3939
nC := p.Channels()
4040
if len(d)%nC != 0 {
41-
return ChannelAlignmentError
41+
return ErrChannelAlignment
4242
}
4343
trgFrms := len(d) / nC
4444
pkt := &packet{sl: d}
@@ -70,7 +70,7 @@ func (p *pipe) Close() error {
7070
func (p *pipe) Receive(dst []float64) (int, error) {
7171
nC := p.Channels()
7272
if len(dst)%nC != 0 {
73-
return 0, ChannelAlignmentError
73+
return 0, ErrChannelAlignment
7474
}
7575
dPkt := &packet{sl: dst, n: 0}
7676
inFrms := len(dst) / nC

Diff for: sink.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type Sink interface {
1414
//
1515
// len(d) must be a multiple of the number of channels
1616
// associated with the Sink, or Send will return a
17-
// ChannelAlignmentError.
17+
// ErrChannelAlignment.
1818
//
1919
// In case the Sink is multi-channel, d is interpreted in
2020
// channel-deinterleaved format.

Diff for: sndbuf/buf.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (b *T) Channels() int {
122122
// data in dst.
123123
func (b *T) Receive(dst []float64) (int, error) {
124124
if len(dst)%b.nchan != 0 {
125-
return 0, sound.ChannelAlignmentError
125+
return 0, sound.ErrChannelAlignment
126126
}
127127

128128
n := len(dst)
@@ -154,7 +154,7 @@ func (b *T) Receive(dst []float64) (int, error) {
154154
// and placing it in the memory buffer.
155155
func (b *T) Send(d []float64) error {
156156
if len(d)%b.nchan != 0 {
157-
return sound.ChannelAlignmentError
157+
return sound.ErrChannelAlignment
158158
}
159159

160160
frms := len(d) / b.nchan

Diff for: source.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type Source interface {
1919
//
2020
// Receive returns multi-channel data in de-interleaved format.
2121
// If len(d) is not a multiple of Channels(), then Receive returns
22-
// ChannelAlignmentError. If Receive returns fewer than len(d)/Channels()
22+
// ErrChannelAlignment. If Receive returns fewer than len(d)/Channels()
2323
// frames, then the deinterleaved data of n frames is arranged in
2424
// the prefix d[:n*Channels()].
2525
Receive(d []float64) (int, error)

0 commit comments

Comments
 (0)