File tree 14 files changed +29
-23
lines changed
14 files changed +29
-23
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ package sound
5
5
6
6
import "errors"
7
7
8
- // ChannelAlignmentError is returned by sources and sinks
8
+ // ErrChannelAlignment is returned by sources and sinks
9
9
// when the input/output slices aren't sized correctly
10
10
// with respect to the number of channels
11
11
// in the sink/source. More concretely this error is returned
@@ -17,4 +17,4 @@ import "errors"
17
17
//
18
18
// Because the buffers d don't contain a number of samples representing
19
19
// 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" )
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ func (t *T) Len() int {
66
66
// for each channel.
67
67
//
68
68
// 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
70
70
//
71
71
// raw's frame count may differ from that given in the constructor.
72
72
//
@@ -76,7 +76,7 @@ func (t *T) Inter(raw []float64) error {
76
76
}
77
77
N := len (raw )
78
78
if N % t .c != 0 {
79
- return sound .ChannelAlignmentError
79
+ return sound .ErrChannelAlignment
80
80
}
81
81
orgF := t .f
82
82
defer t .SetFrames (orgF )
@@ -107,15 +107,15 @@ func (t *T) Inter(raw []float64) error {
107
107
//
108
108
// raw's frame count may differ from that given in t's constructor.
109
109
//
110
- // Deinter returns a sound.ChannelAlignmentError if len(raw)%nC != 0
110
+ // Deinter returns a sound.ErrChannelAlignment if len(raw)%nC != 0
111
111
// where nC is the number of channels given in the constructor.
112
112
func (t * T ) Deinter (raw []float64 ) error {
113
113
if t .c == 1 {
114
114
return nil
115
115
}
116
116
N := len (raw )
117
117
if N % t .c != 0 {
118
- return sound .ChannelAlignmentError
118
+ return sound .ErrChannelAlignment
119
119
}
120
120
orgF := t .f
121
121
defer t .SetFrames (orgF )
Original file line number Diff line number Diff line change @@ -16,11 +16,11 @@ type Duplex interface {
16
16
// SendReceive on a duplex connection will play out
17
17
// and capture to in.
18
18
//
19
- // SendReceive returns a ChannelAlignmentError if
19
+ // SendReceive returns a ErrChannelAlignment if
20
20
// len(in) is not a multiple of InChannels() and also
21
21
// if len(out) is not a multiple of OutChannels().
22
22
//
23
- // SendReceive returns a FrameAlignmentError if
23
+ // SendReceive returns a ErrFrameAlignment if
24
24
// the number of frames in out is not equal to the number
25
25
// of frames in in.
26
26
//
@@ -34,4 +34,4 @@ type Duplex interface {
34
34
}
35
35
36
36
// See Duplex.SendReceive
37
- var FrameAlignmentError = errors .New ("duplex frames misaligned." )
37
+ var ErrFrameAlignment = errors .New ("duplex frames misaligned." )
Original file line number Diff line number Diff line change 1
1
// Copyright 2018 The ZikiChombo Authors. All rights reserved. Use of this source
2
2
// code is governed by a license that can be found in the License file.
3
3
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".
4
11
package gen_test
5
12
6
13
import (
@@ -18,7 +25,6 @@ func TestNote(t *testing.T) {
18
25
if e := wav .Save (a , "a3.wav" ); e != nil {
19
26
t .Fatal (e )
20
27
}
21
-
22
28
}
23
29
24
30
func TestNotes (t * testing.T ) {
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ func (a *sAdd) Receive(dst []float64) (int, error) {
60
60
frms = n
61
61
}
62
62
if frms != n {
63
- return 0 , sound .ChannelAlignmentError
63
+ return 0 , sound .ErrChannelAlignment
64
64
}
65
65
for i := 0 ; i < nC * frms ; i ++ {
66
66
dst [i ] += a .buf [i ]
@@ -114,7 +114,7 @@ func (m *sMul) Receive(dst []float64) (int, error) {
114
114
frms = n
115
115
}
116
116
if frms != n {
117
- return 0 , sound .ChannelAlignmentError
117
+ return 0 , sound .ErrChannelAlignment
118
118
}
119
119
for i := 0 ; i < nC * frms ; i ++ {
120
120
dst [i ] *= m .buf [i ]
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ func (d *decimate) wFrames(f int) int {
49
49
func (d * decimate ) Receive (dst []float64 ) (int , error ) {
50
50
nC := d .Channels ()
51
51
if len (dst )% nC != 0 {
52
- return 0 , sound .ChannelAlignmentError
52
+ return 0 , sound .ErrChannelAlignment
53
53
}
54
54
nF := len (dst ) / nC
55
55
rF := d .rFrames (nF )
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ type eSrc struct {
82
82
func (e * eSrc ) Receive (dst []float64 ) (int , error ) {
83
83
nC := e .Source .Channels ()
84
84
if len (dst )% nC != 0 {
85
- return 0 , sound .ChannelAlignmentError
85
+ return 0 , sound .ErrChannelAlignment
86
86
}
87
87
n , err := e .Source .Receive (dst )
88
88
if err != nil {
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ func (j *join) Channels() int {
25
25
26
26
func (j * join ) Receive (dst []float64 ) (int , error ) {
27
27
if len (dst )% len (j .srcs ) != 0 {
28
- return 0 , sound .ChannelAlignmentError
28
+ return 0 , sound .ErrChannelAlignment
29
29
}
30
30
n := len (dst ) / len (j .srcs )
31
31
nf := - 1
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ type loop struct {
19
19
func (l * loop ) Receive (dst []float64 ) (int , error ) {
20
20
nC := l .Channels ()
21
21
if len (dst )% nC != 0 {
22
- return 0 , sound .ChannelAlignmentError
22
+ return 0 , sound .ErrChannelAlignment
23
23
}
24
24
if l .n == 0 {
25
25
return 0 , io .EOF
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ type up struct {
18
18
func (u * up ) Receive (dst []float64 ) (int , error ) {
19
19
nC := u .Channels ()
20
20
if len (dst )% nC != 0 {
21
- return 0 , sound .ChannelAlignmentError
21
+ return 0 , sound .ErrChannelAlignment
22
22
}
23
23
nF := len (dst ) / nC
24
24
rnF := (nF - u .i ) / u .n
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ type packet struct {
38
38
func (p * pipe ) Send (d []float64 ) error {
39
39
nC := p .Channels ()
40
40
if len (d )% nC != 0 {
41
- return ChannelAlignmentError
41
+ return ErrChannelAlignment
42
42
}
43
43
trgFrms := len (d ) / nC
44
44
pkt := & packet {sl : d }
@@ -70,7 +70,7 @@ func (p *pipe) Close() error {
70
70
func (p * pipe ) Receive (dst []float64 ) (int , error ) {
71
71
nC := p .Channels ()
72
72
if len (dst )% nC != 0 {
73
- return 0 , ChannelAlignmentError
73
+ return 0 , ErrChannelAlignment
74
74
}
75
75
dPkt := & packet {sl : dst , n : 0 }
76
76
inFrms := len (dst ) / nC
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ type Sink interface {
14
14
//
15
15
// len(d) must be a multiple of the number of channels
16
16
// associated with the Sink, or Send will return a
17
- // ChannelAlignmentError .
17
+ // ErrChannelAlignment .
18
18
//
19
19
// In case the Sink is multi-channel, d is interpreted in
20
20
// channel-deinterleaved format.
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ func (b *T) Channels() int {
122
122
// data in dst.
123
123
func (b * T ) Receive (dst []float64 ) (int , error ) {
124
124
if len (dst )% b .nchan != 0 {
125
- return 0 , sound .ChannelAlignmentError
125
+ return 0 , sound .ErrChannelAlignment
126
126
}
127
127
128
128
n := len (dst )
@@ -154,7 +154,7 @@ func (b *T) Receive(dst []float64) (int, error) {
154
154
// and placing it in the memory buffer.
155
155
func (b * T ) Send (d []float64 ) error {
156
156
if len (d )% b .nchan != 0 {
157
- return sound .ChannelAlignmentError
157
+ return sound .ErrChannelAlignment
158
158
}
159
159
160
160
frms := len (d ) / b .nchan
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ type Source interface {
19
19
//
20
20
// Receive returns multi-channel data in de-interleaved format.
21
21
// 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()
23
23
// frames, then the deinterleaved data of n frames is arranged in
24
24
// the prefix d[:n*Channels()].
25
25
Receive (d []float64 ) (int , error )
You can’t perform that action at this time.
0 commit comments