Topic: non-additive latency

Hello,

Just an interesting observation that may be of benefit to others: I was trying to determine the added latency of the sound produced by pianoteq and a scarlett 2i2, using my Kawai CA58 as a controller, as compared to the sound produced by the CA58 itself.

As others have said many times before there are other factors that significantly add to the overall latency, such as communication over USB, sound card / driver etc., which I also find -- no surprise there. However what I did find surprising was that the pianoteq latency setting does not appear to be just an additive factor to the overall latency. I.e. if I change the setting from 1.5 ms to 4.4 ms, the real latency does not just become 2.9 ms longer. In my case it becomes 10 ms longer. The difference becomes even disproportionally larger with longer latency settings. E.g. a latency setting of 20 ms results in an added latency of a whopping 144 ms. Here are my measurements:

Pianoteq latency setting -> overall real latency increase as compared to CA58
0.7 ms -> 9 ms
1.5 ms -> 12 ms
2.9 ms -> 17 ms
4.4 ms -> 22 ms
5.8 ms -> 23 ms
7.3 ms -> 30 ms
8.7 ms -> 35 ms
10.2 ms -> 47 ms
20.3 ms -> 144 ms

To measure the above, I routed my soundcard analog output to my piano's analog input, and recorded with a mic the resulting mix of the pianoteq/scarlett sound and the piano's own sound, played over the piano speakers. I changed pianoteq's diapason setting so that pianoteq and piano generate different frequencies in response to the same key stroke, facilitating latency measurement.
My laptop is based on Windows 10, i5 6200U @ 2.3 GHz, 8Gb RAM. Pianoteq @ 44.1 kHz, 48 polyphony. 0.7 ms is not a good setting for this system, but 1.5 ms usually plays nicely. Apparently this adds 12 ms latency with respect to the CA58's own sound.

Gabe

Re: non-additive latency

Hi,

interesting, thanks.

A few questions to the procedere.

Is the audio-input of your Kawai fully analog and therefore with zero latency? Or is it A/D-D/A converted in the Kawai? (probably not)

How do you measure the time difference? In an audio-editor by finding the startpoint of the two pianosounds in one wave? An example would be nice.

It would be interesting, how the onboard audiocodec (PCI) of your laptop behaves in comparison to the USB-Audiointerface Scarlett 2i2.

cheers

Re: non-additive latency

groovy wrote:

Is the audio-input of your Kawai fully analog and therefore with zero latency? Or is it A/D-D/A converted in the Kawai? (probably not)

Good point. I don't know. I assumed it is all analog from input to speakers, but perhaps not. In either case the surprisingly large differences between pt latency settings still stand as the analog input of the piano wouldn't know about any settings.

groovy wrote:

How do you measure the time difference? In an audio-editor by finding the startpoint of the two pianosounds in one wave? An example would be nice.

Yes, I used Praat (http://www.praat.org), which is designed for speech research, but also very usable for measuring sounds in general. Highly recommended, free, open, multi-platform. There is some room for improvement in the method I used, but I think it is reasonable. There may be a slight overestimation of the latency. Praat shows both the waveform and spectrogram at the same time.  I used the waveform. The start of the first (CA58-generated) sound is very easy to determine precisely, but the start of the delayed pt sound is a bit more difficult because it is superimposed on the CA58 sound which is much louder at this point in time. The spectrogram helps (the frequencies are different because I changed diapason), but I think the waveform is the way to go. I used the sound mix with the longest delay as a reference, and then compared the ones with the shorter delay to that and see where the waveform starts to diverge, as a result of the start of the pt sound. Of course, I made sure not to move the recording mic between measurements.

I am not sure if the above is sufficiently clear. If not I could provide screenshots / images, although I am not sure I can use them on this forum.

What could be improved is that I manually played the same key, but it might be better to play a midi file on the piano, so as to generate the exact same volume each time.

groovy wrote:

It would be interesting, how the onboard audiocodec (PCI) of your laptop behaves in comparison to the USB-Audiointerface Scarlett 2i2.

Not good probably. I can see if I can have a go at measuring this. I am not sure it has a line out, but there may be ways around this.

Gabe

Re: non-additive latency

A while ago, I performed some tests in a different way - easier in my opinion: record the same note on different tracks of a DAW, one coming from the digital piano, the other form Pianoteq. Look at the position of the waveform, done. But either way, you're always measuring apples and oranges...! I mean that the AD part (recording) also has a role to play.

Re: non-additive latency

AD/DA part is very very very short (a few samples usually), USB bus is what adds much more latency...

Last edited by EvilDragon (27-07-2018 14:30)
Hard work and guts!

Re: non-additive latency

groovy wrote:

It would be interesting, how the onboard audiocodec (PCI) of your laptop behaves in comparison to the USB-Audiointerface Scarlett 2i2.

I just checked this, the output from the laptop played over the laptop speakers, and the piano over the piano speakers. I.e. the test is not identical to the one of yesterday, but it captures more or less the difference one is interested in (latency difference to ears). The distance of the mic to either speaker system was short and the same, ~10 cm. I also now measured the key press to sound latency (by hitting the key fast with my nail to get an impulsive sound), this is ~ 20 ms on the CA58 (i.e from nail contacting the key to sound produced).

As to the onboard sound hardware/drivers:

In terms of latency the results are not nearly as bad as I thought as long as you find the right drivers. Here are the results:

driver and latency setting in PT -> overall real latency increase as compared to CA58

winaudio 48kHz / 192 samples, 4.0 ms -> 78 ms (44kHz was not possible)
winaudio exclusive mode  44kHz / 192 samples, 4.4 ms -> 14 ms (lowest setting available)
directsound 44kHz / 64 samples, 1.5 ms -> 77 ms (not usable for playing on this system, pops etc)
directsound 44kHz / 192 samples, 4.4 ms ->  115 ms

the ASIO4ALLv2 drivers (with onboard audio hardware):

asio4allv2 44kHz / 64 samples, 1.5 ms -> 10 ms
asio4allv2 44kHz / 256 samples, 5.8 ms ->  21 ms
asio4allv2 44kHz / 896 samples, 20.3 ms  47 ms

Focusrite scarlett 2i2, new somewhat improved measurements:

focusrite 44kHz / 16 samples, 0.4 ms -> 6 ms (not usable for playing on this system)
focusrite 44kHz / 32 samples, 0.7 ms -> 7 ms (not usable for playing on this system)
focusrite 44kHz / 64 samples, 1.5 ms -> 10 ms (a bit better than my measurement yesterday)
focusrite 44kHz / 128 samples, 2.9 ms -> 14 ms
focusrite 44kHz / 192 samples, 4.4 ms -> 19 ms
focusrite 44kHz / 256 samples, 5.8 ms -> 23 ms
focusrite 44kHz / 448 samples, 10.2 ms -> 44 ms
focusrite 44kHz / 896 samples, 20.3 ms -> 80 ms

Concluding: all in all it seems that the latency of onboard system (Realtek High Definition Audio) is not bad at all if you use asio4allv2 drivers or winaudio exclusive mode. The shortest latency (that is reasonably free of pops etc) can be obtained with asio4allv2 and focusrite scarlett, both adding 10 ms to the latency of the piano. From the nail contacting the key to sound is 20 ms on the piano, and 30 ms with asio4allv2 and focusrite scarlett (@ 1.5 ms PT setting).

The observation that I reported yesterday, that longer latency settings in PT lead to disproportionally longer actual latencies overall seems to hold across hardware.

Last edited by gabe (27-07-2018 15:39)

Re: non-additive latency

I tried something similar and also got large audible differences (surely 100-200 ms) between the analog output of my keyboard and simultaneously through pianoteq with the largest buffer size (2048 samples, 42.7 ms). I hear it by plugging my keyboard in an analog input of my Roland Duo-Capture and listening through headphones with direct monotoring while pianoteq goes through the AD/DA chain. I can't record this to see the wave file, though...if I record the resulting combined output of the Roland inside my Mac Pro, I get a mostly correct difference in the two wave files beginning of about 60 ms for the 2048 sample buffer since both inputs now go through the AD/DA chain. For my usual setup of 64 samples (1.3 ms) the two wave files are almost undistinguishable audibly as well as visually.

I guess then that this long audible delay is not due to pianoteq itself. I don't know where the non linearity comes from though...

Last edited by Gilles (27-07-2018 16:08)

Re: non-additive latency

Luc Henrion wrote:

A while ago, I performed some tests in a different way - easier in my opinion: record the same note on different tracks of a DAW, one coming from the digital piano, the other form Pianoteq.

If the DAW hardware is independent of the Pianoteq hardware, I agree with you.

Luc Henrion wrote:

But either way, you're always measuring apples and oranges...! I mean that the AD part (recording) also has a role to play.

But if that part is identical, then the difference is still valid, right? I.e. if you record on the same device (with a mic or analog input) in parallel the acoustic/analog output of the piano and the acoustic/analog output of the system that runs Pianoteq, then the latency difference is what you would experience when you are playing.

Re: non-additive latency

The way I was doing it was sending a very basic MIDI sequence consisting of just one note, both to a digital piano and to PTQ, and to record simultaneously the output of both on 2 separate tracks. There is no PTQ "hardware" AFAIK ! ;-) Instead, PTQ had no AD conversion needed, while the piano did. So you could expect a slight advantage for PTQ. As Evildragon points, it's a small difference anyway, but then you'd have to add the interface itself input latency: USB (or Firewire, or PCI, or any other). In fact, I performed this test to various synths and pianos, and the results were close but very different altogether... You would be surprised.

Re: non-additive latency

Luc Henrion wrote:

The way I was doing it was sending a very basic MIDI sequence consisting of just one note, both to a digital piano and to PTQ, and to record simultaneously the output of both on 2 separate tracks. There is no PTQ "hardware" AFAIK ! ;-) Instead, PTQ had no AD conversion needed, while the piano did. So you could expect a slight advantage for PTQ. As Evildragon points, it's a small difference anyway, but then you'd have to add the interface itself input latency: USB (or Firewire, or PCI, or any other). In fact, I performed this test to various synths and pianos, and the results were close but very different altogether... You would be surprised.

That's the result I also get with my test: the digitally recorded result for the analog piano output vs pianoteq is consistent with the given buffer size. What is left unexplained (to me and Gabe I guess) is the fact that when listening live to the result (not the recording) the delay increases non-linearly with the buffer size. If you do your test only with a minimal pianoteq buffer and listen at the same time, you don't hear much delay. Where does that non-linearity happen? The unescapable latency should be fixed whatever the buffer size and only be additively increased by the pianoteq buffer. The recording is, but not the live output...

Re: non-additive latency

gabe wrote:

this is ~ 20 ms on the CA58 (i.e from nail contacting the key to sound produced).

This matches to my old Kawai ES3 with 22 ms:
https://www.forum-pianoteq.com/viewtopi...8593#p8593

gabe wrote:

latency of onboard system (Realtek High Definition Audio)

Hmm, onboard seems to be better or equal to USB on your Laptop at the most interesting buffer-size (64 samples):

onboard audio hardware
1.5 ms -> 10 ms

USB Scarlett 2i2
1.5 ms -> 12 ms
1.5 ms -> 10 ms (new somewhat improved measurement)
2.9 ms -> 17 ms
2.9 ms -> 14 ms (new somewhat improved measurement)

In the past onboard PCI was 5 ms better than an external USB Scarlett 2i2 here:
https://www.forum-pianoteq.com/viewtopi...14#p939514

Thanks for your link to http://www.praat.org. Didn't know that and I see this software is in my linux-distribution (Debian). Your explanation was good, but a picture says more, than thousand words. You can post images in the forum, but I don't know, which hoster is good. Sometimes postimages.org is used.

Last edited by groovy (28-07-2018 05:27)

Re: non-additive latency

My current setup for Pianoteq v6.2.2 is an Intel N4200 notebook with onboard audiocodec ALC255. Let's see, how the lag of this is compared to my Kawai ES3 Stagepiano.

The method used is a dual channel recording. Left channel is recorded from line-out of my ES3. Right channel is the headphone-output of my notebook. PTQ is triggered by MIDI from the ES3.

For example PTQ with 64 samples audio buffer at 44.1 kHz samplerate results in a lag of 7 ms versus ES3 internal audio:

https://s8.postimg.cc/gbxd4mpth/example-_ES3-vs-_PTQ-latency.png

Other common buffersizes from 128 to 256 samples increase the lag linearly in this environment:

                 
samples   buffer[ms]  lag[ms]
64           1.5            7
128         2.9            12
192         4.4            15
256         5.8            19

https://s8.postimg.cc/cgtz1o945/PTQ-lag-vs-_ES3-buffer-depending.png

MIDI events used are C4 note-ons recorded on the ES3. I always used the second note, because there seems to be something like an wake-on-effect with the first MIDI-note. Maybe because CPU-upscaling starts, buffers are filled the first time or something. This effect needs a few milliseconds on my system, for example the 7 ms lag at 64 samples is 2 ms longer then (=9 ms).

Instrument in the test was Steinway D Player Clean with all default effects (like delay! and reverb) switched off.

cheers

Last edited by groovy (28-07-2018 09:26)

Re: non-additive latency

groovy wrote:

(like delay!

Not that delay as used in the patch actually delays the note on...

Hard work and guts!

Re: non-additive latency

EvilDragon wrote:

Not that delay as used in the patch actually delays the note on...

The default delay in "Steinway D Player Clean" delays the dry signal with 60 ms. But it only has 3 % amount in the mix with the dry signal, so this effect has no impact on our topic, yes. The dry signal is always present.

Re: non-additive latency

groovy wrote:

Other common buffersizes from 128 to 256 samples increase the lag linearly in this environment:

Groovy, I now measured things using your method, routing the analog outputs to a sound card and establishing the latency difference. The signal to noise ratio is a lot better this way, and I am willing to assume that the last step, analog -> to acoustic, which is not captured, has zero latency. Having a better s/n ratio shaves off a few ms of my original 'acoustic' measurements, presumably due to systematic measurement error as the start of the lagging sound was masked. I chose Steinway D Clean and switched delay and other effects off, measuring the second note in a series. I can confirm the non-additive but largely linear relationship between buffer setting and lag. See the results:

results

Interestingly, latency-wise the scarlet 2i2 is only better than the on-board hardware at low buffer settings (<= 2.9 ms). At 1.5 ms buffer, I measure a 7 ms lag with scarlett, and 9 ms with on-board sound. But these are rounded to the nearest ms. More precisely, the lag of the on-board system is only 1.3 ms more than that of the scarlett at this buffer setting.

The disproportional increase in lag with longer buffer settings, which I started the thread with, remains true for both systems, though with a different linear function.

Re: non-additive latency

Hi gabe,

I have a Focusrite 2i2 also, so I could check this USB-device too:

https://s8.postimg.cc/z6tkduts5/PTQ-lag-vs-_ES3-buffer-depending-2.png

The 2i2 is worse than the onboard ALC255 in my environment. Every additional 1 ms PTQ audiobuffer increases the lag with 4.0 ms in other words.

With ALC255 every additional 1 ms  PTQ audiobuffer increases the lag just with 2.7 ms (see Trend Line Equation).

I have to amend, that I never had tried to tweak/optimize the USB-audiopath on that notebook. Maybe there is some hidden potential, looking at your interesting results with the 2i2.

gabe wrote:

The disproportional increase [...]

... how do you mean that? The increase is proportional or are your axis scaled logarithmically? 

cheers

PS:
Below my raw values, sometimes image-hosters disappear or change their URL and all images and work are lost then.
--------------------------------------------------------------------------------
        ALC255    Scarlett 2i2
    [ms]    [ms]    [ms]
samples    PTQ audiobuffer    lag (PCI ALC255)    lag (USB Scarlett 2i2)
64    1.5    7    12
128    2.9    12    21
192    4.4    15    25
256    5.8    19    30
---------------------------------------------------------------------------------

Re: non-additive latency

You sure you have the latest drivers for your 2i2? Focusrite released them a few months ago (even for the old gen1).

Hard work and guts!

Re: non-additive latency

Does Focusrite support the Linux-Kernel?

Re: non-additive latency

Not sure. Probably not. I guess that'd explain your results if you're using some sort of generic driver...

Hard work and guts!

Re: non-additive latency

groovy wrote:
gabe wrote:

The disproportional increase [...]

... how do you mean that? The increase is proportional or are your axis scaled logarithmically?

Unfortunate wording indeed. Axes are linear. It is proportional in the sense that there is a linear relationship, but I would have expected the effect to be additive. That is, that an increase of the buffer in PT would increase the overall latency just with that amount, as the latency by other factors such as USB etc would remain the same. In that case the slope of the line in our graphs would be 1. But it clearly isn't. In my case the slope is 2.0 for on-board realtek and 3.8 for scarlett. In the latter case, increasing the PT buffer for example with 5 ms increases the overall latency with 19 ms. Strange.

groovy wrote:

Below my raw values, sometimes image-hosters disappear or change their URL and all images and work are lost then.

Good point. My measurements are:
PTEQ buffer duration (ms), scarlett lag (ms), onboard lag (ms)
1.5,      7.,     9.
2.9,     10.,   n/a
4.4,     16.,   n/a
5.8,     21.,   18.
11.6,   44.,   30.
17.4,   60.,   41.
21.8,   86.,   49.

Re: non-additive latency

EvilDragon wrote:

Not sure. Probably not. I guess that'd explain your results if you're using some sort of generic driver...

I think this is the case, they do not provide support for linux. The 2i2 does work on my Ubuntu linux computer though (but I guess that is almost the same as Groovy's Debian), but my piano laptop is windows and has the latest focusrite drivers. Another thing to note is that there is a first and a second generation 2i2. I have the latter.

I forgot to mention that I connect the CA58 piano with USB to my laptop. So midi is over USB, not over a midi cable.

Last edited by gabe (28-07-2018 21:42)

Re: non-additive latency

I did some quick-and-dirty latency tests a few years ago and had much different results.

That might be due to RME ASIO drivers or user error but I tried a bunch of testing methods to make sure the results were reasonable, including recording everything with one mic on one channel only.

My approach was similar to that of Luc Henrion. I don't remember all the details but basically ran the following:

- Kawai es100
- MIDI DIN cable to BabyFacePro to PianoTeq laptop#1 back to BabyFacePro
- Recording output with Audacity on laptop #2

I tried recording on laptop #2 a few ways. For example, comparing headphone out of es100 to that of BabyFacePro. I also tried recording via mics: fingernail hitting key, MIDI signal from es100, sound from es100 speakers, sound from monitors connected to BabyFacePro. etc.

Time between fingernail hitting key and:

- es100 internal sound output of es100 headphone out was less than 5ms and fastest I recorded.
- es100 to BFP to PianoTeq to BFP headphone out was just a bit more than 5ms (I think with PianoTeq at say 48KHz and a buffer of 64)
- PianoTeq had somewhat lower recorded latency than I could obtain with some sampled VIs; felt lower also.

Not sure why the es100 internal sounds are so fast. Onboard es100 Keyscanning, processing and MIDI buffering? Optimised onboard hardware and software?

Loudspeakers added about 4ms of latency to player position, which made sense given distance was a bit more than 1 metre.

Regardless, at these levels I don't notice a difference in latency between es100 internal sounds and PianoTeq via said chain.

Re: non-additive latency

music_guy wrote:

Time between fingernail hitting key and:
- es100 internal sound output of es100 headphone out was less than 5ms and fastest I recorded.

Really? See above:

gabe: ~ 20 ms, Kawai CA58
groovy: 22 ms, Kawai ES3
music_guy: 5 (?) ms, Kawai ES100

@gabe:
With a dirty trick I can boost my USB-Audio. Using PTQ with 88200 Hz samplerate and 64 samples I can achieve the same minimum lag of 7 ms, that I have already with the Onboard (PCI) ALC255 at 44100 Hz. But that higher samplerate is wasting audio load excessively. With the N4200 (perf-index 43) no real deal.

But on my Intel i5 with perf-index ~ 90 a valid option/work-around.

But I'll keep on playing my N4200 with onboard codec ...

cheers

Last edited by groovy (29-07-2018 21:47)

Re: non-additive latency

gabe wrote:

slope [...] Strange.

I found some useful Information in the latest README_LINUX.txt from Pianoteq v6.2.2:

"* with Jack or Alsa, use buffer sizes that are multiple of 64, as Pianoteq prefers those
   sizes. With the Alsa driver, the latency is 3 times the buffer size (a buffer of 64 samples at
   44100Hz gives a latency of 4.3 ms)."

I guess that is a corrected version of the text in Pianoteq v5:

" - with Jack or Alsa, pick-up buffer sizes that are multiple of 64, as
   Pianoteq prefers those sizes. With the Alsa driver, the latency is
   2 times the buffer size (a buffer of 64 samples at 44100Hz gives a
   latency of 2.9 ms)."

So if the new README is correct, the best theoretical slope we can expect with Alsa drivers is 3 ("latency is 3 times the buffer ...").

Let's look at my regression lines:

PCI ALC255: f(x) = 2.7x + 3.4
USB 2i2: f(x) = 4.0x + 7.3

The on-board-PCI with slope 2.7 is near the theoretical minimum 3. The usb-audio-path with 4.0 is just a bit more sensitive for buffer size changes in a negative way.

What about the other constants in the equation?
ALC255: 3.4 (ms)
2i2: 7.3 (ms)

In my interpretation the 2i2 path is constantly 3.9 ms behind the ALC255 (7.3 - 3.4 = 3.9) and the dynamic increase/slope is superimposed.

A conclusion could be:

* The Alsa driver for USB (snd-usb-audio) has not ideal slope of 3 like the Alsa driver for the Realtek ALC255.

* USB-Audio at best lags 3.9 ms behind the PCI-Path on my PC-system.

* My 2i2 is 1st gen, gabe's 2nd gen. Maybe the newer hardware has less latency or the USB audio-driver is better latency-wise or something I don't know .

PS:
I guess the weak point is the snd-usb-audio, because I have the same latencies with two other USB-Audiointerfaces .

Last edited by groovy (30-07-2018 18:46)

Re: non-additive latency

groovy wrote:

A conclusion could be:

* The Alsa driver for USB (snd-usb-audio) has not ideal slope of 3 like the Alsa driver for the Realtek ALC255.

* USB-Audio at best lags 3.9 ms behind the PCI-Path on my PC-system.

* My 2i2 is 1st gen, gabe's 2nd gen. Maybe the newer hardware has less latency or the USB audio-driver is better latency-wise or something I don't know .
PS:
I guess the weak point is the snd-usb-audio, because I have the same latencies with two other USB-Audiointerfaces .

Very interesting. Despite differences in the specific latency function parameters with differing hardware and OS, it seems that the steeper slope of the 2i2 is a consequence of the fact that it is a USB device. I would guess that focusrite's Windows drivers are highly optimized and while they do not even support Linux, the slope on both platforms is the same: 4.

Re: non-additive latency

gabe wrote:

Despite differences in the specific latency function parameters with differing hardware and OS, it seems that the steeper slope of the 2i2 is a consequence of the fact that it is a USB device. I would guess that focusrite's Windows drivers are highly optimized and while they do not even support Linux, the slope on both platforms is the same: 4.

I agree with you.

But I don't know, if Focusrite is to blame. The Scarlett 2i2 (1st gen) is USB Class Compliant and works fine on Linux, just the latency for realtime is not the best on (at least) my Linux-Kernel.

Re: non-additive latency

groovy wrote:

But I don't know, if Focusrite is to blame. The Scarlett 2i2 (1st gen) is USB Class Compliant and works fine on Linux, just the latency for realtime is not the best on (at least) my Linux-Kernel.

The plot thickens... I should stop doing these measurements and play the piano, but to satisfy my curiosity I did the same type of measurement on an old (~6 years) Macbook Air (i5). Same piano, CA58. Surprisingly the 2i2 does not scale with a factor 4, but it is much better now:

buffer size / latency PTEQ -> lag

2i2:

64    1.5 ms  ->  5 ms
128   2.9 ms  ->  8 ms
256   5.8 ms  -> 14 ms
512   11.6 ms -> 25 ms
1024  23.2 ms -> 48 ms

macbook air i5 onboard:

64    1.5 ms  ->  7 ms
128   2.9 ms  -> 10 ms
256   5.8 ms  -> 16 ms
512   11.6 ms -> 27 ms
1024  23.2 ms -> 50 ms

The both scale with ~ factor 2. And the latencies are good. And it plays well:  at the shortest latencies no noticeable artifacts. The i2i is 2 ms better than the mac hardware, in terms of latency.

I should add that I noticed that the pianoteq sound starts with a very low amplitude oscillation that I did not include in all measurements reported, because I wasn't sure what it was. It looks as part of the sound, though.If it is included that would shave off 1 ms from all latencies.

Re: non-additive latency

gabe wrote:

macbook air i5 onboard

Just for curiosity - which vendor/chipset is the onboard codec on that macbook?

Re: non-additive latency

groovy wrote:

Just for curiosity - which vendor/chipset is the onboard codec on that macbook?

I have a hard time finding this in Mac OS, which I hardly use. It is a work laptop that I use for presentations mostly. If I boot the machine in Linux, I find that the audio device is: 7 Series/C210 Series Chipset Family High Definition Audio Controller, by Intel.

The old mac seems to do better than my relatively new (1.5 years) Windows 10 laptop (LENOVO YOGA 510-14ISK) which I specifically bought for the piano....

Re: non-additive latency

gabe wrote:

7 Series/C210 Series Chipset Family High Definition Audio Controller, by Intel.

Sorry, but thanks for your efforts!

That is just the controller at the PCI-bus, often shortnamed "Intel HDA" type.

Analog to the output of a (Samsung-)notebook for example:

# lspci | grep Audio
00:1b.0 Audio device: Intel Corporation 7 Series/C216 Chipset Family High Definition Audio Controller (rev 04)

The audiocodec behind that controller is an Realtek ALC269V in this example:

# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC269VC Analog [ALC269VC Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Re: non-additive latency

groovy wrote:

# aplay -l

Aha, I see. Following your example, it turns our this macbook has the Cirrus Logic cs4206.

Re: non-additive latency

Thank you!

EDIT:
Scarlett is using Cirrus Logic too.
Interesting document about latency of 2i2 1st and 2nd gen here:
http://caulixtla.com/JP-08/2i2.html

Last edited by groovy (31-07-2018 15:32)

Re: non-additive latency

BTW I have a new hypothesis, why the Scarlett 2i2 1st Gen could have more latency, than the newer 2nd Gen.

The max. samplerate of 1st Gen is 96 kHz. So it only can be compliant to USB Audio Class 1 (UAC1).

The 2nd Gen is specified with 192 kHz samplerate, which means it could be USB Audio Class 2 (UAC2).

I found a nice PDF with the title Why do you need USB Audio Class 2?

Interesting are the Streaming differences (Table 6):

UAC   Streaming latency
-----------------------
UAC1  4ms
UAC2  500μs

That reminds me of the  3.9 ms static lag of my 2i2 (1st Gen) compared with onboard PCI-Audio. Could be the amount for UAC1.

On the other hand the Linux-kernel is supporting UAC2 for years now, so chances are good, that the Focusrite Scarlett 2i2 2nd Gen will have lower latencies with generic alsa-driver (should 2nd Gen really be UAC2 compliant).

PS: And it would fit in the picture, that I found the same latencies (@64 samples) with two other UAC1-Audiointerfaces, Behringer UCA-222 and Esi Maya22.

Last edited by groovy (02-08-2018 13:13)

Re: non-additive latency

Why not ask to Focusrite directly? Their after sales service is good.

Re: non-additive latency

groovy wrote:

I found a nice PDF with the title Why do you need USB Audio Class 2?

Interesting info. Thanks!

Re: non-additive latency

In comparison my new 2i2 2nd gen (B-Stock) has better latency, than 1st gen.

I installed JACK Audio Connection Kit and jack_iodelay to determine the Round-Trip-latency. Output and input are looped with a patch-cable. Settings in jackd 44100 Hz, 64 samples, 2 periods.

Two examples:

2i2 1st:
   520.655 frames     11.806 ms total roundtrip latency
        extra loopback latency: 328 frames
        use 164 for the backend arguments -I and -O

2i2 2nd:
   359.706 frames      8.157 ms total roundtrip latency
        extra loopback latency: 167 frames
        use 83 for the backend arguments -I and -O

But that was in JACK's default asynchronous mode, which means one extra period is used (2 + 1 = 3). With jackd -S prefix the daemon is started in synchronous mode and really 2 periods are effective. Result is a slightly better RT-latency, example:

2i2 1st:
   468.655 frames     10.627 ms total roundtrip latency
        extra loopback latency: 340 frames
        use 170 for the backend arguments -I and -O

2i2 2nd:
   307.706 frames      6.977 ms total roundtrip latency
        extra loopback latency: 179 frames
        use 89 for the backend arguments -I and -O


Without JACK and just ALSA directly in PTQ the new hardware although was just 1 ms better than the 1st gen Scarlett, not really significant.

But using JACK in synchronous mode with Pianoteq I have won 4 - 5 ms now. In other words, compared with my Kawai ES3 the 1st gen had 12 ms lag, while 2nd gen (and JACK) has a lag of just 7 - 8 ms now.

That is practically the same lag I had with the on-board Codec (7 ms). Fine.

For the next time I will play PTQ with the 2i2 2nd gen.

@modartt
Does the change from "2 times" to "3 times" in your newer README_LINUX.txt mean, that PTQ feeds ALSA with 3 periods of 64 samples in this scenario since v6.x, while JACK can feed ALSA with a minimum of 2 periods in synchronous mode?

Last edited by groovy (12-08-2018 22:33)

Re: non-additive latency

groovy wrote:

Really? See above:

gabe: ~ 20 ms, Kawai CA58
groovy: 22 ms, Kawai ES3
music_guy: 5 (?) ms, Kawai ES100

groovy wrote:

But using JACK in synchronous mode with Pianoteq I have won 4 - 5 ms now. In other words, compared with my Kawai ES3 the 1st gen had 12 ms lag, while 2nd gen (and JACK) has a lag of just 7 - 8 ms now.

That is practically the same lag I had with the on-board Codec (7 ms). Fine.

Are you saying that the latency on your ES3-PianoTeq has fallen from 22ms to 7-8ms?

For clarity, is that 7-8ms from finger triggering a key to sound output of say a headphone?

Thanks

Re: non-additive latency

music_guy wrote:

Are you saying that the latency on your ES3-PianoTeq has fallen from 22ms to 7-8ms?

For clarity, is that 7-8ms from finger triggering a key to sound output of say a headphone?

No, the internal sound at the line-out of my Kawai is just a reference point. My notebook with PTQ v6.2.2 has always a lag / delay compared to that (both sound-engines are triggered by the same midi-event from the Kawai). All the times are just relative.

For the concept see my 12th post:
https://www.forum-pianoteq.com/viewtopi...73#p955473

Last edited by groovy (13-08-2018 06:50)

Re: non-additive latency

groovy wrote:

@modartt
Does the change from "2 times" to "3 times" in your newer README_LINUX.txt mean, that PTQ feeds ALSA with 3 periods of 64 samples in this scenario since v6.x, while JACK can feed ALSA with a minimum of 2 periods in synchronous mode?

Yes, that's correct.

Re: non-additive latency

Thank you, julien!

Maybe it could be an option in later PTQ-versions to select between 2 or 3 periods in ALSA output for those, who are manic and squeeze every millisecond from given hardware.

cheers