Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoding in real-time becomes gaped #69

Open
OnkelTem opened this issue Mar 23, 2021 · 1 comment
Open

Decoding in real-time becomes gaped #69

OnkelTem opened this issue Mar 23, 2021 · 1 comment

Comments

@OnkelTem
Copy link

My question may look a little unrelated to the usage of this particular library.

Basically, I receive an Opus stream from the internet, decode it with prism.opus.Decoder, get PCM packets and stream them forward to the speakers:

    events.onAudioData(async ({ event, opusInfo, getStream }) => {
        // A stream with Opus packets
        const stream = getStream(undefined, false);

        const frameSize = (opusInfo.inputSampleRate * opusInfo.frameSize) / 1000;
        const opusOpt = {
          rate: opusInfo.inputSampleRate,
          channels: opusInfo.channels,
          frameSize,
        };
        const opusDecoder = new prism.opus.Decoder(opusOpt);

        const normalizer = new NormalizeRateStream({
          bufferLengthMs: 2 * 1000,
          packetLengthMs: event.packet_duration,
        });

        const speaker = new Speaker({
          channels: opusInfo.channels,
          bitDepth: 16,
          sampleRate: opusInfo.inputSampleRate,
        });

        stream.pipe(getOpusStatsStream(pinoLogger)).pipe(opusDecoder).pipe(normalizer).pipe(speaker);
    });

There is also a duplex normalizing stream which ensures requested rate of packets per time.

The problem is that sound becomes gaped and I cannot find a way to glue pieces in one steady stream.

I recorded a helping video which demonstrates the problem:

https://www.youtube.com/watch?v=O7Fv3GTMjKQ

Do you have any idea why it's happening?

@amishshah
Copy link
Owner

Hi @OnkelTem, I'm afraid I'm not too sure what is happening either :(

Is onAudioData only fired once after connecting to the radio? The only thing I can think of is that it is being called repeatedly and giving the weird gap.

The issue is unrelated to the library, however I think I'll keep it open until I run out of ideas 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants