public interface AudioSendHandler
Modifier and Type | Field | Description |
---|---|---|
static javax.sound.sampled.AudioFormat |
INPUT_FORMAT |
Audio Input Format expected by JDA if
isOpus() returns false. |
Modifier and Type | Method | Description |
---|---|---|
boolean |
canProvide() |
If this method returns true JDA will attempt to retrieve audio data from this handler by calling
provide20MsAudio() . |
default boolean |
isOpus() |
If this method returns true JDA will treat the audio data provided by
provide20MsAudio() as a pre-encoded
20 Millisecond packet of Opus audio. |
byte[] |
provide20MsAudio() |
If
canProvide() returns true JDA will call this method in an attempt to retrieve audio data from the
handler. |
static final javax.sound.sampled.AudioFormat INPUT_FORMAT
isOpus()
returns false. 48KHz 16bit stereo signed BigEndian PCM.boolean canProvide()
provide20MsAudio()
. The return value is checked each time JDA attempts send audio, so if
the developer wanted to start and stop sending audio it could be done by changing the value returned
by this method at runtime.provide20MsAudio()
byte[] provide20MsAudio()
canProvide()
returns true JDA will call this method in an attempt to retrieve audio data from the
handler. This method need to provide 20 Milliseconds of audio data as a byte array.
Considering this system needs to be low-latency / high-speed, it is recommended that the loading of audio data be done before hand or in parallel and not loaded from disk when this method is called by JDA. Attempting to load all audio data from disk when this method is called will most likely cause issues due to IO blocking this thread.
The provided audio data needs to be in the format: 48KHz 16bit stereo signed BigEndian PCM.
Defined by: AudioSendHandler.INPUT_FORMAT
.
If isOpus()
is set to return true, then it should be in pre-encoded Opus format instead.
default boolean isOpus()
provide20MsAudio()
as a pre-encoded
20 Millisecond packet of Opus audio. This means that JDA WILL NOT attempt to encode the audio as Opus, but
will provide it to Discord exactly as it is given.