local sample_buffer = renoise.song().selected_sample.sample_buffer
-- check if sample data is preset at all firstif (sample_buffer.has_sample_data) then-- before touching any sample, let renoise create undo data, when necessary
sample_buffer:prepare_sample_data_changes()
-- modify sample data in the selection (defaults to the whole sample)for channel = 1, sample_buffer.number_of_channels dofor frame = sample_buffer.selection_start, sample_buffer.selection_end dolocal value = sample_buffer:sample_data(channel, frame)
value = -value -- do something with the value
sample_buffer:set_sample_data(channel, frame, value)
endend-- let renoise update sample overviews and caches. apply bit depth -- quantization. create undo/redo data if needed...
sample_buffer:finalize_sample_data_changes()
else
renoise.app():show_warning("No sample preset...")
end
local selected_sample = renoise.song().selected_sample
local sample_buffer = selected_sample.sample_buffer
-- create new or overwrite sample data for our sound:local sample_rate = 44100local num_channels = 1local bit_depth = 32local num_frames = sample_rate / 2local allocation_succeeded = sample_buffer:create_sample_data(
sample_rate, bit_depth, num_channels, num_frames)
-- check for allocation failuresif (not allocation_succeeded) then
renoise.app():show_error("Out of memory. Failed to allocate sample data")
returnend-- let renoise know we are about to change the sample buffer
sample_buffer:prepare_sample_data_changes()
-- fill in the sample data with an amazing zapp soundfor channel = 1,num_channels dofor frame = 1,num_frames dolocal sample_value = math.sin(num_frames / frame)
sample_buffer:set_sample_data(channel, frame, sample_value)
endend-- let renoise update sample overviews and caches. apply bit depth -- quantization. finalize data for undo/redo, when needed...
sample_buffer:finalize_sample_data_changes()
-- setup a pingpong loop for our new sample
selected_sample.loop_mode = renoise.Sample.LOOP_MODE_PING_PONG
selected_sample.loop_start = 1
selected_sample.loop_end = num_frames