Documentation ¶
Overview ¶
go wrapper for c opus library. All c functions have a 'w' prefix (wrapper function)
Index ¶
Constants ¶
const ( CODEC_OPUS = iota CODEC_VORBIS CODEC_UNKNOWN )
const ( // Best for most VoIP/videoconference applications where listening quality and intelligibility matter most OPUS_APPICATION_VOIP = 2048 // Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input OPUS_APPLICATION_AUDIO = 2049 // Only use when lowest-achievable latency is what matters most. Voice-optimized modes cannot be used. OPUS_APPLICATION_RESTRICTEDLOWDELAY = 2051 // Signal being encoded is voice OPUS_SIGNAL_VOICE = 3001 // Signal being encoded is music OPUS_SIGNAL_MUSIC = 3002 )
Possible constants to use
const ( // samplerate of 48kHz is opus default setting OPUS_SAMPLE_RATE = 48000 // number of channels to use (2 for Stereo, 1 for Mono). OPUS_CHANNELS = 2 //OPUS_BITRATE=128000 // Opus at 128 KB/s (VBR) is pretty much transparentk //-1 means MAX_BITRATE // MAX_BITRATE means libopus will use as much space it can put in opus packets. So it's controlled by the MAX_PACKET_SIZE in some way. OPUS_BITRATE = 40000 // size in pcm samples (1 sample is int16) (2 bytes = 1 sample) (480 frame_size = 960 bytes // samplerate * frame_duration = frame_size = number of pcm sampels in one frame per channel OPUS_PCM_FRAME_SIZE = 480 // 48000*10ms = 480 OPUS_FRAME_DURATION = 10 // 10 ms // The Application to use for opus. libopus will automatically OPUS_APPLICATION = OPUS_APPLICATION_AUDIO // Variable Bit Rate, if set to one libopus will automatically change the bitrate as it sees fit. OPUS_VBR = 0 )
Settings for encoding to opus
Variables ¶
This section is empty.
Functions ¶
Types ¶
type OpusDecoder ¶
type OpusDecoder struct {
// contains filtered or unexported fields
}
func NewOpusDecoder ¶
func NewOpusDecoder(samplerate int32, channels int) (*OpusDecoder, error)
type OpusEncoder ¶
type OpusEncoder struct {
// contains filtered or unexported fields
}
func NewOpusEncoder ¶
func NewOpusEncoder() (*OpusEncoder, error)
[in] Fs opus_int32: Sampling rate of input signal (Hz) This must be one of 8000, 12000, 16000, 24000, or 48000. [in] channels int: Number of channels (1 or 2) in input signal [in] application int: Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO/OPUS_APPLICATION_RESTRICTED_LOWDELAY). This parameter is currently ignored and instead OPUS_APPLICATION_AUDIO will be used [out] error int*: Error codes
func (*OpusEncoder) CtlSetBitrate ¶
func (enc *OpusEncoder) CtlSetBitrate(bitrate int) error
func (*OpusEncoder) CtlSetVbr ¶
func (enc *OpusEncoder) CtlSetVbr(vbr int) error
func (*OpusEncoder) Encode ¶
func (enc *OpusEncoder) Encode(pcm []int16) ([]byte, error)
[in] st OpusEncoder*: Encoder state [in] pcm opus_int16*: Input signal (interleaved if 2 channels). length is frame_size*channels*sizeof(opus_int16) [in] frame_size int: Number of samples per channel in the input signal. This must be an Opus frame size for the encoder's sampling rate. For example, at 48 kHz the permitted values are 120, 240, 480, 960, 1920, and 2880. Passing in a duration of less than 10 ms (480 samples at 48 kHz) will prevent the encoder from using the LPC or hybrid modes. [out] data unsigned char*: Output payload. This must contain storage for at least max_data_bytes. [in] max_data_bytes opus_int32: Size of the allocated memory for the output payload. This may be used to impose an upper limit on the instant bitrate, but should not be used as the only bitrate control. Use OPUS_SET_BITRATE to control the bitrate. returns The length of the encoded packet (in bytes) on success or a negative error code (see Error codes) on failure.