Topic: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

To state it first: Everything works (a bit). I'm using Ubuntu Studio, the audio server is Jack, my virtual piano is (of course) Pianoteq, and I'm using an external Soundcard: Focusrite Scarlett 2i2, attached to my laptop via USB. I use this software to play Piano on a Kawai VPC-1. So far everything is fine: I can choose the "Jack-Device" in Pianoteq, I can set Settings like the Sample rate or the Buffer size in the QJackctl, and the output at my Focusrite scarlet (which I plugged my headphones to) behaves accordingly. I can play Piano with this, and if I press a Key on my VPC-1, then I hear a sound from the output of the Focusrite Scarlett.

The only issue that I have: Using Jack and the external sound device Focusrite Scarlett 2i2, the performance is worse than simply using my onboard soundcard (and not using Jack): Using my onboard Soundcard, I can use higher sample rates, without having xruns, or unplayable delay. With the Focusrite Scarlett, using a buffer-size of 128 and 48000 Hz Sample rate will allready result in xruns, and having a buffer-size of 256 results in a slight latency.
Question: What am I doing wrong?

More answerable question: Is it plausible that the focusrite Scarlett can't compete with a 10 year old Toshiba Tecra (i386 Architecture, double Core, arround 1 GHz processor frequency).

Alternative more-answerable question: Is my understanding right?: When I tell pianoteq to use the Focusrite Scarlett via Jack, does that mean that the computations that pianoteq needs to perform to create the piano sounds is performed inside the Focusrite Scarlett processor?
And when I tell Pianoteq to use my onboard Soundcard, does that mean that the Sound will be processed on my on lab-top?

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

Set the audio priority at 95 in qjacktcl.
Turn the wifi off.
Try again.

Keep in mind that using jack is needed only if you want to connect applications to each other.
If you juste want to play Pianoteq, you can use Alsa direct without jack.

Can you give us some informations about your pc?

Last edited by stamkorg (14-12-2017 23:29)

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

Quantumwhisp wrote:

More answerable question: Is it plausible that the focusrite Scarlett can't compete with a 10 year old Toshiba Tecra (i386 Architecture, double Core, arround 1 GHz processor frequency).

I don't think so.
Now, be aware that your pc seems to be somehow old for Pianoteq. Honestly, I wouldn't recommand something below and intel core i3 for Pianoteq.

Quantumwhisp wrote:

Alternative more-answerable question: Is my understanding right?: When I tell pianoteq to use the Focusrite Scarlett via Jack, does that mean that the computations that pianoteq needs to perform to create the piano sounds is performed inside the Focusrite Scarlett processor?
And when I tell Pianoteq to use my onboard Soundcard, does that mean that the Sound will be processed on my on lab-top?

No, the process is inside the computer. The external soundcard will give you a better sound and maybe some buffer management. In any case, Pianoteq runs on the processor. That's why we need a good one.
With my computer, a scarlett 6i6 1st gen and Librazik (a french music oriented Linux debian based distribution) I can achieve a setting at 48000 / 32 samples / 3 buffers, for a 2msec reported latency inside qjackctl, without any xrun.
It is totally possible, and gives a perfect connection between the keyboard and the sound.

I think your soundcard is not the problem here.

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

stamkorg wrote:

I don't think so.
Now, be aware that your pc seems to be somehow old for Pianoteq. Honestly, I wouldn't recommand something below and intel core i3 for Pianoteq.

Well, I'm not having anything better at the moment, and I still want to make it work as good as possible. Note that Pianoteq alone does run fine on low Settings (Soundquality that is fine for me 44100 Hz sampling rate, Buffersize of 192 samples, no noticable latency), if I use it via Alsa. I was just wondering wether Jack could do a better job with the external audio device, and I have to get it work anyways if I want to record stuff with Ardour. 

stamkorg wrote:

No, the process is inside the computer. The external soundcard will give you a better sound and maybe some buffer management. In any case, Pianoteq runs on the processor. That's why we need a good one.

Can you explain that in more detail? If the sound is created in the computer, what exactly is the soundcard good for? Is my assumption right that for virtual instruments, the choice of the soundcard is irrellevant?

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

stamkorg wrote:

Set the audio priority at 95 in qjacktcl.
Turn the wifi off.
Try again.

Keep in mind that using jack is needed only if you want to connect applications to each other.
If you juste want to play Pianoteq, you can use Alsa direct without jack.

Can you give us some informations about your pc?

It's a Toshiba Tecra. The CPU is an Intel(R) Core(TM)2 . With a frequency of 2.00 GHz each. Distribution Running is Ubuntu Studio (underlying is an Ubuntu 14.04 with a Low Latency Kernel 3.13.0-24-lowlatency.

As I want to use Ardour to record things (not only sounds from pianoteq), I want to use Jack anyways. Basically I started the thread because I want to know what's going on, and how Jack works with Pianoteq.

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

Quantumwhisp wrote:

Can you explain that in more detail? If the sound is created in the computer, what exactly is the soundcard good for? Is my assumption right that for virtual instruments, the choice of the soundcard is irrellevant?

The soundcard will give a better sound with less jitter and parasit noise + the ability to have more inputs and output.
If you just want 1 headphones output and if you are happy with the onboard soundcard, stay with it.

Quantumwhisp wrote:

It's a Toshiba Tecra. The CPU is an Intel(R) Core(TM)2 . With a frequency of 2.00 GHz each. Distribution Running is Ubuntu Studio (underlying is an Ubuntu 14.04 with a Low Latency Kernel 3.13.0-24-lowlatency.

As I want to use Ardour to record things (not only sounds from pianoteq), I want to use Jack anyways. Basically I started the thread because I want to know what's going on, and how Jack works with Pianoteq.

Ubuntu Studio is solid, it should run fine.

1. Click qjackctl
2. select the soundcard you want to use
3. set the desired sample rate and buffer size
4. check "realtime"
5. set the audio priority to 95
6. select the right power plan: you should use "performance" instead of "ondemand" or the other plans.

7. start Jack using the button on qjackctl

8. start Pianoteq and choose the auto connection to jack.

Et voilà

Last edited by stamkorg (16-12-2017 17:41)

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

Quantumwhisp wrote:

Can you explain that in more detail? If the sound is created in the computer, what exactly is the soundcard good for? Is my assumption right that for virtual instruments, the choice of the soundcard is irrellevant?

Pianoteq runs in the computer and produces the sound as digital samples, (for example 48000 samples of 24 bits each per second) but these bits have to be converted to audible sound through a DAC (digital to analog converter). There is one in your computer, that can be of lower quality and more prone to noise (due to others circuits around it) than if you buy an external USB card, that also furnishes a number of MIDI input channels for you keyboard.

So you need a fast enough computer for pianoteq's computation of the samples, but you get better audible results using a good external soundcard.

Last edited by Gilles (18-12-2017 18:50)

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

Gilles wrote:
Quantumwhisp wrote:

Can you explain that in more detail? If the sound is created in the computer, what exactly is the soundcard good for? Is my assumption right that for virtual instruments, the choice of the soundcard is irrellevant?

Pianoteq runs in the computer and produces the sound as digital samples, (for example 48000 samples of 24 bits each per second) but these bits have to be converted to audible sound through a DAC (digital to audio converter). There is one in your computer, that can be of lower quality and more prone to noise (due to others circuits around it) than if you buy an external USB card, that also furnishes a number of MIDI input channels for you keyboard.

So you need a fast enough computer for pianoteq's computation of the samples, but you get better audible results using a good external soundcard.

Do I understand right the the Buffer Size tells me how many samples are processed before they are sent to the Soundcard? If it is like that, then why are XRuns more probable if the buffer size is lower?

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

Because your CPU has to work a lot harder in order to put those buffers out faster because they're smaller. Processing demands are increased.

Hard work and guts!

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

EvilDragon wrote:

Because your CPU has to work a lot harder in order to put those buffers out faster because they're smaller. Processing demands are increased.

This is probably getting to the core of my non-understanding. I will state my line of thoughts, and I would appreciate it if you tell me for each of them individually if it's wrong, in case it is wrong:

Let's say we have a sample rate of 48kHz. And a Buffer Size of 256 Samples.

1. Sample Rate of 48 kHz means that the sound card expects 48k samples per second, which it processes to audible signals.
2. This also means it expects 48 k / 256 transmissions per second from the pc.
3. If the computer fails to deliver the 256 at the point where they are expected, that results in an xrun.
4. This means the Computer has to provide 256 samples at every transmission.
5. The computer still has to compute 48 k samples per second, independent from the buffer size.

So where is the samplesize a factor that makes xruns more probable? The computer doesn't have more work to do when the buffer size is smaller.

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

Quantumwhisp wrote:

The computer doesn't have more work to do when the buffer size is smaller.

Yes it does! It's not about the number of samples it has to process (well not QUITE, higher sample rates will again increase the processing demands simply because a certain block size now takes shorter time with a higher sample rate), it's about the AMOUNT OF PROCESSING needed for every processing block. That's the keyword: block, not individual sample. So, if you have a lot of heavy math and you have to do it in really short amount of time (say 32 samples), processing demands on the CPU will be much higher than if it were a larger block of samples, which can be spread out over time for processing (at cost of increasing latency). Therein lies the catch.

It's like building a house in 3 days vs 30 days. What is more difficult? Of course, building it in 3 days.


Also, your statement "5. The computer still has to compute 48 k samples per second, independent from the buffer size. " is wrong. Today's CPUs can process 48k of samples in faster than a second. Buffers are QUEUED. If there was no difficult math in order to produce an audio buffer whole, it is sent out. What is an overrun, anyways? It's when the CPU takes MORE time to process ONE BLOCK of audio than the duration of the block itself. That is very much possible if the block is too short compared to the amount of math needed to process it fully.

Last edited by EvilDragon (17-12-2017 09:31)
Hard work and guts!

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

EvilDragon wrote:
Quantumwhisp wrote:

The computer doesn't have more work to do when the buffer size is smaller.

Yes it does! It's not about the number of samples it has to process (well not QUITE, higher sample rates will again increase the processing demands simply because a certain block size now takes shorter time with a higher sample rate), it's about the AMOUNT OF PROCESSING needed for every processing block. That's the keyword: block, not individual sample. So, if you have a lot of heavy math and you have to do it in really short amount of time (say 32 samples), processing demands on the CPU will be much higher than if it were a larger block of samples, which can be spread out over time for processing (at cost of increasing latency). Therein lies the catch.

I guess "one Block" means 256 samples, in our example? (This question is about terminology that I'm not yet familiar with).

I agree with you then, the smaller the Block Size, the smaller is the time that the computer has to calculate the desired samples. This is a linear relation.
But: The smaller the Block size, the smaller the number of calculations that have to be performed, right? (In order to process 128 samples, the computer has to do half the work compared to processing 256 samples).

EvilDragon wrote:

It's like building a house in 3 days vs 30 days. What is more difficult? Of course, building it in 3 days.

To Stick to that example (and following my line of thought), I'd counter that it's as difficult to build one house in 30 days, as building 1/10 House in 3 days.

EvilDragon wrote:

What is an overrun, anyways? It's when the CPU takes MORE time to process ONE BLOCK of audio than the duration of the block itself. That is very much possible if the block is too short compared to the amount of math needed to process it fully.

Thank you for this definite explanation.

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

Quantumwhisp wrote:

But: The smaller the Block size, the smaller the number of calculations that have to be performed, right? (In order to process 128 samples, the computer has to do half the work compared to processing 256 samples).

Wrong. It's exactly the opposite, because timing requirement on that processing just got twice as strict. So, you have half the data to process compared to "original" buffer size of 256, but you also need to do it twice as fast, so again: processing requirements are increased, which means CPU has to "sweat more".

Last edited by EvilDragon (17-12-2017 12:45)
Hard work and guts!

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

EvilDragon wrote:
Quantumwhisp wrote:

But: The smaller the Block size, the smaller the number of calculations that have to be performed, right? (In order to process 128 samples, the computer has to do half the work compared to processing 256 samples).

Wrong. It's exactly the opposite, because timing requirement on that processing just got twice as strict. So, you have half the data to process compared to "original" buffer size of 256, but you also need to do it twice as fast, so again: processing requirements are increased, which means CPU has to "sweat more".

If I have half the data to process, but I also have to do it twice as fast (which means in half the time), shouldn't those effects cancel out?

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

No. Because PROCESSING DEMAND on the CPU is higher when the audio buffer size is low. If you have some complex math inside, it's going to be much easier on the CPU to spread it out over a larger buffer, because then it has more time to process it. If you take the same math and make the buffer too small, CPU won't be able to keep up and you get dropouts.

Just take it for a fact: lower audio buffer sizes WILL take more CPU. Higher sample rates at the same buffer size WILL take more CPU. Period.

Last edited by EvilDragon (18-12-2017 09:49)
Hard work and guts!

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

EvilDragon wrote:

No. Because PROCESSING DEMAND on the CPU is higher when the audio buffer size is low. If you have some complex math inside, it's going to be much easier on the CPU to spread it out over a larger buffer, because then it has more time to process it. If you take the same math and make the buffer too small, CPU won't be able to keep up and you get dropouts.

Ah ... I think what you're getting at. It's because of the way the CPU works that the time required for processing, the amount of to process data and the effort are not strictly proportional / antiproportional?

To use another quit simple example: It takes at least 2 hours to bake 16 little breads, because I have to make the dough, let them rise, and afterwards bake them for 1 hour.
This time won't change if I bake 8 breads. It still takes around the same time for the to rise and to bake, and a little bit less time for me to make the dough.
Then I'd get it.


EvilDragon wrote:

Higher sample rates at the same buffer size WILL take more CPU.

This I understand, it's absolutely logical to me.

Re: Setup with Ubuntu and Focusrite Scarlett 2i2 - Low Performance?

Yes. That bakery example is perfect.

Hard work and guts!