func (enc *Encoder) SetInBandFEC(fec bool) error {
	i := 0
	if fec {
		i = 1
	}
	res := C.bridge_encoder_set_inband_fec(enc.p, C.opus_int32(i))
	if res != C.OPUS_OK {
		return Error(res)
	}
	return nil
}
SetInBandFEC configures the encoder's use of inband forward error
correction (FEC)
package opus
import (
	"fmt"
	"unsafe"
)
import "C"
type Bandwidth int
const (
	Narrowband = Bandwidth(C.OPUS_BANDWIDTH_NARROWBAND)
	Mediumband = Bandwidth(C.OPUS_BANDWIDTH_MEDIUMBAND)
	Wideband = Bandwidth(C.OPUS_BANDWIDTH_WIDEBAND)
	SuperWideband = Bandwidth(C.OPUS_BANDWIDTH_SUPERWIDEBAND)
	Fullband = Bandwidth(C.OPUS_BANDWIDTH_FULLBAND)
)
var errEncUninitialized = fmt.Errorf("opus encoder uninitialized")
type Encoder struct {
	p        *C.struct_OpusEncoder
	channels int
	mem []byte
}
func NewEncoder(sample_rate int, channels int, application Application) (*Encoder, error) {
	var enc Encoder
	err := enc.Init(sample_rate, channels, application)
	if err != nil {
		return nil, err
	}
	return &enc, nil
}
func (enc *Encoder) Init(sample_rate int, channels int, application Application) error {
	if enc.p != nil {
		return fmt.Errorf("opus encoder already initialized")
	}
	if channels != 1 && channels != 2 {
		return fmt.Errorf("Number of channels must be 1 or 2: %d", channels)
	}
	size := C.opus_encoder_get_size(C.int(channels))
	enc.channels = channels
	enc.mem = make([]byte, size)
	enc.p = (*C.OpusEncoder)(unsafe.Pointer(&enc.mem[0]))
	errno := int(C.opus_encoder_init(
		enc.p,
		C.opus_int32(sample_rate),
		C.int(channels),
		C.int(application)))
	if errno != 0 {
		return Error(int(errno))
	}
	return nil
}
func (enc *Encoder) Encode(pcm []int16, data []byte) (int, error) {
	if enc.p == nil {
		return 0, errEncUninitialized
	}
	if len(pcm) == 0 {
		return 0, fmt.Errorf("opus: no data supplied")
	}
	if len(data) == 0 {
		return 0, fmt.Errorf("opus: no target buffer")
	}
	if len(pcm)%enc.channels != 0 {
		return 0, fmt.Errorf("opus: input buffer length must be multiple of channels")
	}
	samples := len(pcm) / enc.channels
	n := int(C.opus_encode(
		enc.p,
		(*C.opus_int16)(&pcm[0]),
		C.int(samples),
		(*C.uchar)(&data[0]),
		C.opus_int32(cap(data))))
	if n < 0 {
		return 0, Error(n)
	}
	return n, nil
}
func (enc *Encoder) EncodeFloat32(pcm []float32, data []byte) (int, error) {
	if enc.p == nil {
		return 0, errEncUninitialized
	}
	if len(pcm) == 0 {
		return 0, fmt.Errorf("opus: no data supplied")
	}
	if len(data) == 0 {
		return 0, fmt.Errorf("opus: no target buffer")
	}
	if len(pcm)%enc.channels != 0 {
		return 0, fmt.Errorf("opus: input buffer length must be multiple of channels")
	}
	samples := len(pcm) / enc.channels
	n := int(C.opus_encode_float(
		enc.p,
		(*C.float)(&pcm[0]),
		C.int(samples),
		(*C.uchar)(&data[0]),
		C.opus_int32(cap(data))))
	if n < 0 {
		return 0, Error(n)
	}
	return n, nil
}
func (enc *Encoder) SetDTX(dtx bool) error {
	i := 0
	if dtx {
		i = 1
	}
	res := C.bridge_encoder_set_dtx(enc.p, C.opus_int32(i))
	if res != C.OPUS_OK {
		return Error(res)
	}
	return nil
}
func (enc *Encoder) DTX() (bool, error) {
	var dtx C.opus_int32
	res := C.bridge_encoder_get_dtx(enc.p, &dtx)
	if res != C.OPUS_OK {
		return false, Error(res)
	}
	return dtx != 0, nil
}
func (enc *Encoder) SampleRate() (int, error) {
	var sr C.opus_int32
	res := C.bridge_encoder_get_sample_rate(enc.p, &sr)
	if res != C.OPUS_OK {
		return 0, Error(res)
	}
	return int(sr), nil
}
func (enc *Encoder) SetBitrate(bitrate int) error {
	res := C.bridge_encoder_set_bitrate(enc.p, C.opus_int32(bitrate))
	if res != C.OPUS_OK {
		return Error(res)
	}
	return nil
}
func (enc *Encoder) SetBitrateToAuto() error {
	res := C.bridge_encoder_set_bitrate(enc.p, C.opus_int32(C.OPUS_AUTO))
	if res != C.OPUS_OK {
		return Error(res)
	}
	return nil
}
func (enc *Encoder) SetBitrateToMax() error {
	res := C.bridge_encoder_set_bitrate(enc.p, C.opus_int32(C.OPUS_BITRATE_MAX))
	if res != C.OPUS_OK {
		return Error(res)
	}
	return nil
}
func (enc *Encoder) Bitrate() (int, error) {
	var bitrate C.opus_int32
	res := C.bridge_encoder_get_bitrate(enc.p, &bitrate)
	if res != C.OPUS_OK {
		return 0, Error(res)
	}
	return int(bitrate), nil
}
func (enc *Encoder) SetComplexity(complexity int) error {
	res := C.bridge_encoder_set_complexity(enc.p, C.opus_int32(complexity))
	if res != C.OPUS_OK {
		return Error(res)
	}
	return nil
}
func (enc *Encoder) Complexity() (int, error) {
	var complexity C.opus_int32
	res := C.bridge_encoder_get_complexity(enc.p, &complexity)
	if res != C.OPUS_OK {
		return 0, Error(res)
	}
	return int(complexity), nil
}
func (enc *Encoder) SetMaxBandwidth(maxBw Bandwidth) error {
	res := C.bridge_encoder_set_max_bandwidth(enc.p, C.opus_int32(maxBw))
	if res != C.OPUS_OK {
		return Error(res)
	}
	return nil
}
func (enc *Encoder) MaxBandwidth() (Bandwidth, error) {
	var maxBw C.opus_int32
	res := C.bridge_encoder_get_max_bandwidth(enc.p, &maxBw)
	if res != C.OPUS_OK {
		return 0, Error(res)
	}
	return Bandwidth(maxBw), nil
}