Attaching notifiers to sliders

Pardon me if I was rude

Well, I had this:

 for i = 1, sampcount do  
 smp =  
 if smp.volume > 1 then smp.volume = 1 end  
 sliders[i] =   
 vb:column {  
 vb:slider { id = "vol"..i, min = 0, max = 1, value = smp.volume, height = 150, width = 40 },  
 vb:minislider { id = "pan"..i, min = 0, max = 1, value = smp.panning , height = 20, width = 40 },  
 vb:minislider { id = "txp"..i, min = -120, max = 120, value = smp.transpose , height = 20, width = 40 },  
 vb:minislider { id = "fit"..i, min = -127, max = 127, value = smp.fine_tune , height = 20, width = 40 },  
 vb:popup { id = "lpm"..i, items = LOOP_MODES , value = smp.loop_mode , height = 20, width = 40 },  
 vb:popup { id = "ctm"..i, items = CUT_MODES , value = smp.new_note_action, height = 20, width = 40 },  
 for _,pmt in ipairs({'vol','pan','txp','fit','lpm','ctm'}) do  
 loadstring(""..i..")."..pmtname[pmt].." = "..vb.views[pmt..i].value)()  

now tell me that second for loop isn’t rediculous, annoying, and ugly.

I hope you don’t mind that i split your question because else the existing topic goes way off…

Now that i read my comment back, it sounds like i advised you to “stick it up your ass”, but that wasn’t meant to sound that way at all.

It depends on what you exactly want here.
I would rather stuff the above values in a multidimensional array, link values to notifiers for each sample and create the GUI only when necessary.
I don’t assume you want to display all those sliders for each sample at the same moment?

Have a look at his Instrument Mixer tool and you might change your opinion…


The thing is, it also respawns the gui (only if window is active of course) every time a sample is added to instrument, or another instrument is selected. So right now I’ve modified the code a little bit, as you can see on this page (starting line #303), but it definitely became less readable code, and I wished I could just type

bind = smp.volume  

instead if adding a whole notifier function for it (i’m just complaining, I know, less code ‘readability’ making maintenance of such a tool a little shittier)

Yes, simple lines for binding would make stuff easier to maintain.
If all fails it all comes up to simply creating a function for that to get the code more readable…
like bind(smp.volume).
I will check out that instrmix tool of yours as soon as i get back to the Netherlands. I currently have no opportunity to test stuff at all.