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

Noise at the beginning of playback #161

Open
OnkelTem opened this issue Mar 25, 2021 · 0 comments
Open

Noise at the beginning of playback #161

OnkelTem opened this issue Mar 25, 2021 · 0 comments

Comments

@OnkelTem
Copy link

OnkelTem commented Mar 25, 2021

My system: Linux Kubuntu 20.04

When I try to play something, it crumples the beginning second or two of the recording and I hear a noise.

My code is doing something like this:

const stream = fs.createReadStream('test/fixtures/01.wav');
const transcoderStream = new prism.FFmpeg({
  args: ['-i', '-', '-f', 's16le', '-ar', '16000', '-channel_layout', 'mono'],
});
const speaker = new Speaker({
  channels: 1,
  bitDepth: 16,
  sampleRate: 16000,
});
stream
    .pipe(transcoderStream)
    .pipe(speaker);

When I run this script repeatedly, the artifact is somehow different each time. I.e." khhhh", "phftttt", "kchttttttt" LOL

It looks like there's some data left in some playback buffer, but I have no idea what it could be.

This is how I shutdown my script:

process.on('SIGINT', async function () {
  stream.destroy();
  await pEvent(stream, 'close');
  process.exit();
});

I also tried calling speaker.destroy(); but it didn't make any difference for the issue.

If I however output the same stream to aplay for example:

stream
    .pipe(transcoderStream)
    .pipe(process.stdout);

with:

$ node play-wav.js | aplay -f S16_LE -r 16000

there are no any artifacts and occasional restarts don't bring them.

So there seems to be a problem in the Speaker playback tract.

What is going wrong?

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

1 participant