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
"Last" green primitive action - Ruby version. Possible?
9 posts
• Page 1 of 1
"Last" green primitive action - Ruby version. Possible?
Heya,
Was wondering if Ruby can output the last coming parameter(s) of one or more inputs, just like the green "Last"version does. If it can, which parameters can be instantly processed and how? I believe Arrays, integers, floats, strings and red clips are no problem. But what about a full midi event (status, channel, data1, data2) ?
I mean let's say I have 2 midi inputs that each of them gets a random signal from 2 sources, one at the time. Can I instantly output each of them by using "Last" method?
Examples for all kind of situations (midi and non-midi) are welcome
Was wondering if Ruby can output the last coming parameter(s) of one or more inputs, just like the green "Last"version does. If it can, which parameters can be instantly processed and how? I believe Arrays, integers, floats, strings and red clips are no problem. But what about a full midi event (status, channel, data1, data2) ?
I mean let's say I have 2 midi inputs that each of them gets a random signal from 2 sources, one at the time. Can I instantly output each of them by using "Last" method?
Examples for all kind of situations (midi and non-midi) are welcome
-
kortezzzz - Posts: 763
- Joined: Tue Mar 19, 2013 4:21 pm
Re: "Last" green primitive action - Ruby version. Possible?
- Code: Select all
def event v
output v
end
This should do the job. You can add arbitrary many inputs and it will send the last one to the first output.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: "Last" green primitive action - Ruby version. Possible?
KG_is_back wrote:
- Code: Select all
def event v
output v
end
This should do the job. You can add arbitrary many inputs and it will send the last one to the first output.
Oh dear. I thought I understood event handling. I thought the order was input (index), value and time.
So I would have put def event i,v
If you just put def event v does Ruby know you mean value and not input?
Cheers
Spogg
-
Spogg - Posts: 3358
- Joined: Thu Nov 20, 2014 4:24 pm
- Location: Birmingham, England
Re: "Last" green primitive action - Ruby version. Possible?
There are 4 separate versions of event method
the first two are a little obscure, because they are usable in only the simplest cases. The last one is redundant because you can always access current time-stamp via time method.
- Code: Select all
event()
event(value)
event(input,value)
event(input,value,time)
the first two are a little obscure, because they are usable in only the simplest cases. The last one is redundant because you can always access current time-stamp via time method.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: "Last" green primitive action - Ruby version. Possible?
I say this without having checked it in a RubyEdit, but I'm pretty sure that's wrong.
You can't just have event(v), it MUST be event(i, v). From the user guide, chapter 8:
EDIT: KG, Ruby doesn't support method overloading
You can't just have event(v), it MUST be event(i, v). From the user guide, chapter 8:
For more advanced data handling you can define an event method. This is a special method which FlowStone looks for whenever it receives data at an input. The event method can have up to 3 input parameters:
▪ i - references the input at which the data arrived
▪ v - value that arrived at the input
▪ t - time at which the data arrived (schematic time in seconds)
You can have 0,1,2 or all 3 input parameters but you must add them in the order. So for example, you can have no parameters or
you can have i on its own
or i and v
or i and v and t
but you can't have v on its own or i and t without v.
EDIT: KG, Ruby doesn't support method overloading
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: "Last" green primitive action - Ruby version. Possible?
KG_is_back wrote:
- Code: Select all
def event v
output v
end
This should do the job. You can add arbitrary many inputs and it will send the last one to the first output.
I'm sorry KG, but it doesn't work for me. Tried it with integers, strings and floats pramenters.
-
kortezzzz - Posts: 763
- Joined: Tue Mar 19, 2013 4:21 pm
Re: "Last" green primitive action - Ruby version. Possible?
This is from an exercise I set myself early in my learning process.
It might be shit but it does work!
Cheers
Spogg
It might be shit but it does work!
Cheers
Spogg
- Attachments
-
- Last changed float .fsm
- (95.21 KiB) Downloaded 825 times
-
Spogg - Posts: 3358
- Joined: Thu Nov 20, 2014 4:24 pm
- Location: Birmingham, England
Re: "Last" green primitive action - Ruby version. Possible?
Am I being ignored? Why so neglecting? Just replace "v" with "i,v" in KGs example and it should work.
- Code: Select all
def event(i, v)
output v
end
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: "Last" green primitive action - Ruby version. Possible?
It works, tula
Sorry, but I missed the syntax at your first comment. When you wrote it clearly at the last, I understood. It may sound obvious to you, but people with no coding skills sometime miss the context until you clearly write the code
Sorry, but I missed the syntax at your first comment. When you wrote it clearly at the last, I understood. It may sound obvious to you, but people with no coding skills sometime miss the context until you clearly write the code
-
kortezzzz - Posts: 763
- Joined: Tue Mar 19, 2013 4:21 pm
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 48 guests