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

ARRAY Search [RUBY] ??

For general discussion related FlowStone

Re: ARRAY Search [RUBY] ??

Postby RJHollins » Wed Aug 14, 2013 10:28 pm

trogluddite wrote:Keys to solving this, I think, are...

- Get all the information into a single data structure
- Test strings using regular expressions - they take some learning, but are super versatile.

Something like this...
Trumpet Finder.fsm


Trog ... Thank-you ! I know you've been trying to take a little time off [at least from here] :) But I always look forward to your posts. Once again, the code and the internal descriptors have provided much to study.

What's interesting is looking at the code techniques you've used. I have been reading various Ruby forums [tutorials] and see all these things presented in your code. I'm a long way from understanding most of this.

I've been testing out the code you posted. I've gone in and substituted some of my intended integration via Inputs, and mod'd a bit on the variable names. This help me see some of the logic and syntax for what I'm needing to do.

I did find something confusing on the output. For my test, the outputs are showing as:
[["1", "test1"], ["2", "test2"], ["3", "test3"], ["4", "test4"]]


I'm trying to figure how to 'remove' all the brackets, quotes, & commas to just output a 'clean' Array list.

The destination for all the 'found' arrays are going to be fed into a 'pull-down' menu Selector. The idea is to parse an XML file into the 2 input arrays [patchnames, patchnumber]. From the search routine I can then more quickly organize these patches into a related sub-group. These groups will be fed to the pull-down menu, allowing the User to select a patch from the group.

The patchnames or mostly for display purposes. The patchnumbers are the actual MIDI PRGCHG values that I'll be using to control external VST plugs with.

This is all in effort to ease the User Configuration. Instead of the user manually entering in all the patch data.

It a concept I'm wanting to try to see if this would be better.
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: ARRAY Search [RUBY] ??

Postby RJHollins » Thu Aug 15, 2013 7:13 am

TrojakEW wrote:or something like this. it will search for string and return array with index and element from input array
Code: Select all
a = ["preset_test1","test2","preset_test3","test4"]
names = a.select {|x| x =~ /preset/ }
number = a.each_with_index.select { |i, idx| i =~ /preset/}
number.map! { |i| i[1] }
number.zip(names)

Hi TrojakEW,

Thank-you for posting code suggestion, unfortunately, I've not solved how to alter your code example to work with external inputs :cry: I attribute this to my rookie skills with Ruby [and I use the term 'skills' in the generic sense] :roll: I'm still playing with it, though ... it seemed a more specific [and hoped] easier code for me to understand.

I was able to modify TROG's code to take the inputs I was sending. The only issue was getting the outputs in a clean 'array list' format.

I think I should post a simple schematic to illustrate what I'm trying to accomplish, so as NOT to waste everyone time or add confusion. My bad :oops:

The output from TROG's post shows this:
[["2", "test2"]]

I don't understand how to have the output with no brackets ... just the 2 and the test2 ... but as separate outputs
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: ARRAY Search [RUBY] ??

Postby RJHollins » Thu Aug 15, 2013 8:15 am

Here's a schematic sample that I'm working from:
capture-1.JPG
capture-1.JPG (45.64 KiB) Viewed 14095 times


With TROG's search routine as the centerpiece, I've only modified to take 3 Inputs. The 'working' Output shows
the result ... but in a format that I don't know how to use.

The 2 text boxes below that show the format I'm trying to get to.

Hope this makes sense ... or maybe I'm thinking about this all wrong :?
Trumpet Finder [RJH-mod]-3.fsm
(1.93 KiB) Downloaded 890 times
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: ARRAY Search [RUBY] ??

Postby Tronic » Thu Aug 15, 2013 11:19 am

like this?
Attachments
Trumpet Finder_RJH-mod_3_Tronic.fsm
(1.9 KiB) Downloaded 861 times
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: ARRAY Search [RUBY] ??

Postby TrojakEW » Thu Aug 15, 2013 2:22 pm

Here is my modified version with 2 inputs. 3 outputs element names,element index a combined array name+index. Oh and my skills with ruby are almost same as yours :D . I'm ruby noob.
Attachments
search_array.fsm
(778 Bytes) Downloaded 868 times
User avatar
TrojakEW
 
Posts: 111
Joined: Sat Dec 25, 2010 10:12 am
Location: Slovakia

Re: ARRAY Search [RUBY] ??

Postby RJHollins » Thu Aug 15, 2013 5:48 pm

Tronic wrote:like this?


Closer :lol:

The 'found' INDEX [output] should only be those found, and in sync to the patchnames.

Thanks for looking at this Tronic !!!!!!
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: ARRAY Search [RUBY] ??

Postby RJHollins » Thu Aug 15, 2013 9:14 pm

TrojakEW wrote:Here is my modified version with 2 inputs. 3 outputs element names,element index a combined array name+index. Oh and my skills with ruby are almost same as yours :D . I'm ruby noob.

Hi TrojakEW,

Your latest 'modified version' .... WORKS !!! :D

Looking over the code, I see familiar terms and syntax that I was trying to use in my attempt. I did, however, see new terms, like the 'map!' tp get the index array. That's one I'd not seen before.

As to Ruby skills ... well YOU might consider yourself a 'ruby noob' ... :lol: but the code AND the internal comments you wrote are MUCH APPRECIATED 8-) I can actually follow along with your code ... still, I need to understand the internal workings, among many other things. This is great ! Thank-you.

Well, at least now I can start putting together the original idea, and see if this all comes together.

Thanks again for everyone's help in dragging along a rookie to a working destination. :lol:
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: ARRAY Search [RUBY] ??

Postby RJHollins » Sun Nov 17, 2013 4:02 am

Again with the Ruby Arrays ! :shock: :shock: :lol:

So close ... yet so far ...

Finally getting back to a project idea, and this array search routine.

I have 2 arrays that need to be directly linked to each other. One is 'name', the other are 'patch#'.

I'm using a 'search' to separate items from the list into an output array together with it's specific patch#.

I'd like to separate this 2-d array back into separate string arrays to 2 outputs.

The output format is another puzzle ... I need to change the current format so it can be used in part for GUI display and part for MIDI data.

... may the RUBY lessons continue .... :lol:
Trumpet Finder_RJH-mod - 4.fsm
(2.23 KiB) Downloaded 857 times


**** edit ***
strange ... just tried to DL and load this file ... now showing a Ruby error :roll:
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: ARRAY Search [RUBY] ??

Postby RJHollins » Sun Nov 17, 2013 4:25 pm

small step forward :lol:

To the code I posted above, I added this Ruby line:
Code: Select all
output 0,@found.join(",")

I believe this is what NuBeat was referring to ?!?

his now give an output in this form:
Code: Select all
Wind Chimes,32


If I could stay within RUBY ... I'd like to be able to output each side of the ',' to a separate output [arrays], while still maintaining this 'clean' format.

Maybe I'm making this more difficult than it need be :oops: I've been known to complicate :roll:

help :lol:
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm

Re: ARRAY Search [RUBY] ??

Postby Tronic » Mon Nov 18, 2013 2:06 am

:arrow:
Trumpet Finder_RJH-mod_4_Tronic.fsm
(2.01 KiB) Downloaded 903 times
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

PreviousNext

Return to General

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 10 guests