b64audio

package module
v0.0.0-...-ba4f49b Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2019 License: MIT Imports: 7 Imported by: 0

README

b64audio

Golang library for audio base64 encoding/decoding

Documentation

Index

Constants

View Source
const (
	BLOCK_SIZE    = 480  //480 == 60ms at 8kHz/8bit, for Opus encoding
	FRAME_SIZE_MS = 60   // 60ms
	SAMPLE_RATE   = 8000 // kHz
	CHANNELS      = 1
	OPUS_BIT_RATE = 16000
)

Variables

This section is empty.

Functions

func ContinuousPlay

func ContinuousPlay(ingoing chan []byte) error

ContinuousPlay opens audio stream and plays raw pcm chunks, requesting ingoing channel. It's blocking function.

func ContinuousPlayOpus

func ContinuousPlayOpus(ingoing chan []byte) error

ContinuousPlayOpus opens audio stream and plays opus encoded chunks, requesting ingoing channel. It's a blocking function.

func ContinuousRecord

func ContinuousRecord(outgoing chan []byte) error

ContinuousRecord records chunks and puts them into channel. It's a blocking function.

func ContinuousRecordOpus

func ContinuousRecordOpus(outgoing chan []byte) error

ContinuousRecordOpus records Opus encoded chunks and puts them into channel. It's a blocking function.

func DecodePayload

func DecodePayload(payload []byte) ([]byte, error)

DecodePayload converts base64 to []byte

func EncodePayload

func EncodePayload(chunk []byte) []byte

EncodePayload retruns the base64 encoding of input

func EncodePayloadToString

func EncodePayloadToString(chunk []byte) string

EncodePayloadToString converts []byte to base64 string

func PlayChunk

func PlayChunk(chunk []byte) error

PlayChunk plays raw PCM chunk

func PlayWAVChunk

func PlayWAVChunk(chunk []byte) error

PlayWAVChunk plays wav format chunk

func RecordChunk

func RecordChunk() ([]byte, error)

RecordChunk records audio chunk

func RecordWAVChunk

func RecordWAVChunk() ([]byte, error)

Types

type WAVInfo

type WAVInfo struct {
	Id              [4]byte
	Length          int32
	WavFmt          [8]byte
	Format          int32
	PCM             int16
	Channels        int16
	Freq            int32
	BytesPerSecond  int32
	BytesPerCapture int16
	BitsPerSample   int16
	Data            [4]byte
	BytesInData     int32
}

WAVInfo contains wav information

func GetWAVInfo

func GetWAVInfo(chunk []byte) (*WAVInfo, error)

GetWAVInfo gets information from wav chunk

Jump to

Keyboard shortcuts

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