Documentation ¶
Index ¶
- type Option
- type Options
- type PbWriter
- func (pbw *PbWriter) Close() error
- func (pbw *PbWriter) Flush()
- func (pbw *PbWriter) SetToWireCb(cb func([]byte))
- func (pbw *PbWriter) SetVolume(v float32)
- func (pbw *PbWriter) Start() error
- func (pbw *PbWriter) Stop() error
- func (pbw *PbWriter) Volume() float32
- func (pbw *PbWriter) Write(audioMsg audio.Msg) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Options)
Option is the type for a function option
func Channels ¶
Channels is a functional option to set the amount of channels to be used with the audio device. Typically this is either Mono (1) or Stereo (2). Make sure that your audio device supports the specified amount of channels.
func Encoder ¶
func Encoder(enc audiocodec.Encoder) Option
Encoder is a functional option to set a specific decoder. By default, the opus decoder is used.
func FramesPerBuffer ¶
FramesPerBuffer is a functional option which sets the amount of sample frames our audio device will request / provide when executing the callback. Example: A buffer with 960 frames at 48000kHz / stereo contains 1920 samples and results in 20ms Audio.
func Samplerate ¶
Samplerate is a functional option to set the sampling rate of the audio device. Make sure your audio device supports the specified sampling rate.
type Options ¶
type Options struct { DeviceName string Encoder audiocodec.Encoder Channels int Samplerate float64 FramesPerBuffer int UserID string ToWireCb func([]byte) }
Options is the data structure holding the optional values. The values are typically set by calling the functional options.
type PbWriter ¶
PbWriter implements the audio.Sink interface. It is used to encode audio.Msg with a selected audiocodec into Protocol buffers. This Sink is typically used when audio frames have to be send to the network.
func NewPbWriter ¶
NewPbWriter is the constructor for a ProtoBufWriter. The ToWireCb callback will be executed when an audio.Msg has been encoded into a protobuf byte slice and ready to be send to the network. Additional functional options can be passed in (e.g. the audio codec to be used).
func (*PbWriter) SetToWireCb ¶
SetToWireCb allows to set a callback which will be called whenever the data has been serialized and is ready to be send on the wire.