What's new

Is there a way to extract the file names from file selector?

You use .and., not .or.. This will test all bits for equality, then you need to query if that result is the same to the state of your current filter. To get the state of your current filter based on buttons that represent them:

Code:
current_filter := 0

for i := 0 to NUM_TAGS - 1
    current_filter := current_filter + (sh_left(1, i) * BrowserButtonIDs[i] -> value)
end for

To query a bunch of soundsources for their attributes and fill an array with results:

Code:
num_results := 0
array.fill(filtered_results, -1) // just a quick function that runs a loop throughout the whole array (first arg) and fills it with a specified number (second arg)

for i := 0 to num_elements(sound_bitmasks) - 1 // sound_bitmasks would be the array that contains integers that pose as bitmasks for the attributes you want
    if sound_bitmasks[i] # 0
        if (sound_bitmasks[i] .and. current_filter = current_filter
            filtered_results[num_results] := i

            inc(num_results)
        end if
    else
        i := num_elements(sound_bitmasks) // break loop
    end if
end for
 
Sorry I wasn't clear about the "or" statements. I am using the .and. operands, I was referring to this part of my code:

Code:
function mdl.set_preset_btn_params()
            for i := 0 to NUM_PRESET_ENTRIES - 1
                if (%preset_categories[$i] .and. $attribute_1 > 0 or %preset_categories[$i] .and. $attribute_2 > 0 or %preset_categories[$i] .and. $attribute_3 > 0)
                    Entry[i] -> text := !preset_names[($preset_scroll + i)]
                end if
            end for

            call mdl.sel_preset_entry()
end function

Thought that maybe there was a way to not have the if statement cluttered with so many "or" conditions. I started playing with the sh_left as you have shown above so I'll study what you've written there.

Not sure I quite understand the second part where I'm trying to consolidate the filtered results to display on my buttons. But I'll look closely at what you've written here. This stuff doesn't come easy to me ;)
 
Last edited:
Hey, your if clause needs as many queries as needed! What you can do, though, to make things more readable, is spread it over multiple rows, like so:

Code:
function mdl.set_preset_btn_params()
            for i := 0 to NUM_PRESET_ENTRIES - 1
                if (%preset_categories[$i] .and. $attribute_1 > 0 or ...
                    %preset_categories[$i] .and. $attribute_2 > 0 or ...
                    %preset_categories[$i] .and. $attribute_3 > 0)

                    Entry[i] -> text := !preset_names[($preset_scroll + i)]
                end if
            end for

            call mdl.sel_preset_entry()
end function

But the way you're doing it is not efficient indeed. You need to get_ui_id() of all your attribute buttons sequentially, then you can use the loop method as I showcased - basically taking the state of all the attribute buttons and smashing it all into a single integer (basically converting it into a bitmask, which you then use for filtering the soundsource list).
 
The filtering is working well, I appreciate all the help. I was having an issue with the scroll bar but I think I got it working although I'm not sure if it's the most efficient way of doing it. Wondered if you had any critiques.

Here's what I have currently.

Code:
            for $i := 0 to NUM_BROWSER_BUTTONS - 1
                $val_preset_scroll := (((($sli_preset_scroll - 0) * (($num_results-NUM_BROWSER_BUTTONS)*(1+(sh_right(($num_results-NUM_BROWSER_BUTTONS)-0, 31))) - 0)) / (12 - 0)) + 0)
                if (%filtered_results[$i + $val_preset_scroll] # -1)
                    browser_buttons[$i] -> text := !preset_names[%filtered_results[$i + $val_preset_scroll]]
                end if
            end for
 
Last edited:
Yeah that seems alright. You might only want to do this when an actual increment of $val_preset_scroll happens, so I suppose have a variable that keeps its previous state then compare with it etc. etc.
 
Noooo, you should use a simple integer number. You get 32 bits to use for your attributes, and then you use bitwise .and. in a loop to test if a particular bit is flipped (which equals to "is this attribute valid for this patch").
I have this working with a small number of attributes but now that I have my browser functionality in place, I want to finalize with 16 attributes total. For some reason weird things are happening that I can't pin point. The first 3 attributes (1,2,4 bit values) work fine when the bit mask array elements are only 3 digits or less. If I add more than 3 attributes I can't get those to work. So for example, an attribute filter value of 8 doesn't recognize my bit 8 but the filter value of 4 does recognize the bit 4. Any idea what might be causing this or why this happens?


** Edit **
So I think I figured this out. I wasn't expecting it to work the way it does. I had the bitmask array set up using zeros and ones thinking that is how the filter would recognize switches. But it seems that is not right unless I'm missing something else. I guess the reason I was confused is because it did work the way I thought it did on the first 3 attributes for some reason.
 
Last edited:
Top Bottom