ddf / Minim

A Java audio library, designed to be used with Processing.
http://code.compartmental.net/tools/minim
GNU Lesser General Public License v3.0
670 stars 137 forks source link

Choppy Sound when routing LiveInput #95

Open MeFisto94 opened 5 years ago

MeFisto94 commented 5 years ago

Sorry for the vast description, it's hard to explain sound sometimes, but I guess you can understand what I mean, essentially it sounds like a too small buffer, but when I increase the buffer it just takes longer for the interruption to appear.

As soon as I attach an LiveInput to the AudioOutput even other UGens attached to THIS Output such as FilePlayers don't play correctly anymore. Note that a different AudioOutput is unaffected by this. I could only guess that this is something like LiveInput running into an empty buffer and then pausing everything until there are more samples ready. Is there anything related I could try?

ddf commented 5 years ago

Yeah I think it's possible for the input reading to block here: https://github.com/ddf/Minim/blob/b0e7734c6a0fe5993a75062c13efc7f03ab9ea51/src/main/java/ddf/minim/javasound/JSAudioInput.java#L148

If that happened it'd hold up the entire signal chain. The comment about that implementation being "sort of terrible" is a bit of an understatement. Probably LiveInput should be using the version of read that takes a MultiChannelBuffer. I don't think this UGen was super well tested. :-/

As far as I know, using an AudioInput with monitoring enabled works well, but then you'd need to use the deprecated AudioEffect stuff (ie addEffect on the AudioInput) to modify the input before it goes back out to the speakers.