Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local par_table = {}
- local par_string_table = {}
- local t_final = {}
- local old_str = 'x'
- local function dump_pars(par)
- local adjusted_string
- par.value = 0
- for x=0, 1, 0.1 do --0.1 for testing purposes, full range will take too long
- par.value = x
- if old_str ~= par.value_string then
- old_str = par.value_string
- --remove non-digits
- adjusted_string = string.gsub(par.value_string, '%a' , '')
- adjusted_string = string.gsub(adjusted_string, '%p', '')
- --insert
- table.insert(par_table, par.value)
- table.insert(par_string_table, tonumber(adjusted_string))
- end
- end
- --add 00
- local par_string_table_00 = {}
- for i=1, #par_string_table do
- table.insert(par_string_table_00, par_string_table[i]*100)
- end
- par_string_table = par_string_table_00
- --interpolate
- local function interpol(y,y1,y2,y3,x)
- local x2 = x*x
- local a = y3 - y2 - y + y1
- local a1 = y - y1 - a
- local a2 = y2 - y
- return(a*x*x2+a1*x2+a2*x+y3)
- end
- --for readability
- local tt = table.rcopy(par_string_table)
- local ts = table.rcopy(par_table)
- for i=1, #tt do
- --return if reached the end of the table
- if not tt[i+3] then break end
- --load up the values for interpolation
- local ts0, ts1, ts2, ts3 = ts[i], ts[i+1], ts[i+2], ts[i+3]
- local tt0, tt1, tt2, tt3 = tt[i], tt[i+1], tt[i+2], tt[i+3]
- for x=1, 99 do
- --interpolate values at t0+x (starting value handled with +x)
- local interp_key = interpol(ts0, ts1, ts2, ts3, ts0+x)
- local interp_val = interpol(tt0, tt1, tt2, tt3, tt0+x)
- --insert result of interpolation in between the current values with additional '00' in the original tables, at position i+1 (insert data right before next iteration's data)
- table.insert(par_string_table, i+1, interp_key)
- table.insert(par_table, i+1, interp_val)
- end
- end
- for i=1, #par_table do
- table.insert(t_final, par_string_table[i], par_table[i])
- print(t_final[par_string_table[i]], par_string_table[i], par_table[i])
- end
- end
- local sel_par = renoise.song().selected_device:parameter(2)
- dump_pars(sel_par)
- --for x=1, #par_table do
- -- par_table[x] = '<Point>'..x..','..par_table[x]..'</Point>'
- -- end
- -- for x=1, #par_table do
- -- print(par_table[x])
- -- end
Advertisement
Add Comment
Please, Sign In to add comment