> And what vline does, is it reads that list, and then schedules itself to
be hit after the correct amount of logical time has elapsed.
I'm not exactly sure what "schedules itself" means here. So I'll just
start explaining how it works until I understand it myself... :)
The [vline~]
object processes blocks of samples at a time (in vline_tilde_perform). But
any of those clock events Frank mentioned that happen to be "ripe" for
the upcoming block get sent to the "float" method of line (vline_tilde_float),
which adds them to the linked list x_xlist.
For example,
suppose you have the following:
[0 0.1, 1 0.2(
|
[pipe]
|
[vline~]
|
[print~]
When you click the message box, [pipe] does the proper clock delay for
each message: the "0" is scheduled for 0.1ms in the future, and the "1" is
scheduled for 0.2ms. But these delay times take less time to fire than it
takes to compute a block. So if [vline~] is calculating its output in blocks
of 64 samples, when does it actually receive the output from [pipe~]?
The answer is that Pd actually sends the "0" and "1" messages to [vline~]
one after the other, before it calculates the next block. By "send" I mean it
calls the function vline_tilde_float with the float argument "0", and then it calls
vline_tilde_float with the float argument "1". But before each of those calls, it updates the "sys_time" to be the time when that clock was set to go off. So if the "0" was set to go off at "now + 0.1", Pd sets "now+0.1" to be the new system time, then it sends the "0" message to vline_tilde_float. And before it sends "1",
it sets the sys_time to "now + 0.2".
Let's go back to vline_tilde_float-- notice in the first line we're fetching the
sys_time. And what is it going to be for our "0" message? As stated above, we
set it to "now + 0.1". Great! And when we process "1" message, we get "now + 0.2". Thus, [vline~] adds those messages and their associated timings to the linked list.
Finally, we do [vline~] perform routine. It starts with the time equal to what it
was at the beginning of the block. Then it loops through our block's samples
until it reaches a sample that corresponds to the time that an event in our
linked list needs to be triggered. When we reach that sample, we jump to
the new value.
It's the same process for ramps, except that vline~ calculates an increment
value for the ramp.
After looking, I'm kind of curious what is most responsible for [vline~]
overhead. I'd guess it's the math needed to set each ramp segment, but I'm not
certain.
-Jonathan