DiscordPHP-Voice Documentation

DCA extends ProcessAbstract
in package

FinalYes

Handles the encoding and decoding of audio streams using DCA format.

Tags
since
10.19.0

Table of Contents

Constants

DCA_VERSION  : string = 'DCA1'
The DCA version the client is using.
DEFAULT_KHZ  : int = 48000
Default KHz value for voice to be decoded after someone talks.

Properties

$exec  : string

Methods

checkForDca()  : bool
Locates a `dca` executable on PATH, caching the resolved path in `self::$exec`.
checkForExecutable()  : string|null
Checks if the specified executable is available on the system.
decode()  : Process
Builds a `dca` decode process.
encode()  : Process
Encodes audio to DCA format.

Constants

DCA_VERSION

The DCA version the client is using.

public string DCA_VERSION = 'DCA1'

The DCA version.

DEFAULT_KHZ

Default KHz value for voice to be decoded after someone talks.

public int DEFAULT_KHZ = 48000

Properties

$exec

protected static string $exec = 'dca'

Methods

checkForDca()

Locates a `dca` executable on PATH, caching the resolved path in `self::$exec`.

public static checkForDca() : bool
Return values
bool —

True if a usable binary was found.

checkForExecutable()

Checks if the specified executable is available on the system.

public static checkForExecutable(string $exec) : string|null
Parameters
$exec : string
Return values
string|null

decode()

Builds a `dca` decode process.

public static decode([string|null $filename = null ][, int|float $volume = 0 ][, int $bitrate = 128000 ][, int $channels = 2 ][, int|null $frameSize = null ][, array<string|int, int|string>|null $preArgs = null ]) : Process
Parameters
$filename : string|null = null

Input filename, or null to read from stdin.

$volume : int|float = 0

Volume adjustment in dB.

$bitrate : int = 128000

Target bitrate in bits per second.

$channels : int = 2

Output channel count.

$frameSize : int|null = null

Samples per frame; defaults to 960 (20 ms at 48 kHz).

$preArgs : array<string|int, int|string>|null = null

Extra arguments placed before the main flags.

Return values
Process

encode()

Encodes audio to DCA format.

public static encode([string|null $filename = null ][, int|float $volume = 0 ][, int $bitrate = 128000 ][, array<string|int, mixed>|null $preArgs = null ]) : Process
Parameters
$filename : string|null = null

The input filename, or null for pipe input.

$volume : int|float = 0

The volume adjustment in dB.

$bitrate : int = 128000

The bitrate for the output audio.

$preArgs : array<string|int, mixed>|null = null

Additional arguments to pass before the main flags.

Tags
TODO

Implement function, was not in original code.

Return values
Process
On this page

Search results