Skip to content

Is it possible to turn on/off DTX mode? #204

@chapayGhub

Description

@chapayGhub

Hey

In c/c++ i can turn on DTX by code below

	opus_encoder_ctl(enc, OPUS_SET_DTX(enable ? 1 : 0));

and can skip data without voice

int32_t r = opus_encode(enc, data, static_cast<int>(len), buffer, 4096);
if ( r<=0 ) {
        //some error
} else if( r<=2 ) {
        //https://stackoverflow.com/questions/39718307/how-to-use-opus-dtx-from-opensource-opus-demo-binary
        /*
         When using Opus over a network, using a protocol such as RTP where the packets are timestamped, DTX may be enabled if you want to reduce the packets sent during periods where there is no voice activity.
         A packet would still be sent about every 400 ms, updating background noise.
         Using the packet timestamps the receiver can determine the duration of any gaps and fill them in with the background noise to keep it sounding natural.

         Enable DTX in the encoder using opus_encoder_ctl(enc, OPUS_SET_DTX(1));
         , or with the -dtx option on opus_demo.
         Then, simply do not send any packets produced by the encoder with a length of 2 bytes or less.
         (These "DTX packets" are just zero-length frames, with a normal 1- or 2-byte packet header (TOC), and do not contain any audio data.)
         Packets with a length larger than 2 bytes should be sent as usual.

         The receiver should use normal packet loss concealment to handle missing packets, in the same manner as it would handle packet loss.
         In particular it can call opus_decode() with data = NULL, len = 0, and frame_size equal to the size of the missing frame(s),
         and the decoder will generate audio data to conceal the missing frame(s).
         */
} else {
        //r contains size of encoded data
}

Can I do the same with JS? and how ;) ?
Sorry I`m newbie in JS

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions