Hi Kommandotolken,
You can use the Lua Length operator #
in front of tables to get the number of entries, so:
for i = 1, #renoise.song().instruments do
Note: the count would be from 1 and not 0 aswell.
You would also need to do an internal loop for the list of samples in each instrument, so:
for i = 1, #renoise.song().instruments do
for j = 1, #renoise.song():instrument(i).samples do
--access bit depth
renoise.song():instrument(i):sample(j).sample_buffer.bit_depth
end
end
edit: it looks like the .bit_depth is read only from the docs so it looks like you will need to work with the sample data directly. A part of the API I`ve not delved into but here are the relevant docs:
--------------------------------------------------------------------------------
-- renoise.SampleBuffer
--------------------------------------------------------------------------------
-------- Constants
renoise.SampleBuffer.CHANNEL_LEFT
renoise.SampleBuffer.CHANNEL_RIGHT
renoise.SampleBuffer.CHANNEL_LEFT_AND_RIGHT
-------- Functions
-- Create new sample data with the given rate, bit-depth, channel and frame
-- count. Will trash existing sample data. Initial buffer is all zero.
-- Will only return false when memory allocation fails (you're running out
-- of memory). All other errors are fired as usual.
renoise.song().instruments[].samples[].sample_buffer:create_sample_data(
sample_rate, bit_depth, num_channels, num_frames)
-> [boolean, success]
-- Delete existing sample data.
renoise.song().instruments[].samples[].sample_buffer:delete_sample_data()
-- Read access to samples in a sample data buffer.
renoise.song().instruments[].samples[].sample_buffer:sample_data(
channel_index, frame_index)
-> [number -1-1]
-- Write access to samples in a sample data buffer. New samples values must be
-- within [-1, 1] and will be clipped automatically. Sample buffers may be
-- read-only (see property 'read_only'). Attempts to write on such buffers
-- will result into errors.
-- IMPORTANT: before modifying buffers, call 'prepare_sample_data_changes'.
-- When you are done, call 'finalize_sample_data_changes' to generate undo/redo
-- data for your changes and update sample overview caches!
renoise.song().instruments[].samples[].sample_buffer:set_sample_data(
channel_index, frame_index, sample_value)
-- To be called once BEFORE sample data gets manipulated via 'set_sample_data'.
-- This will prepare undo/redo data for the whole sample. See also
-- 'finalize_sample_data_changes'.
renoise.song().instruments[].samples[].sample_buffer:prepare_sample_data_changes()
-- To be called once AFTER the sample data is manipulated via 'set_sample_data'.
-- This will create undo/redo data for the whole sample, and also update the
-- sample view caches for the sample. The reason this isn't automatically
-- invoked is to avoid performance overhead when changing sample data 'sample by
-- sample'. Don't forget to call this after any data changes, or changes may not
-- be visible in the GUI and can not be un/redone!
renoise.song().instruments[].samples[].sample_buffer:finalize_sample_data_changes()
-- Load sample data from a file. Files can be any audio format Renoise supports.
-- Possible errors are shown to the user, otherwise success is returned.
renoise.song().instruments[].samples[].sample_buffer:load_from(filename)
-> [boolean, success]
-- Export sample data to a file. Possible errors are shown to the user,
-- otherwise success is returned. Valid export types are 'wav' or 'flac'.
renoise.song().instruments[].samples[].sample_buffer:save_as(filename, format)
-> [boolean, success]
-------- Properties
-- Has sample data?
renoise.song().instruments[].samples[].sample_buffer.has_sample_data
-> [read-only, boolean]
-- _NOTE: All following properties are invalid when no sample data is present,
-- 'has_sample_data' returns false:_
-- True, when the sample buffer can only be read, but not be modified. true for
-- sample aliases of sliced samples. To modify such sample buffers, modify the
-- sliced master sample buffer instead.
renoise.song().instruments[].samples[].sample_buffer.read_only
-> [read-only, boolean]
-- The current sample rate in Hz, like 44100.
renoise.song().instruments[].samples[].sample_buffer.sample_rate
-> [read-only, number]
-- The current bit depth, like 32, 16, 8.
renoise.song().instruments[].samples[].sample_buffer.bit_depth
-> [read-only, number]
-- The number of sample channels (1 or 2)
renoise.song().instruments[].samples[].sample_buffer.number_of_channels
-> [read-only, number]
-- The sample frame count (number of samples per channel)
renoise.song().instruments[].samples[].sample_buffer.number_of_frames
-> [read-only, number]
-- The first sample displayed in the sample editor view. Set together with
-- DisplayLength to control zooming.
renoise.song().instruments[].samples[].sample_buffer.display_start, _observable
-> [number >= 1 <= number_of_frames]
-- The number of samples displayed in the sample editor view. Set together with
-- DisplayStart to control zooming.
renoise.song().instruments[].samples[].sample_buffer.display_length, _observable
-> [number >= 1 <= number_of_frames]
-- The start and end points of the sample editor display.
renoise.song().instruments[].samples[].sample_buffer.display_range[], _observable
-> [array of two numbers, 1-number_of_frames]
-- The vertical zoom level where 1.0 is fully zoomed out.
renoise.song().instruments[].samples[].sample_buffer.vertical_zoom_factor, _observable
-> [number, 0.0-1.0]
-- Selection range as visible in the sample editor. always valid. returns the entire
-- buffer when no selection is present in the UI.
renoise.song().instruments[].samples[].sample_buffer.selection_start, _observable
-> [number >= 1 <= number_of_frames]
renoise.song().instruments[].samples[].sample_buffer.selection_end, _observable
-> [number >= 1 <= number_of_frames]
renoise.song().instruments[].samples[].sample_buffer.selection_range[], _observable
-> [array of two numbers, 1-number_of_frames]
-- The selected channel.
renoise.song().instruments[].samples[].sample_buffer.selected_channel, _observable
-> [enum = CHANNEL_LEFT, CHANNEL_RIGHT, CHANNEL_LEFT_AND_RIGHT]