Topic: Latency and the number of samples...

First off: Thanks Moddart for releasing such a beautiful instrument. You have managed to make a great product even better.:lol:

I'd like to know the opinion of the community over this: AFAIK, there is a direct relationship between the number of samples and the latency, although Im still not sure because the number of milliseconds that appear beside the number of samples used by PT3 is described evidently as "audio buffer size".
Now, if it is, what is the difference between this concept of buffer size and latency? Are they the same right? Please note that I am not an expert in these matters (I have been unable to test for what they call "midi latency" in my computers because I just dont know how to do it in Macs)
So, the best settings for the audio should be more than 512 samples? What's the ideal number to obtain a better sound? What is the drawback? (there's always a catch, right?) I'd like to take the best of the performance of PT and my machines while have the lowest possible latency with the best sound possible....

My other question has to do with the so called Internal sample rate and the Host sample rate. Is normal that PT3 has a "top" or ceiling in terms of those numbers?. Let me rephrase the question: If I have a host sample rate of 96000Hz, why is it that PT3 does not handle that same number? It is normal that it can only reach 48000Hz?. Perhaps this is a bit too technical and, moreover, I may not know how to put the question.
I apologize if I'm not making any sense.

Thanks

Last edited by mimoviz (28-02-2009 15:58)
Guillermo
____________________________
Yamaha CVP-309PM --- Casio PX-720
iMac 20' 2.6Ghz/MacBook Pro 2.4Ghz

Re: Latency and the number of samples...

Pianoteq seems to have a maximum sample rate of 48k.

I did ask before if there were plans to increase it to 96k -
I expect real pianos also make acoustic energy in that extra octave of harmonics between 20kHz and 40kHz,
and I continue to wonder if the pianoteq model would sound any different if it took this into account
(it seems to pay so much attention to so many other things,
so why not this?)

Re: Latency and the number of samples...

So, the best settings for the audio should be more than 512 samples?

Guillermo
____________________________
Yamaha CVP-309PM --- Casio PX-720
iMac 20' 2.6Ghz/MacBook Pro 2.4Ghz

Re: Latency and the number of samples...

mimoviz wrote:

So, the best settings for the audio should be more than 512 samples?

No, the smaller the better for latency. On my Tascam US-122, I get 256 samples (24 bits) giving 5.3 ms latency at 48KHz which, to me, is instantaneous.

You have to increase the buffer only if you get audible cracks or delays.

Re: Latency and the number of samples...

Latency can be difficult to understand.  The way it works is this:

Audio application send sound data to the sound card, but they don't send them one sample at a time as that would be really inefficient.  Instead they send a buffer's worth of samples in one go.

This means that they first have to fill that buffer before they can send it - that's why a larger buffer = larger latency.  It takes longer for the sound to make it to the card (latency = late).

So smaller buffers/latency are better, but if the system is busy, then it can cause dropouts or glitches.  So you want to go as low as you can, without getting clicks or dropouts.

EDIT:

The reason for dropouts is that smaller buffers means they have to be sent more frequently.  If the system is busy doing something else at that point, it may not be able to send the data to the card in time, and this causes the glitches/dropouts.

Last edited by ReBased (28-02-2009 20:50)

Re: Latency and the number of samples...

ReBased wrote:

Latency can be difficult to understand.  The way it works is this:

Ao smaller buffers/latency are better, but if the system is busy, then it can cause dropouts or glitches.  So you want to go as low as you can, without getting clicks or dropouts.

Thanks man. I got it now!

Guillermo
____________________________
Yamaha CVP-309PM --- Casio PX-720
iMac 20' 2.6Ghz/MacBook Pro 2.4Ghz

Re: Latency and the number of samples...

feline1 wrote:

Pianoteq seems to have a maximum sample rate of 48k.

I did ask before if there were plans to increase it to 96k -
I expect real pianos also make acoustic energy in that extra octave of harmonics between 20kHz and 40kHz,
and I continue to wonder if the pianoteq model would sound any different if it took this into account

There are 2 issues here. (1) would PTQ sound better if its sample rate was 96 kHz? (2) do frequencies emitted by instruments above 20kHz need to be reproduced?

(1) The answer depends on the frequency limit set when the PTQ piano sound is compiled. As this is internal to the software implementation of the synthesis, it can be made to simulate a perfect theoretical "brick-wall" anti-aliasing filter (in fact that would be the simplest filter to implement!). So, as long as this frequency limit is below 0.5 x sampling rate, there cannot be any sonic improvements from adopting a higher rate.

This is quite different from recording and digitising piano sounds, where the the microphone used may have a small but significant frequency output above 20KHz - and the downstream recording equipment is designed to accommodate this - so that the data stream output from the D/A converter contains frequencies which potentially could alias back into the audible range at low level and be perceived as a more or less subtle distortion.

(2) This has been an issue that has been around in acoustics and audio for decades. It has generally been assumed that since the human ear cannot hear sine waves above (nominally) 20kHz, that it is not necessary to reproduce them. I have seen some research from the 1990's done with gamelan music and using equipment that could reproduce 50-60kHz, which indicated that the presence/absence of these frequencies is detectable.  But because a difference can observed, does it mean that it is important to reproduce sound  to 60KHz? I am not convinced (and not just because I cannot hear 10kHz any more )

There is a simple example of an observable difference, that does not seem to have a large bearing on reproduced music - the absolute acoustic phase of a sound wave. Consider the recording of a kick drum: the mic is placed on the audience side of the drum. The initial sound that arrives at the mic is a compression wave . That means that in a domestic living room, etc the initial sound should be delivered by the speakers as a compression and not a rarefaction, i.e. the drive unit diaphragms to move outwards. In practice, many people can hear a difference - you can try it easily by simply reversing the loudspeaker + and - leads. (To my ears the difference is quite gross). But it is not evident from "blind" listening which is the correct sound. And it is of course impossible to know when listening to recorded music which is the intended sound. The recording chain may contain equipment which reverses the phase 180 degrees - indeed, most recording consoles have a button expressly for that purpose.

Gilles wrote:

I get 256 samples (24 bits) giving 5.3 ms latency at 48KHz which, to me, is instantaneous.

Latencies mentioned on sound driver control panels often do not include additional latencies due to internal data buffers. The only way of determining the real latency is with "round trip" methods. I think it is due to the fact that real latencies are not known, that the empirical rule of thumb has evolved to set latency in the driver as low as possible, but not so low that causes audible glitches or breakups.

I think a reasonable latency to aim for in the equipment is 3 ms. This number was discovered by accident long before computers. In the early days of sound reproduction, cinema speakers used multi-way horns. At first, these horns were aligned with their mouths in the same plane. All seemed well - until the film showed an actor tap-dancing (Mr Bojangles?). Then the sound had clear and distinct echoes. This was due to the path difference between the different drive units. When the horns were moved so that the difference between the horn throats was less than about 1 metre, the echoes disappeared.

It's easy to appreciate that a drummer playing an electronic kit may be disconcerted by an acoustic latency, especially if the speakers are more than about 2m from him. But pianists invariable face a latency in the hammer action of a real piano that is an order of magnitude greater than this 3 ms psychoacoustic limit.

Re: Latency and the number of samples...

hyper.real wrote:

It's easy to appreciate that a drummer playing an electronic kit may be disconcerted by an acoustic latency, especially if the speakers are more than about 2m from him. But pianists invariable face a latency in the hammer action of a real piano that is an order of magnitude greater than this 3 ms psychoacoustic limit.

Hyperreal: Thanks for your well written answer. I had not idea of such things (horns) before. Anyway, is it correct when you are assuming that the latency in a real piano revolves around 30ms? If so, then what the software tries to do is far from being all too real, but fancy the need of musicians. Hmmm, this sounds as if the real piano qualities (both good and bad) gets discarded or, better, substituted by a "virtual" piano that only exist in our imagination... without delays and glitches.

Anyway, I don't presume to be expert  on this area. I'm 38 years old as of last month and, I have always played with "fake" pianos. Just had some chance to play with the real stuff during classes at the Conservatory, so.... I don't really miss any of the sound qualities that identify the piano against any other instrument.
Strange...

Anyway, thanks again for a great reply.

Last edited by mimoviz (01-03-2009 14:22)
Guillermo
____________________________
Yamaha CVP-309PM --- Casio PX-720
iMac 20' 2.6Ghz/MacBook Pro 2.4Ghz

Re: Latency and the number of samples...

ReBased wrote:

Latency can be difficult to understand.  The way it works is this:

Audio application send sound data to the sound card, but they don't send them one sample at a time as that would be really inefficient.  Instead they send a buffer's worth of samples in one go.

This means that they first have to fill that buffer before they can send it - that's why a larger buffer = larger latency.  It takes longer for the sound to make it to the card (latency = late).

So smaller buffers/latency are better, but if the system is busy, then it can cause dropouts or glitches.  So you want to go as low as you can, without getting clicks or dropouts.

EDIT:

The reason for dropouts is that smaller buffers means they have to be sent more frequently.  If the system is busy doing something else at that point, it may not be able to send the data to the card in time, and this causes the glitches/dropouts.

Thanks for the clear concise description - it clears up a lot of things.

Glenn

__________________________
Procrastination Week has been postponed.  Again.

Re: Latency and the number of samples...

Hyper real,
I would imagine that when modelling the interactions of string harmonics and the soundboard, etc,
then it could well "make a difference" if the model considered frequencies in that extra octave (20kHz - 40kHz).

The issue is not really "can the human cochlea respond to these frequencies directly?" -
it is that interactions of these frequencies can produce results in the audible band (sum and difference tones, etc)

Re: Latency and the number of samples...

mimoviz wrote:

is it correct when you are assuming that the latency in a real piano revolves around 30ms?

Please take that as a very approximate figure.  I expect it varies with the design of the action.  Also, from the player's perspective surely the attack also affects the subjective sensation of latency, don't you think? 

Very occasionally, I go to the keyboard and my brain cannot adjust to the latency compared to acoustic guitar - and I fail!

feline1 wrote:

when modelling the interactions of string harmonics and the soundboard, etc,
then it could well "make a difference" if the model considered frequencies in that extra octave (20kHz - 40kHz).

A bit off topic, but...

I would expect some acoustic energy to be produced by a real piano above 20kHz - mostly from the metallic bits - not a great amount. I can't say at what level as I've not done or seen measurements.

feline1 wrote:

The issue is not really "can the human cochlea respond to these frequencies directly?" -
it is that interactions of these frequencies can produce results in the audible band (sum and difference tones, etc)

I would say - show us the evidence for that, either empirical or mathematical in relation to musical instruments.

The mathematical equations of acoustics have solutions which appear as nodes (sharp pointy bits on a graph - ouch), and these correlate well in the frequency domain with the observed sonic properties of physical materials.  PTQ is strong evidence for the truth of that statement!  From the point of view of the maths, the concepts of harmonic overtones, or sum and difference tones, are not inputs to the process. For some physical materials and configurations, the solutions to the equations closely approximate a harmonic overtone series (e.g. a taut string), but in others not (e.g. plate or bell). The appeal of PTQ is that it captures the reality of both the harmonic overtone series, and the subtle but real deviation from simple frequency multiples (inharmonicity).

Are there equations of acoustics whose solutions include sum and difference tones? An interesting question, and I haven't a clue what the answer is. If there are, they are not the primary ones - but I suspect that they would entail a radically different approach to the basic inputs of mass, elasticity, and the bulk properties of materials. Perhaps there is room for such equations in modelling musical instruments. Is there a need?

I am not sure of that either. In the physical world, sum and difference tones do not seem to contribute much to the timbre of a musical instrument, as the physical configuration does not support their longevity, i.e. the things are optimised to have relatively low amounts of internal energy damping at the "musical" frequencies of note production, so that these sounds have "sustain". That in turn implies that S+D tones will tend mostly to fall at frequencies where the combination of impedances and damping means only a small acoustic output is possible. And at this point, psychoacoustics comes in - things like the subjective masking of low-level tones by high amplitude ones. the perception of transients compared to steady tones, etc.

None of that is to disparage "golden ears" - criticism and dissatisfaction are strongly motivational to improving any status quo.

Re: Latency and the number of samples...

I might expect to hear a 'beat frequency' between two piano string harmonics in the 20k - 40k range as an audible thing?

What is the fundamental frequency of the top piano strings? Around 8kHz? Their 8th partials will be 'supersonic', will they not?

If I cranked up the 8th harmonic on the pianoteq spectrum profile, I could put a lot of acoustic energy up there.....