musikinformatik / SuperDirt

Tidal Audio Engine
GNU General Public License v2.0
519 stars 75 forks source link

Synths with "sustain" cause many xruns #233

Closed rlafuente closed 3 years ago

rlafuente commented 3 years ago

Hi, I spent the last week tracking the sources of many clicks and cracks in my audio while playing certain songs in Tidalcycles. Jack is having many xruns, especially when recording with OBS; they come up in force when scrolling in my text editor (both Atom and VSCode). Even changing lines with the cursor will cause cracks.

After many attempts at tweaking Jack's settings and some fiddling in Tidal, I found that the issue went away once I disabled sustain in the playing synths. CPU usage was clearly down, and Jack reported a DSP load of 10% -- after re-enabling sustain it went up to 40% (not sure if this is relevant, I just happened to notice the spike). I used the example script below with only two channels; uncommenting the last line of each block will cause the described behaviour.

do 
  bpm 105
  all $ (|* gain 0.7)

p "bassline"
  $ n "[12 0 12 0  10 0 15 8  0 12 0 12  15 0 17 0   12 0 12 0  10 0 12 8  0 12 0 12  15 <0 3> 6 18]/2" |+ n "-2"
  |+ n "[0 0 -2 [-7|-6|-4|-3|1]]/4"
  # sound "superfm" # octave 3 # fmratio 2 3
  -- # sustain 0.4 # release 0.4 # gain 1.15

p "blinkfm" -- from "Moog City" by C418
  $ jux (((1/8) <~) . rev) $ fast 2 (n "0 5 7 12 15 19 22 <27!4 29>") |+ n "-2"
  |+ n "[0 0 -2 [-7|-6|-4|-3|1]]/4"
  # sound "superfm" # octave 5 # fmratio 1 4 # fmratio 2 8 # gain 0.7
  -- # sustain 0.7 # release 0.7

Is this expected behaviour, synths with sustain being so heavy on the CPU?

telephon commented 3 years ago

Well, the sustain parameter will determine the absolute duration of every event in seconds. This may cause more overlapping sounds.

rlafuente commented 3 years ago

Good to know that it isn't strange behaviour. I'll just find an alternative to my aging laptop to deal with the cracks and clicks. Thanks!

rlafuente commented 4 months ago

I ran into this issue again while working with mi-uGens, and right now I'm wondering what might be the bottleneck in my system. I'm willing to invest a bit in a better hardware setup, but I don't know what exactly I should be looking into:

@telephon can you shed some light here? I'd love to put together a Troubleshooting doc in tidalcycles that could address points like this one.

telephon commented 3 months ago

you could try to work with # legato instead of # sustain. If legato < 1 you should have no overlap in that particular voice. Let me know how it goes...

rlafuente commented 3 months ago

Aha that's the thing, I want the overlap :-) I like to overlay long-playing synths with high sustain/legato values, and when I have 3 or 4 simultaneous synth channels playing, I get noticeable cracks and clicks.

This is not constant however, sometimes it plays without issue, and I have the feeling that the effect is less present when I don't have anything else open in my PC.

Which is why I wanted to know what I should be looking to fix/upgrade in my system so that Superdirt/SuperCollider can handle all the events. Or maybe it's a setting somewhere, I'm pretty lost.

Thanks for the quick reply!

telephon commented 3 months ago

Yes, this really sounds like a system issue. Hope you get it working …