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
Loops in Flowstone
11 posts
• Page 1 of 2 • 1, 2
Loops in Flowstone
Hi stoners,
I put together a little tutorial on loops (as a programming structure, not as repeating audio fragments) in Flowstone. It is quite elementary for now, I might elaborate more if there is interest. Your comments and suggestions are welcome!
I put together a little tutorial on loops (as a programming structure, not as repeating audio fragments) in Flowstone. It is quite elementary for now, I might elaborate more if there is interest. Your comments and suggestions are welcome!
- Attachments
-
- LoopTut.fsm
- Added nested loops
- (4.9 KiB) Downloaded 1003 times
Last edited by martinvicanek on Sun May 10, 2020 4:36 pm, edited 2 times in total.
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
Re: Loops in Flowstone
I can't say anything about DSP and ASM code loops, but I trust your expertise in that regard. I agree on green loops. I strongly disagree on Ruby loops, and hope, you trust my expertise in that regard.
Never use for-loops in Ruby. It's so contrary to the concept of Ruby that it is just bad. A Ruby for-loop actually is amethod of the object class and a very complicated way to do
There is a looping method of the object class, however, that is constructed in C (the underlying code base of Ruby) with a for loop.
Since your schematic is a tutorial, you should definitely refrain from using 'for' as a Ruby example!
Never use for-loops in Ruby. It's so contrary to the concept of Ruby that it is just bad. A Ruby for-loop actually is amethod of the object class and a very complicated way to do
- Code: Select all
range.each
- Code: Select all
x = 0
r = for i in 0..9
x += i
end
- Code: Select all
r #will show '0..9' in the inspector pane
x #will show '45'
- Code: Select all
## slow and non-Ruby
x = 0
for i in 0..9
x += i
end
##fast and Ruby
x = 0
(0..9).each do |i|
x += i
end
There is a looping method of the object class, however, that is constructed in C (the underlying code base of Ruby) with a for loop.
- Code: Select all
x = 0
i = 0
while i < 9
i += 1
x += i
end
x #will show '45' in the inspector pane
- Code: Select all
x += 1 while x < 10
Since your schematic is a tutorial, you should definitely refrain from using 'for' as a Ruby example!
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Loops in Flowstone
Thanks Tula. I removed the Ruby section.
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
Re: Loops in Flowstone
Many thanks Martin and tulamide!
Whenever I've come across the Green looper I'm always surprised at how fast it seems to run. No idea why...
Cheers
Spogg
Whenever I've come across the Green looper I'm always surprised at how fast it seems to run. No idea why...
Cheers
Spogg
-
Spogg - Posts: 3358
- Joined: Thu Nov 20, 2014 4:24 pm
- Location: Birmingham, England
Re: Loops in Flowstone
Hey,
Thanks Martin! very enlightening with the comments you included
Thanks Martin! very enlightening with the comments you included
"Essential random order for chaotic repetitive sequences"
-
tektoog - Posts: 141
- Joined: Sat Oct 30, 2010 11:49 pm
- Location: Geneva - Switzerland
Re: Loops in Flowstone
Thanks Martin,
Just what I have been looking for, very well presented . I am trying to learn to use the code box and the more examples I can study the better. This is great, I hope you keep these lessons comming! Anyone else interested in seeing more?
Thanks again, BobF.....
Just what I have been looking for, very well presented . I am trying to learn to use the code box and the more examples I can study the better. This is great, I hope you keep these lessons comming! Anyone else interested in seeing more?
Thanks again, BobF.....
- BobF
- Posts: 598
- Joined: Mon Apr 20, 2015 9:54 pm
Re: Loops in Flowstone
Hi Martin,
I note in the very last example you said "It has advantages to let the loop counter run backwrds". Interesting .. but I can't see why - can you elaborate?
Afraid I live permanently in FS4 world these days .. don't think any of my stuff works in 3.06 any more. Wherein (in FS4), you've been able to do variable loop lengths, and indeed nested loops, inside a DSP box for quite a while, I've used both extensively.
Admittedly I invariably rely on hanging a text box onto the DSP box 'S' output to start me off in assem, it's the ideal way to start to learn how assembler works I reckon. Worked for me anyway - it's almost like a built-in tutorial.
Presumably it would be possible to do nested loops in FS3 inside an Assem box?
H
I note in the very last example you said "It has advantages to let the loop counter run backwrds". Interesting .. but I can't see why - can you elaborate?
Afraid I live permanently in FS4 world these days .. don't think any of my stuff works in 3.06 any more. Wherein (in FS4), you've been able to do variable loop lengths, and indeed nested loops, inside a DSP box for quite a while, I've used both extensively.
Admittedly I invariably rely on hanging a text box onto the DSP box 'S' output to start me off in assem, it's the ideal way to start to learn how assembler works I reckon. Worked for me anyway - it's almost like a built-in tutorial.
Presumably it would be possible to do nested loops in FS3 inside an Assem box?
H
-
HughBanton - Posts: 265
- Joined: Sat Apr 12, 2008 3:10 pm
- Location: Evesham, Worcestershire
Re: Loops in Flowstone
Thanks guys for your responses. I have added nested loops, refer to the top post.
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
Re: Loops in Flowstone
Wowzer!
Some real-life examples would be helpful I expect. If I can get my head around all the pushes & pops, and with Martin's new info, I'll see if any of my earlier efforts can be smartened up enough to be presentable. A simple example I've used a number of times is an interpolator that generates, say, 61 values for a keyboard, derived instantly from the top and bottom note values. (Assembler runs at ludicrous-speed, not at green-speed ).
When I first moved things into FS4 last year I had several DLL modules in my scheme, almost all of them for generating obscure arrays of one kind or another. Of course they didn't work at first because they were all 32-bit, but I pretty soon discovered I could replace every one of them with 'dsp + signal-analyser pairs' without any of the dll hassle, very much easier. (Have never gone back to dll's).
And .. FS4 allows nested loops inside DSP! Mind you setting such things up directly in assembler like Martin does still looks pretty daunting to me, but I'll keep staring at it until something clicks.
So I basically always rely on the 'S' output from DSP modules to get a working basic assembler code and then proceed from there - MyCo has revised this feature considerably from the 3.0.x versions, his explains what's going on with all the movaps and the xorps much better than in the past.
However I note that in my current nested loops, as produced by FS4, ebx never makes an appearance; any internal loops are always achieved (I think!) by yet more pushes & pops of eax.
I can see that using ebx instead is a major simplification so there's my second challenge right there ....
Oooeck ...
H
Some real-life examples would be helpful I expect. If I can get my head around all the pushes & pops, and with Martin's new info, I'll see if any of my earlier efforts can be smartened up enough to be presentable. A simple example I've used a number of times is an interpolator that generates, say, 61 values for a keyboard, derived instantly from the top and bottom note values. (Assembler runs at ludicrous-speed, not at green-speed ).
When I first moved things into FS4 last year I had several DLL modules in my scheme, almost all of them for generating obscure arrays of one kind or another. Of course they didn't work at first because they were all 32-bit, but I pretty soon discovered I could replace every one of them with 'dsp + signal-analyser pairs' without any of the dll hassle, very much easier. (Have never gone back to dll's).
And .. FS4 allows nested loops inside DSP! Mind you setting such things up directly in assembler like Martin does still looks pretty daunting to me, but I'll keep staring at it until something clicks.
So I basically always rely on the 'S' output from DSP modules to get a working basic assembler code and then proceed from there - MyCo has revised this feature considerably from the 3.0.x versions, his explains what's going on with all the movaps and the xorps much better than in the past.
However I note that in my current nested loops, as produced by FS4, ebx never makes an appearance; any internal loops are always achieved (I think!) by yet more pushes & pops of eax.
I can see that using ebx instead is a major simplification so there's my second challenge right there ....
Oooeck ...
H
-
HughBanton - Posts: 265
- Joined: Sat Apr 12, 2008 3:10 pm
- Location: Evesham, Worcestershire
11 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 73 guests