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?
7 posts
• Page 1 of 1
DSP local variables persist?
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?
Do you have an example? Not sure I understand what you mean.
- Exo
- Posts: 426
- Joined: Wed Aug 04, 2010 8:58 pm
- Location: UK
Re: DSP local variables persist?
- 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?
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.
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.
- Exo
- Posts: 426
- Joined: Wed Aug 04, 2010 8:58 pm
- Location: UK
Re: DSP local variables persist?
I see. I believe whenever the schematic recompiles as well.
This should definitely be in the manual.
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?
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).
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?
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
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 48 guests