Just to add a little further Raul and your question ‘Is value 51 omitted?’…
Well let’s think about this, a couple of things to keep in mind. Firstly remember that in Lua a value of say 51 is represented internally as a floating point value and not a whole integer. So you can write:
renoise.song().tracks[1].color_blend = 51.999
Secondly, we know at that moment that the color_blend variable can range from 0 to 100. However the slider numerical value seems to scale from 0 to 99 (however you can slide the slider all the way to the right and it will latch the value 100, it’s just the numerical value will still read 99.) One way of looking at this is if someone asked me to take a value between 0 and 100 and scale the value so that it is now between 0 and 99 I’d probably multiply the value with 0.99 If we take a few numbers and do that:
12 * 0.99 = 11.88
32 * 0.99 = 31.68
50 * 0.99 = 49.5
51 * 0.99 = 50.49
74 * 0.99 = 73.26
Thing to notice here is that once the value goes > 50, the last two scaled digits fall below half. Well you could (as speculation) argue that that maybe goes some way of explaining why when you put a value > 50 into color_blend via lua, the numerical value display goes out by 1? Depends on how Renoise/Lua is internally rounding the floating point values Raul. ‘Is value 51 omitted?’ Well I’d say no (it wouldn’t make much sense for the programmer to isolate value 51 and remove it out of the number line ), it is just how it looks via that numerical value which only shows the values between 0-99.
Just as a side note: Funnily enough a ‘floating point rounding thing’ can vary between Renoise os versions. For example if you write this in Windows 7 32-bit Renoise:
renoise.song().tracks[1].color_blend = 100.8
An exception is thrown because it probably has rounded the value internally up to 101. However writing the same thing with my Linux 64-bit version of Renoise produces no exception, possibly because it has ‘floored’ the value to 100? To imagine: Little things like this though with floating point in computing Raul can be the mathematical difference between defcon 2 and red alert defcon 1
This is very interesting and makes sense.If the cause is to take a multiplier of 0.99, this method causes an error (number jump).Would not it be easier to use a range from 0 to 99, because it is simpler?
If we choose to use a valuebox with a range of 0-99, is possible to use a correcting conditioner ( if a > 50 then a = a + 1 end ) so that the color_blend value matches the slider.I have solved it this way in my tool:
--------------------------------------------------------------------------------
-- REARM BACKGROUND BLEND (COLOR BLEND)
--------------------------------------------------------------------------------
--Rearm color blend --song.tracks[].members[] --song.tracks[].group_parent
function pest_fn_rearm_cblend( song, a, b, c, d, e )
song = renoise.song()
a = vb.views['PEST_VB_CBLEND_TRACK'].value
b = vb.views['PEST_VB_CBLEND_SGROUP'].value
c = vb.views['PEST_VB_CBLEND_GROUP'].value
--correctors for color_blend >50. In background color slider, if color_blend < 51 then a = a. If color_blend > 50 then a = a + 1
if ( a > 50 ) then a = a + 1 end
if ( b > 50 ) then b = b + 1 end
if ( c > 50 ) then c = c + 1 end
for i = #song.tracks, 1, -1 do
d = song.tracks[i]
e = renoise.Track
if ( d.type == e.TRACK_TYPE_SEQUENCER or d.type == e.TRACK_TYPE_SEND ) then
d.color_blend = a
elseif ( d.type == e.TRACK_TYPE_GROUP ) then
if not d.group_parent then --if selected track does not have group_parent
d.color_blend = c
else --if selected track have group_parent
d.color_blend = b
end
elseif ( d.type == e.TRACK_TYPE_MASTER ) then
d.color_blend = c
end
end
end
PEST_VB_CBLEND_TRACK = vb:row { vb:text { text = ' Tr', height = 22 },
vb:valuebox { id = 'PEST_VB_CBLEND_TRACK', width = 50, height = 22, min = 0, max = 99, value = 15,
notifier = function() if vb.views['PEST_CB_RTIME'].value == true then pest_fn_rearm_cblend() end end, tooltip = 'Value of background blend to tracks & sends.\n[Default value = 15]' }
}
PEST_VB_CBLEND_SGROUP = vb:row { vb:text { text = ' SGr', height = 22 },
vb:valuebox { id = 'PEST_VB_CBLEND_SGROUP', width = 50, height = 22, min = 0, max = 99, value = 30,
notifier = function() if vb.views['PEST_CB_RTIME'].value == true then pest_fn_rearm_cblend() end end, tooltip = 'Value of background blend to subgroups.\n[Default value = 30]' }
}
PEST_VB_CBLEND_GROUP = vb:row { vb:text { text = ' Gr', height = 22 },
vb:valuebox { id = 'PEST_VB_CBLEND_GROUP', width = 50, height = 22, min = 0, max = 99, value = 55,
notifier = function() if vb.views['PEST_CB_RTIME'].value == true then pest_fn_rearm_cblend() end end, tooltip = 'Value of background blend to groups (parents) & master.\n[Default value = 55]' }
}
PEST_BT_CBLEND = vb:button { id = 'PEST_BT_CBLEND', width = 49, height = 22, text = 'Blend', color = { 0x00,0x40,0x70 },
notifier = function() pest_fn_rearm_cblend() end, tooltip = 'Rearm the background blend to all tracks.'
}
PEST_CB_RTIME = vb:row {
vb:text { text = ' RT', height = 22 },
vb:vertical_aligner { mode = 'distribute',
vb:checkbox { id = 'PEST_CB_RTIME', value = false,
notifier = function()
if vb.views['PEST_CB_RTIME'].value == true then
vb.views['PEST_BT_CBLEND'].color = { 0x40,0x00,0x00 } vb.views['PEST_BT_CBLEND'].active = false
else
vb.views['PEST_BT_CBLEND'].color = { 0x00,0x40,0x70 } vb.views['PEST_BT_CBLEND'].active = true
end
end,
tooltip = 'Rearm in real time the background blend to type of track.\nTr = tracks & sends.\nSGr = subgroups.\nGr = groups (parents) & master.'
}
}
}
Adding this patch:
--correctors for color_blend >50. In background color slider, if color_blend < 51 then a = a. If color_blend > 50 then a = a + 1
if a > 50 then a = a + 1 end
if b > 50 then b = b + 1 end
if c > 50 then c = c + 1 end