Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Clock Accuracy - 10ms?

For general discussion related FlowStone

Clock Accuracy - 10ms?

Postby Nowhk » Fri Nov 20, 2015 11:38 am

The manual says:

The schematic clock runs at 100 Hz. Unlike the Tick components which are not time precise due to
their use of Windows timers, the Events system uses a different timer which is much more accurate so
each 10 millisecond tick should occur precisely on time.


This means that if I call events under 10ms they might be not in synch? For example:

Code: Select all
input 10, nil, time + 0.001

call an event every 1 ms. So 10 times between 2 clocks. They can be un-synch so? Occuring essentially not every 1 ms?

This could be a problem, since I'm making a LFO that change many values during the time, that will occurs around 1ms or less...
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: Clock Accuracy - 10ms?

Postby Nowhk » Sun Nov 22, 2015 11:22 am

Any ideas?
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: Clock Accuracy - 10ms?

Postby nix » Sun Nov 22, 2015 12:59 pm

I say try it and see if it sounds good enough.
Maybe as long as it has no discontinuities/doesn't click.
1000hz does stress the cpu use though.

There is one way to get a tick in samples. A frame can be used to trigger a frame.

I think the hint just uses 10 ms as an example.
If you want to test it, use mono to float and a stream.
User avatar
nix
 
Posts: 817
Joined: Tue Jul 13, 2010 10:51 am

Re: Clock Accuracy - 10ms?

Postby Nowhk » Fri Nov 27, 2015 4:53 pm

This can be a problem for me in Flowstone so.
I make an LFO plugin that make random shape, and works on (max) 1280 discrete values, getting a smooth shape. This is a generated 500 values shape:

Immagine.png
Immagine.png (8.67 KiB) Viewed 24840 times

Once got it, I need to iterate these values; than output (index and the value in my case) at each step:

Code: Select all
def startLFO
   output "lfo_index_1", @lfo_index
   @lfo_index += 1
   if @lfo_index == @lfo_length
      @lfo_index = 0
   end

   output "lfo_value_1", @lfo_shape[@lfo_index]
   input 10, nil, time + @lfo_freq
end

the output is "smooth" using @lfo_freq value >=0.01, and it doesn't requires too many resources (I'm about 2-3% of CPU).

But for this general purpose, the ouput is slow: It tooks such as 6-7 seconds for process all values (automating the linked controller, in FL Studio, in my example).

If I need to process the whole shape in (let say) 1 seconds, I got the problem.
Because using @lfo_freq = 0.001 for example, it will eat lot of resources: such as 45% :shock: Even if I remove all unused modules (draws, labels, and so on).

Is Flowstone heavy on resources? Or how usually plugin manage this huge amount of values? For a smooth signal, I guess 500 "samples" are required "at least".

But I see on some other app that I can process (speed) them quickly. Can I improve the whole mechanism?
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: Clock Accuracy - 10ms?

Postby tulamide » Fri Nov 27, 2015 8:27 pm

You can't rely on exact steps in time. Never and nowhere. I could explain why Flowstone doesn't always get the system's attention at exactly the same time, but that's a long and boring story. To cut it short: That's not the way things work.

This was very apparent in game development, where continuous movements are key to the gameplay mechanics. So they started early to use indirect code, instead of direct one.
If you want to do something continuously you have to use deltatime, short dt. The system clock is the only reliable timing source you have. Therefore, dt measures the time between the last and the current step (in games called "frames") in system clock's ticks, converted to seconds.
When you add those deltatimes, you will always get to one second, no matter in how many frames. It guarantees a constant movement over time, instead of frames.

Say you have to move a sprite by 20 pixels over one second, and your application runs at 30 fps (frames per second). In the ideal case one frame would last 1/30th of a second, or 0.03~s. But in reality, the frames rather take something like 0.03, 0.03, 0.02, 0.07, 0.05, 0.03, etc.

Calculating frame-based would result in 0.66~px per step (this value multiplied by 30 results in 20), but if you compare it with the above sample sequence, you'll see that at the fourth step the duration is more than twice as long. Which makes the movement at this step half as fast as it should be.

The solution is deltatime. Since you know how long each frame is, instead of adding a fixed portion of the distance on every frame, you add a relative portion which is the distance times dt:

Code: Select all
wrong: n += x/30
right: n += x * dt

Now the distance per step will vary, but therefore be constant and continously over time.

Read more about the concept of delta-timing on the net to make yourself comfortable with it :)
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Clock Accuracy - 10ms?

Postby martinvicanek » Sat Nov 28, 2015 12:40 am

Why don't you use stream? The CPU hit is not that bad.
Attachments
ArrayBasedLFO.fsm
(10.3 KiB) Downloaded 1119 times
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Re: Clock Accuracy - 10ms?

Postby nix » Sat Nov 28, 2015 11:17 pm

oh sorry,
yes-
if you can use stream.
The 'wave read' prim is the one you need,
and 'float array to mem'

all success
User avatar
nix
 
Posts: 817
Joined: Tue Jul 13, 2010 10:51 am

Re: Clock Accuracy - 10ms?

Postby Nowhk » Sun Nov 29, 2015 9:18 pm

martinvicanek wrote:Why don't you use stream? The CPU hit is not that bad.

Nice approch! The problem is that I would to "show" the shape how it will be, than "play" it with a progressive bar.
Mem type is "dynamic", so I think I couldn't show what the signal will be and the draw a progressive line on it.

Or is there a way? Such as this:

http://www.fastswf.com/CumhxmY

P.s. how do you generate that "consecutive" random array? I see no heavy jump between points...
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

ArrayBasedLFO with line bar

Postby Tronic » Sun Nov 29, 2015 11:18 pm

:arrow:
ArrayBasedLFO_with_line_bar.fsm
(15.67 KiB) Downloaded 1076 times
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Clock Accuracy - 10ms?

Postby martinvicanek » Sun Nov 29, 2015 11:43 pm

Dammit, Tronic beat me on that one! :lol:
Nowhk wrote:P.s. how do you generate that "consecutive" random array? I see no heavy jump between points...
Oh, I chose some random partial amplitudes and iFFTed them, so the result is smooth and periodic. However, if the period is long enough (>10s) then the ear won't recognize the repeating pattern.
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Next

Return to General

Who is online

Users browsing this forum: No registered users and 66 guests