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

DSP local variables persist?

DSP related issues, mathematics, processing and techniques

DSP local variables persist?

Postby Perfect Human Interface » Mon Aug 18, 2014 4:53 am

I thought local variables in DSP code were initialized at every tick (to 0 if not explicitly). What I'm looking at right now suggests otherwise. Do variable states in DSP code blocks persist indefinitely?
Perfect Human Interface
 
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: DSP local variables persist?

Postby Exo » Mon Aug 18, 2014 6:29 am

Do you have an example? Not sure I understand what you mean.
Flowstone Guru. Blog and download site for Flowstone.
Best VST Plugins. Initial Audio.
Exo
 
Posts: 426
Joined: Wed Aug 04, 2010 8:58 pm
Location: UK

Re: DSP local variables persist?

Postby Perfect Human Interface » Mon Aug 18, 2014 6:42 am

Code: Select all
streamout x;
float y = 0;

y = y + 1;

x = y;


Here y increases indefinitely. I thought local variables were initialized every step, at audio rate. So my expected output to this code before now would have been a constant "1."
Perfect Human Interface
 
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: DSP local variables persist?

Postby Exo » Mon Aug 18, 2014 6:48 am

Ah see what you mean.

No all variables are initialized on the start of the process.
So for poly the variable is initialized for every new voice, for mono it will be initialized when you turn direct sound/asio on.
Flowstone Guru. Blog and download site for Flowstone.
Best VST Plugins. Initial Audio.
Exo
 
Posts: 426
Joined: Wed Aug 04, 2010 8:58 pm
Location: UK

Re: DSP local variables persist?

Postby Perfect Human Interface » Mon Aug 18, 2014 9:03 am

I see. I believe whenever the schematic recompiles as well.

This should definitely be in the manual.
Perfect Human Interface
 
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: DSP local variables persist?

Postby KG_is_back » Mon Aug 18, 2014 12:10 pm

Variables are initialized when the stream is created and that is immediately followed by stage(0). For poly, that means when the note starts to play. For mono when you turn on your soundcard, or cause recompile (by selector or clear audio prim), for signal analyzer, when it receives a trigger. It wouldn't make much sense if the variables didn't persist between samples - how would you do delays? and code blocks that use buffers?

However I noticed, that sometimes when you turn mono stream off with a selector, it simply pauses and continues where it was when you turn it back on (doesn't recompiles/resets).
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: DSP local variables persist?

Postby Perfect Human Interface » Mon Aug 18, 2014 12:23 pm

Thanks. I just wish I had known this a long time ago. :?
Perfect Human Interface
 
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm


Return to DSP

Who is online

Users browsing this forum: No registered users and 59 guests