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

Mixing process doesn't end/close stream #1

Open
CmdrShepardsPie opened this issue Oct 5, 2018 · 3 comments
Open

Mixing process doesn't end/close stream #1

CmdrShepardsPie opened this issue Oct 5, 2018 · 3 comments

Comments

@CmdrShepardsPie
Copy link

This probably isn't a bug, but I am not able to get this process to work. I'm trying to mix a variable number of pcm files into one output file from the command line. Here's the mixing stream code. Node does get to the end of this, but then just pauses and doesn't end the script/process. Am I missing a command to "finish" the process?

  const mixer = new AudioMixer.Mixer({
    channels: 1,
    bitDepth: 16,
    sampleRate: 16000,
  });

  for (const filename of inFilenames) {
    const fileStream = fs.createReadStream(filename);

    const input = mixer.input({
      channels: 1,
      volume: 75,
    });

    fileStream.pipe(input);
  }

  const write = fs.createWriteStream(outFilename);

  mixer.pipe(write);
@ConnorChristie
Copy link
Owner

@chawson Did your PR fix this issue? Thanks

@chawson
Copy link

chawson commented May 31, 2019

@chawson Did your PR fix this issue? Thanks

@ConnorChristie
The execution of setImmediate was manually stopped in an unreasonable way.

 let timer:any = null
 ws.on('drain',()=>{
        clearTimeout(timer)
        timer = setTimeout(()=>{
            clearTimeout(timer)
            mixer.close()
            mixer.destroy()
            ws.end()
        },2000)
 })

Assuming that the waiting time exceeds 2 seconds, the task is considered completed.
The optimization plan is under investigation.

@timo-klarshift
Copy link

I see a similar behaviour: playing 10 times a file to an input will result in 10 open file handles and the file readstream is never terminated.

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

4 participants