Two questions regarding tabread4~:
Let's say we have a 1 second sample at 44,100Hz (....44,100 sample size).
If the answer to my first question is "Yes", then...
Doesn't make sense...
I am wrong somewhere...?
Thanks a lot!
on_off
]]>Two questions regarding tabread4~:
Let's say we have a 1 second sample at 44,100Hz (....44,100 sample size).
If the answer to my first question is "Yes", then...
Doesn't make sense...
I am wrong somewhere...?
Thanks a lot!
on_off
]]>Yes. In theory you would need to resize your array and copy some samples around. In practice it doesn't matter very much for most sampled sounds. You will get some minor interpolation errors on the wraparound but there is little chance that they will be noticeable. Whenever I design samplers in PD I don't make any array changes. If you are using [tabread4~] to scan through an array to generate a control signal then you might want to consider changing your array.
I believe you are correct with 1 to 44101. The guardpoints are for when you try to read something like sample 0.25 or 44101.5. You can get more info on the interpolation method here: http://msp.ucsd.edu/techniques/latest/bookhtml/node31.html
The cubic interpolation will happen everywhere but the beginning and end of your sample if you don't add the guard points (the three additional points). If you add them you'll take full advantage of the interpolation (taken that you store the right samples in the additional points).
I've made some array manipulation patches and uploaded them on github https://github.com/alexandros301/Array_manipulation_patches
one of them adds the guard points for cubic interpolation.
It should read size  3, as the last index is size  1 (starting from 0). Mind though that [phasor~] doesn't reach 1, but a little bit lower. So multiplying by 44,100 and adding 1 will work as it will go from 1 to 44,100. If you use [line~] or [vline~] though, you might want to multiply by 44,099 in case the ramp reaches 1, as multiplying by 44,100 and adding 1 will yield a ramp from 1 to 44,101 (maybe I'm wrong...)
Portabello >> "If you are using [tabread4~] to scan through an array to generate a control signal then you might want to consider changing your array"
Yes Portabello, this is what I am trying to do actually!
Alexandros >> "If you use [line~] or [vline~] though, you might want to multiply by 44,099 in case the ramp reaches 1, as multiplying by 44,100 and adding 1 will yield a ramp from 1 to 44,101 (maybe I'm wrong...)"
Alexandre, in fact and exactly as you wrote, I am multiplying vline~'s ramp (same goes with line~) with 44,099 (>> ramp: 0  44,099) and then I add 1 (>> ramp: 1  44,100). The thing is that the tabread4~ object I am using is associated with a "corrected" array (resized to hold 44,103 samples for the 4point interpolation) in order to use its output as a control signal.
And here is the tricky bit I don't understand...
Why the heck the help patch suggests [1  (n2)]...??
I suppose I have to check the source code.
Cheers both!
best
on_off
]]>Thanks
]]>frac
in the code.index
is an integer. When it is assigned to from the floatingpoint index findex
, and findex
is between n  3 and n  2 then the integer portion of the index will equal maxindex
. So then the test if (index > maxindex)
will fail because they are equal, and the fractional portion frac
will interpolate between n  2 and n  3.
Say that the floating point index findex
were exactly n  2 or above. In this case the if
test succeeds, index
is set to maxindex
and frac
is set to 1. this evaluates the same polynomial as would be evaluated at n  3 or anywhere in between n  3 and n  2 because index
equals maxindex
in all of these cases (and index
sets where the interpolation polynomial is in relation to the array it is reading from) , but when frac
is 1 then that polynomial is being evaluated at exactly n  2, which is the {third point in the polynomial} instead of the {second point plus the fractional part} that is used by tabread4 everywhere else when reading the array.
BTW, how can I put text inside a box in this forum?
]]>BTW, how can I put text inside a box in this forum?
This forum uses Markdown syntax. For the full documentation, have a look on this page: http://daringfireball.net/projects/markdown/syntax
But basically, if you want to write something like this
, simply enclose the phrase around two ` (also known as "grave accent"). And if you want to have code spanning through several lines like this:
[foo]

[bar]
...then you simply have to indent every single line of your code by 4 blank spaces.
Hope this helps, take care,
Gilberto
Having the same polynomial at 2 different indices does not mean that the output is the same, just that the 2 indices are between the same 2 points of the array. for instance if you read between n  3 and n  2 you use the same polynomial as if you read right at n  3, but the result is not the same because when you read you read at a different place in the same polynomial: the input to the polynomial function is different and therefore the output is different. (if f(x) is the polynomial function, then changing x changes f(x), f(x) is usually not constant).
findex
is basically the value from the signal inlet of tabread4~, index
is the integer part of it. So when you do frac = findex  index
then frac
stores the fractional part of the index, and this fractional part is used to offset from the second point in the polynomial. When frac is 1, the offset goes all the way to the 3rd point. This happens only when index
is equal or above n  2. (since index
is an integer, the test index > maxindex
in the code is the same thing as index >= (maxindex + 1)
where maxindex + 1
is equal to n  2).
whenever tabread4 reads a point in an array it always fits a polynomial it uses to interpolate using 4 of the points of the array. Wherever the index is, tabread4 puts 2 points of the polynomial to the left of the index and 2 points to the right of the index. Normally when the index crosses the next point in the array, the polynomial moves 1 point to the right also. However when it tries to read at or past n  2, it just stays at n  2 instead because the polynomial can't move any more: it is already using the last point of the array as the last (4th) point of the polynomial, and n  2 is the third point and so the polynomial can still be evaluated right at the n2 point but not at higher indices.
At the Index 1 the same thing happens but on the other side of the array: if (index < 1) index = 1, frac = 0;
However, handling 1 itself is not necessary in this case because if findex
were exactly 1 then index would already be 1 and frac would already be 0 because findex  index
would be 0
Did I rope your question in all that?
]]>the same polynomial thingy confused me, as in the case where findex is between n  3 and n  2, index > maxindex will fail and frac won't be set to 1.
Anyway, your post now is clear. Still, isn't the maximum value you have to send to [tabread4~] n  3 (or a bit above, n  3.something, but not n  2)? so that the code can still use n  2 and n  1 as the two points on the right side of the index?
P.S. even though gsagostinho explaing how, I still can't highlight text
]]>P.S. even though gsagostinho explaing how, I still can't highlight text stuck_out_tongue_winking_eye
Try reading this: http://daringfireball.net/projects/markdown/syntax#code
You need to make sure that you start and finish with backtick quote marks `
(and not single quotes '
). E.g.: ```test`` but __not__
'test'`
Take care,
Gilberto
damn
that was so easy :)
thanks!
]]>index
as the second point of the polynomial if findex
is an integer, UNLESS index
is n2 or greater, and in that case it is ok to use n  2 (maxindex
+ 1) as the 3rd point.
Also, In lagrange interpolation which is used here all of the integer indices in the polynomial will exactly equal the corresponding indices in the array that the polynomial was made from, so really it doesn't matter if an integer index is used as the 2nd or the 3rd point of the polynomial. Looking from a programming perspective, it is easier to use an integer index as the second point in the polynomial mainly because when you turn the index into an integer it is easier to round down (just assign to integer) than to round up.
the 1st and 4th points will also equal their corresponding points in the array, but it doesn't make sense to read the segment going between the 1st and 2nd points or between the 3rd and 4th points
]]>