forked from zikichombo/sound
-
Notifications
You must be signed in to change notification settings - Fork 0
/
duplex.go
37 lines (32 loc) · 1.09 KB
/
duplex.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2018 The ZikiChombo Authors. All rights reserved. Use of this source
// code is governed by a license that can be found in the License file.
package sound
import "errors"
// Duplex is an interface for full duplex sound I/O.
type Duplex interface {
// NB: channels returns InChannels() + OutChannels()
Form
Closer
InChannels() int
OutChannels() int
// SendReceive on a duplex connection will play out
// and capture to in.
//
// SendReceive returns a ErrChannelAlignment if
// len(in) is not a multiple of InChannels() and also
// if len(out) is not a multiple of OutChannels().
//
// SendReceive returns a ErrFrameAlignment if
// the number of frames in out is not equal to the number
// of frames in in.
//
// SendReceive returns the number of frames of input, n.
// n == 0 iff error != nil
// if n < len(in)/InChannels() then only the first
// n frames of out are sent and subsequent calls to
// SendReceive will return 0, io.EOF.
//
SendReceive(out, in []float64) (int, error)
}
// See Duplex.SendReceive
var ErrFrameAlignment = errors.New("duplex frames misaligned.")