dgvoice

package module
v0.0.0-...-9e4da78 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2022 License: BSD-3-Clause Imports: 9 Imported by: 0

README

dgVoice

GoDoc Go report Build Status Discord Gophers

dgVoice is a Go package that provides an example of adding opus audio and play file support for DiscordGo.

  • You must use the current develop branch of Discordgo
  • You must have ffmpeg in your path and Opus libs already installed.

This code should be considered just a proof of concept, or an example, of accomplishing this task and not a defacto standard.

Please send feedback on any performance improvements that can be made for sound quality, stability, or efficiency.

For help with this package or general Go discussion, please join the Discord Gophers chat server.

Getting Started

Installing

This assumes you already have a working Go environment, if not please see this page first.

go get github.com/bwmarrin/dgvoice

Usage Example

See example folder

Documentation

Overview

Package dgvoice provides opus encoding and audio file playback for the Discordgo package.

Index

Constants

This section is empty.

Variables

View Source
var OnError = func(str string, err error) {
	prefix := "dgVoice: " + str

	if err != nil {
		os.Stderr.WriteString(prefix + ": " + err.Error() + "\n")
	} else {
		os.Stderr.WriteString(prefix + "\n")
	}
}

OnError gets called by dgvoice when an error is encountered. By default logs to STDERR

Functions

func PlayAudioFile

func PlayAudioFile(v *discordgo.VoiceConnection, filename string, stop <-chan bool)

PlayAudioFile will play the given filename to the already connected Discord voice server/channel. voice websocket and udp socket must already be setup before this will work.

func ReceivePCM

func ReceivePCM(v *discordgo.VoiceConnection, c chan *discordgo.Packet)

ReceivePCM will receive on the the Discordgo OpusRecv channel and decode the opus audio into PCM then send it on the provided channel.

func SendPCM

func SendPCM(v *discordgo.VoiceConnection, pcm <-chan []int16)

SendPCM will receive on the provied channel encode received PCM data into Opus then send that to Discordgo

Types

This section is empty.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL