Performance issue

83 views
Skip to first unread message

Fabien

unread,
Jan 9, 2018, 2:22:10 PM1/9/18
to Extempore
Hi everyone,

I have been experiencing issues with performance lately. No matter what I play, I seem to often have audio glitches with "Audio underflow: are you pushing extempore too hard?".

I only have been using the built-in "fmsynth" and "analogue".

In this example:
https://github.com/contested-space/in_c/blob/master/in_c.xtm

I use 6 instruments, and the glitches are very frequent (and it happened a few time that the piece was completely stopped and the glitch became continuous). Ideally, i'd like the number of instruments to be a parameter, and I'm not sure what the upper limit should be.

In the past, I used extempore with a high number of samplers, without issue. What could be the cause? Are the instruments more cpu-demanding than samplers? Is it the way I use them?

Normally, how many instruments should I be able to play simultaneously without issue?

Fabien

Jason Levine

unread,
Jan 9, 2018, 4:36:25 PM1/9/18
to extemp...@googlegroups.com
Hey Fabien,

I've experienced something similar recently.  I'm only using one sampler and then I'm midi controlling a couple software synths.  If I leave Extempore running for to long I get the glitches and even worse, the sampler and midi synths fall out of sync even though they are in the same temporal recursion.  Like you,  I see tons of Audio Underflow messages in the console, but if I quit and restart extempore, all problems are solved.  I'm wondering, do your glitches happen immediately after starting Extempore? or do they turn up after Extempore has been running for a while?

--
You received this message because you are subscribed to the Google Groups "Extempore" group.
To unsubscribe from this group and stop receiving emails from it, send an email to extemporelang+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jason Levine
new media performer + creative coder

Fabien

unread,
Jan 9, 2018, 6:21:54 PM1/9/18
to Extempore
Hi Jason,

It happens as soon as I start playing, even if I just opened extempore.
To unsubscribe from this group and stop receiving emails from it, send an email to extemporelan...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Andrew Sorensen

unread,
Jan 9, 2018, 7:09:51 PM1/9/18
to extemp...@googlegroups.com
Jason,

This 'smells' like a memory leak. Take a look at your memory usage and let me know how you get on.

Cheers,
Andrew.

Andrew Sorensen

unread,
Jan 9, 2018, 7:49:25 PM1/9/18
to extemp...@googlegroups.com
Hi Fabien,

Couple of comments.  If you are having performance problems "no matter what you play" then your problems are likely soundcard/driver/OS related.

If you are on OSX then you shouldn't need to do anything in particular to setup for low latency audio.  If you are on Windows or Linux then you will definitely need to configure your system for decent playback using extempore.  Just as a general list sidenote, I am running Windows 10 as my primary daily platform at the moment and getting reasonably good audio performance - but not out of the box.  In particular on Win10 you need to pay careful attention to your power settings.  This is also true on Linux (cpu throttling etc..).

Also, just be aware that by default Extempore runs with reasonably low buffer sizes (128).  You might like to try pushing frames up --frames=1024 (256, 512 etc.)

What platform are you on?

By far the cheapest instrument in Extempore is the sampler - you should be able to play lots of these without to much trouble.  fmsynth is also reasonably cheap (although still more expensive than the sampler).  The "analogue" synth is EXPENSIVE.  Many times more expensive than fmsynth, even with basic settings.

MULTICORE:

Best practice for Extempore is now to assign one expensive, or multiple cheap, instruments to an extempore "dsp thread".  Here is an example of how you can run 4 analogue synths on (potentially) their own cores:

(sys:load "libs/external/instruments_ext.xtm")

;; make bass, lead, riff and pad
(make-instrument bass analogue)
(make-instrument lead analogue)
(make-instrument riff analogue)
(make-instrument pad analogue)

(bind-func dsp1:DSP
  (lambda (in time chan dat)
    (lead in time chan dat)))

(bind-func dsp2:DSP
  (lambda (in time chan dat)
    (riff in time chan dat)))

(bind-func dsp3:DSP
  (lambda (in time chan dat)
    (bass in time chan dat)))

(bind-func dsp4:DSP
  (lambda (in time chan dat)
    (pad in time chan dat)))

(bind-func dsp:DSPMT
  (lambda (in time chan dat)
    (cond ((< chan 2)
           (+ (pref in 0)   ;; dsp 1
              (pref in 1)   ;; dsp 2
              (pref in 2)   ;; dsp 3
              (pref in 3))) ;; dsp 4
          (else 0.0))))

(dsp:set! dsp dsp1 dsp2 dsp3 dsp4)



Cheers,
Andrew.



--

Fabien

unread,
Jan 9, 2018, 11:04:47 PM1/9/18
to Extempore
Hi Andrew,

You are onto something! I was only using my laptop with linux (Fedora 25). Since I like to code in cafeterias and libraries, I didn't bring my sound device. With it, the 6 insrtuments code works flawlessly, and by using only fmsynths, I can go up to around 10 instruments on a single core without issue. More than that, however, still makes a lot of glitch.

I tried doing the multi-core setup (and got a little bit over excited, thinking that if a single core could withstand a workload of 10 instruments, surely I could have 8 per core!) however, I got the following warning (4 times):

Failed to set realtime priority for Audio thread: Operation not permitted
Starting RT Audio Process

And there was not much music, only glitch. I went down to 4 per core and it still was very glitchy.
 

Andrew Sorensen

unread,
Jan 9, 2018, 11:36:19 PM1/9/18
to extemp...@googlegroups.com
I would try to get your real-time audio privileges sorted out first.

--

Fabien

unread,
Jan 10, 2018, 10:36:30 AM1/10/18
to Extempore
Done! I can now play around 5 fmsynth per core with some (but much less) glitch.

At some points there seems to be much less instuments (and the sound seems... incomplete?) than it should, but I'm guessing it could be due to phase cancellation.

Cian

unread,
Jan 10, 2018, 1:26:21 PM1/10/18
to extemp...@googlegroups.com
Probably phase cancellation. The other thing to look out for is volume. The more synths you have, the more likely you are to get digital clipping.

On Wed, Jan 10, 2018 at 10:36 AM, Fabien <contest...@gmail.com> wrote:
Done! I can now play around 5 fmsynth per core with some (but much less) glitch.

At some points there seems to be much less instuments (and the sound seems... incomplete?) than it should, but I'm guessing it could be due to phase cancellation.

--

Fabien

unread,
Jan 10, 2018, 8:18:04 PM1/10/18
to Extempore
I was wondering, what is the most cpu-consuming, N instruments playing 1 note, or 1 instrument playing N notes?

Andrew Sorensen

unread,
Jan 10, 2018, 8:25:50 PM1/10/18
to extemp...@googlegroups.com
N instruments playing 1 note is more expensive - usually considerably so ...

consider for example that an instrument will often include audio effects, such as reverb, which are active regardless of the number of notes playing (including 0).  All instruments do some 'work' even when no notes are sounding.

On Thu, Jan 11, 2018 at 11:18 AM, Fabien <contest...@gmail.com> wrote:
I was wondering, what is the most cpu-consuming, N instruments playing 1 note, or 1 instrument playing N notes?

--

Fabien

unread,
Jan 12, 2018, 11:43:18 AM1/12/18
to Extempore
Well then, my musicians will share their instruments! Using my sound device and two instruments per core, everything runs with almost no glitch (maybe one noise with warning message every two-three minutes). If I run it without the device however, I still have a lot of glitch and I get the underflow warning as soon as dsp is compiled.

Is there a built-in way to run the dsp loop without playback and without a need for timing (like printing it directly to text to convert it to audio file myself afterwards, thus eliminating the performance issue to make a recorded version) ?

For my present needs though, I'd say that my problems are solved. Now only a few lines to change and the world will finally have the vuvuzela version of Terry Riley's "In C" that it desperately needed!

Thanks


Andrew Sorensen

unread,
Jan 12, 2018, 9:23:24 PM1/12/18
to extemp...@googlegroups.com
What friendly musicians you have!  :)

Unfortunately there isn't any offline (non real-time) mode available for extempore at the moment.

I would also suggest that you take a look into cpu frequency scaling.  A quick Fedora google gives: https://openterprise.it/2017/08/fedora-cpu-frequency-scaling/, but I'm sure you will find many other sources.

Taking a complete guess, I would bet that your system is currently running with heavy cpu throttling - which for real-time audio is a problem.

Also, as you don't care about latency, you would also benefit from pushing up the --frames option (try 1024 or even 2048).  
Try starting extempore with .\extempore --frames=1024 

Cheers,
Andrew.


Fabien

unread,
Jan 13, 2018, 3:49:58 PM1/13/18
to Extempore
It works! Perferctly now, no glitch at all, with 16 instruments, 4 per core. I'm not sure what did it between the larger frame or switching my cpu scaling from powersave to performance, I'll have to make some more tests later, since for now latency is not an issue, but it might be very soon, since I have to build a physical interface or device of some sort as a school project.

But now everything runs super smoothly, even without the sound card. Thanks a lot everyone!

Fabien

unread,
Jan 13, 2018, 4:15:12 PM1/13/18
to Extempore
Quick follow up: I tried changing the 16 fmsynth to 16 analogue. Starting it with 128 frames did a lot of glitches, but around the same as I had before changing the cpu scaling with much less instruments. Changing the frames to 2048 makes it all ok, it sounds terrible, but through no fault of the glitches!

Reply all
Reply to author
Forward
0 new messages