Suva’s inbox seems to be full? “this member can’t receive private messages” or something like that.
so here’s my pm, plus code that should actually work (but surely will contain bugs, the usual precautions apply):
hey there!
I had a quick (and probably sloppy) go to see if I could make your rubberband plugin apply only to the current selection, and it seems to work!
well, the temporary sample creation feels a bit dogdy, and I yet have no idea how to make the new sample have the same properties as the old one. but as a proof of concept it’s okay.
one other thing I really would like to do is to make it non modal, and allow getting the durations for timestretching from the current selection. oh, and remove the loop if the original sample didn’t have one. so I’d like to know if you’re currently working on this, if I should wait until your update etc.
oh, here goes the actual stuff, just replace that function and try it on vocal samples, it’s kinda cool.
[details=“Click to view contents”] ```lua
function process_rubberband(cmd)
local exe
if os.platform() == ‘WINDOWS’ then
exe = ‘"’ … renoise.tool().bundle_path … ‘bin/win32/rubberband.exe"’
elseif os.platform() == ‘MACINTOSH’ then
exe = ‘"’ … renoise.tool().bundle_path … ‘bin/osx/rubberband"’
else
exe = ‘rubberband’
end
local ofile = os.tmpname(‘wav’)
local ifile = os.tmpname(‘wav’)
local xfile = os.tmpname(‘wav’)
local buffer = renoise.song().selected_sample.sample_buffer
– create temporary sample to hold the selection
local instrument = renoise.song().selected_instrument
local temp_sample = renoise.song().selected_instrument:insert_sample_at(renoise.song().selected_sample_index + 1)
local temp_buffer = temp_sample.sample_buffer
local temp_sample2 = renoise.song().selected_instrument:insert_sample_at(renoise.song().selected_sample_index + 1)
local temp_buffer2 = temp_sample2.sample_buffer
if (not temp_buffer:create_sample_data(buffer.sample_rate, buffer.bit_depth, buffer.number_of_channels, (buffer.selection_end - buffer.selection_start) + 1 )) then
renoise.app():show_error(“Couldn’t create sample!”) return
end
local int_frame
local int_chan
local int_new_frame
– copy the selection
for int_chan = 1, buffer.number_of_channels do
int_new_frame = 1
for int_frame = buffer.selection_start, buffer.selection_end do
temp_buffer:set_sample_data(int_chan, int_new_frame, buffer:sample_data(int_chan, int_frame))
int_new_frame = int_new_frame + 1
end
end
– save the temporary sample
temp_buffer:save_as(ofile, ‘wav’)
– process the file
os.execute(exe … " " … cmd … " “…ofile…” "…ifile);
if not io.exists(ifile) then
display_error()
return
end
temp_buffer:load_from(ifile)
– allocate the second sample buffer
– the size is “stuff outside the selection” + “size of processed file”
if not temp_buffer2:create_sample_data(buffer.sample_rate, buffer.bit_depth, buffer.number_of_channels, (buffer.number_of_frames - (buffer.selection_end - buffer.selection_start) + 1) + temp_buffer.number_of_frames)
then
renoise.app():show_error(“Couldn’t create sample!”) return
end
– copy the selection back
int_new_frame = 1
– copy the part before the selection
if buffer.selection_start > 1 then
for int_frame = 1, buffer.selection_start - 1 do
for int_chan = 1, buffer.number_of_channels do
temp_buffer2:set_sample_data(int_chan, int_frame, buffer:sample_data(int_chan, int_frame))
end
int_new_frame = int_new_frame + 1
end
end
– copy the processed part selection
for int_frame = 1, temp_buffer.number_of_frames do
for int_chan = 1, buffer.number_of_channels do
temp_buffer2:set_sample_data(int_chan, int_new_frame, temp_buffer:sample_data(int_chan, int_frame))
end
int_new_frame = int_new_frame + 1
end
– copy the part after the selection
if buffer.selection_end < buffer.number_of_frames then
for int_frame = buffer.selection_end, buffer.number_of_frames do
for int_chan = 1, buffer.number_of_channels do
temp_buffer2:set_sample_data(int_chan, int_new_frame, buffer:sample_data(int_chan, int_frame))
end
int_new_frame = int_new_frame + 1
end
end
temp_buffer2:save_as(xfile, ‘wav’)
buffer:load_from(xfile)
–buffer:finalize_sample_data_changes()
– delete original sample and the one of the temporary samples
– (and make sure this doesn’t delete the wrong samples perhaps… ?!)
instrument:delete_sample_at(renoise.song().selected_sample_index + 1)
instrument:delete_sample_at(renoise.song().selected_sample_index + 1)
os.remove(ofile)
os.remove(ifile)
os.remove(xfile)
end
cheers!