• ### For [phasor~]- and [vline~]-based samplers, how can we be sure all samples are being played?

Hey guys just had a thought here.

Usually when making a sample player with [phasor~] or [vline~], the foundation looks something like this:
My question is that do both these objects, [phasor~] and [vline~], generate all the points needed to playback every sample at whatever audio rate (44.1 khz or otherwise)?

• Posts 11 | Views 2639
• Hmm, that's a good question. My guess is that every "tilde" type of object should output signal data at the same rate as the audio rate. The problem I see now is related to that multiplication you are using: since [phasor~] and your particular construction of [vline~] above both go from 0 to 1, and then are multiplied by a constant, you will sometimes get numbers that are not integers and which I suppose are rounded by [tabread4~] (since indexes of an array should always be integer).

A probably better way of doing this would be to already construct the whole patch in a way to avoid the rounding. If your maths are accurate, then it [line~]'s output will always be exactly +1 at each new audio frame. See:

That said, I really can't hear any difference between these constructions, and so from a practical point of view I would be too much bothered about it. But if you are curious about it, I would recommend you to write to the mailing list, where all the Pd gurus and old Chinese masters live. If someone knows the exact answer to this question, then this person is very likely reading that list.

Cheers!
Gilberto

• @gsagostinho Ah I see. So instead of taking a number between 0-1 (provided by a [phasor~] or [line~]) and multiplying that by the total number of samples, it's more accurate to just use [line~] and have the ramp go from 0 to the last sample.

Which makes me curious. What is the [+ 1] for? Isn't the first index of an array at 0?

• What is the [+ 1] for? Isn't the first index of an array at 0?

My bad, it should actually be [- 1] and the message above [line~] should be [0, \$1 \$2(, since if we have n samples, their indexes are 0 until n-1, right?

Cheers!
Gilberto

I think normal tabread~ uses the floor function (chops off the fractional part)

Oh, really? I thought it interpolates between some samples before and some samples after the current one, but I never expected it to read between the samples. How does his work?

• @gsagostinho when you tell it to read between 2 indices in a table it will output some value in between the values of those 2 indices generally, like a crude form of resampling.
It allows one to give tabread4 values such as, say, 1.25. Tabread4~ can resample the integer sample values to give values in between the original integer indices, and in the case of 1.25 the sample in place 1 will be weighted more heavily than the sample in place 2. samples 0 and 3 would also be used for the weighting though, in order to get the cubic polynomial. (that is why one must read starting from sample 1 rather than sample 0 when using tabread4)
https://ccrma.stanford.edu/~jos/pasp/Lagrange_Interpolation.html)
That is what I mean by being able to read in-between samples: it is valid to pass non-integer sample values and receive a "meaningful" output.

This is also what makes it possible to use tabread4~ to play back samples at a slower or faster rate that isn't some integer multiple of it's sample rate, because you can give it (for instance) 1, 1.5, 2, 2.5 etc. If tabread4 could only read integers and was given the same input it would go 1, 1, 2, 2 etc. This is what regular tabread~ does though.

• @seb-harmonik.ar Hi Seb, thanks for the explanation! So I see what you mean by reading in between the samples.

This is also what makes it possible to use tabread4~ to play back samples at a slower or faster rate that isn't some integer multiple of it's sample rate, because you can give it (for instance) 1, 1.5, 2, 2.5 etc. If tabread4 could only read integers and was given the same input it would go 1, 1, 2, 2 etc. This is what regular tabread~ does though.

When I use different playback speeds which are not multiple of whole numbers with [tabread~] I still get slower or faster rate. I always thought that the only difference between [tabread~] and [tabread4~] is the use of interpolation, nothing else.

Cheers!
Gilberto

• This post is deleted!
• This post is deleted!
• @gsagostinho yes, you will still get a slower or faster rate, but only integer indices will be read, and so certain samples will be repeated or skipped rather than interpolated between. It is true that the only difference is the interpolation (well, aside from tabread4's "onset" inlet)
So I suppose it would have been better to say that you can read faster or slower with tabread~, but the output will have a lot more distortion than with tabread4

Posts 11 | Views 2639
Internal error.

Oops! Looks like something went wrong!