Documentation ¶
Index ¶
- func NewPCMOpusProvider(encoder *opus.Encoder, pcmProvider PCMFrameProvider) (voice.OpusFrameProvider, error)
- func NewPCMOpusReceiver(decoderCreateFunc func() (*opus.Decoder, error), ...) voice.OpusFrameReceiver
- type CombinedPCMPacket
- type PCMCombinedFrameReceiver
- type PCMFrameProvider
- func NewCustomMP3PCMFrameProvider(decoder *mp3.Decoder, rate int, channels int) (PCMFrameProvider, io.Writer, error)
- func NewCustomPCMStreamProvider(r io.Reader, rate int, channels int) PCMFrameProvider
- func NewMP3PCMFrameProvider(decoder *mp3.Decoder) (PCMFrameProvider, io.Writer, error)
- func NewPCMStreamProvider(r io.Reader) PCMFrameProvider
- func NewSampleRateProvider(resampler *samplerate.Resampler, inputSampleRate int, outputSampleRate int, ...) PCMFrameProvider
- type PCMFrameReceiver
- func NewPCMCombinerReceiver(logger log.Logger, pcmCombinedFrameReceiver PCMCombinedFrameReceiver) PCMFrameReceiver
- func NewPCMStreamReceiver(w io.Writer, receiveUserFunc voice.ShouldReceiveUserFunc) PCMFrameReceiver
- func NewSampleRateReceiver(resampler *samplerate.Resampler, inputSampleRate int, outputSampleRate int, ...) PCMFrameReceiver
- type PCMPacket
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPCMOpusProvider ¶
func NewPCMOpusProvider(encoder *opus.Encoder, pcmProvider PCMFrameProvider) (voice.OpusFrameProvider, error)
NewPCMOpusProvider creates a new voice.OpusFrameProvider which gets PCM frames from the given PCMFrameProvider and encodes the PCM frames into Opus frames. You can pass your own *opus.Encoder or nil to use the default Opus encoder(48000hz sample rate, 2 channels, opus.ApplicationAudio & 64kbps bitrate).
func NewPCMOpusReceiver ¶
func NewPCMOpusReceiver(decoderCreateFunc func() (*opus.Decoder, error), pcmFrameReceiver PCMFrameReceiver, receiveUserFunc voice.ShouldReceiveUserFunc) voice.OpusFrameReceiver
NewPCMOpusReceiver creates a new voice.OpusFrameReceiver which receives Opus frames and decodes them into PCM frames. A new decoder is created for each user. You can pass your own *opus.Decoder by passing a decoderCreateFunc or nil to use the default Opus decoder(48000hz sample rate, 2 channels). You can filter users by passing a voice.ShouldReceiveUserFunc or nil to receive all users.
Types ¶
type CombinedPCMPacket ¶
CombinedPCMPacket is a PCMPacket which got created by combining multiple PCMPacket(s).
type PCMCombinedFrameReceiver ¶
type PCMCombinedFrameReceiver interface { // ReceiveCombinedPCMFrame is called when a new CombinedPCMPacket is received. ReceiveCombinedPCMFrame(userIDs []snowflake.ID, packet *CombinedPCMPacket) error // Close is called when the PCMCombinedFrameReceiver is no longer needed. It should close any open resources. Close() }
PCMCombinedFrameReceiver is an interface for receiving PCMPacket(s) from multiple users as one CombinedPCMPacket.
func NewPCMCombinedStreamReceiver ¶
func NewPCMCombinedStreamReceiver(w io.Writer) PCMCombinedFrameReceiver
NewPCMCombinedStreamReceiver creates a new PCMCombinedFrameReceiver which writes the CombinedPCMPacket to the given io.Writer.
func NewSampleRateCombinedReceiver ¶
func NewSampleRateCombinedReceiver(resampler *samplerate.Resampler, inputSampleRate int, outputSampleRate int, pcmFrameReceiver PCMCombinedFrameReceiver) PCMCombinedFrameReceiver
type PCMFrameProvider ¶
type PCMFrameProvider interface { // ProvidePCMFrame is called to get a PCM frame. ProvidePCMFrame() ([]int16, error) // Close is called when the provider is no longer needed. It should close any open resources. Close() }
PCMFrameProvider is an interface for providing PCM frames.
func NewCustomPCMStreamProvider ¶
func NewCustomPCMStreamProvider(r io.Reader, rate int, channels int) PCMFrameProvider
func NewMP3PCMFrameProvider ¶
NewMP3PCMFrameProvider returns a PCMFrameProvider that reads mp3 and converts it into pcm frames. Write the Mp3 data to the returned mp3Writer.
func NewPCMStreamProvider ¶
func NewPCMStreamProvider(r io.Reader) PCMFrameProvider
NewPCMStreamProvider creates a new PCMFrameProvider which reads PCM frames from the given io.Reader.
func NewSampleRateProvider ¶
func NewSampleRateProvider(resampler *samplerate.Resampler, inputSampleRate int, outputSampleRate int, pcmFrameProvider PCMFrameProvider) PCMFrameProvider
type PCMFrameReceiver ¶
type PCMFrameReceiver interface { // ReceivePCMFrame is called when a PCM frame is received. ReceivePCMFrame(userID snowflake.ID, packet *PCMPacket) error // CleanupUser is called when a user is disconnected. This should close any resources associated with the user. CleanupUser(userID snowflake.ID) // Close is called when the receiver is no longer needed. It should close any open resources. Close() }
PCMFrameReceiver is an interface for receiving PCM frames.
func NewPCMCombinerReceiver ¶
func NewPCMCombinerReceiver(logger log.Logger, pcmCombinedFrameReceiver PCMCombinedFrameReceiver) PCMFrameReceiver
NewPCMCombinerReceiver creates a new PCMFrameReceiver which combines multiple PCMPacket(s) into a single CombinedPCMPacket. You can process the CombinedPCMPacket by passing a PCMCombinedFrameReceiver.
func NewPCMStreamReceiver ¶
func NewPCMStreamReceiver(w io.Writer, receiveUserFunc voice.ShouldReceiveUserFunc) PCMFrameReceiver
NewPCMStreamReceiver creates a new PCMFrameReceiver which writes PCM frames to the given io.Writer. You can filter which users should be written by passing a voice.ShouldReceiveUserFunc.
func NewSampleRateReceiver ¶
func NewSampleRateReceiver(resampler *samplerate.Resampler, inputSampleRate int, outputSampleRate int, pcmFrameReceiver PCMFrameReceiver) PCMFrameReceiver