Someone can create this tool?

Hi, someone can create a tool that make these operations on a sample:

maximize volume, set loop to forward, adjust sample to 16 bit, and then open “save sample…” dialog!

I’m going to sample many many one shot wave from my keyboards, virus ti, motif es, nord stage…

once I’ve finished, I’ll put these samples on my web!

Thanks very much!

1 Like

Set Loop to Forward should be easy with the Renoise API.

Not so sure about if there is an API function for Maximize Volume, or for opening the save dialogue. If there is, please chime in!

Normalizing samples isn’t hard. Here is a snippet you can paste into the scripting console and run

-- Normalize selected sample to 100% volume

local sample = renoise.song().selected_sample
local sbuf = sample.sample_buffer

if (sbuf.has_sample_data) then

  -- collect the highest peak value
  local highest_detected = 0
  for frame_idx = 1, sbuf.number_of_frames do
    if (sbuf.number_of_channels == 2) then
      highest_detected = math.max(math.abs(sbuf:sample_data(1,frame_idx)),highest_detected)
      highest_detected = math.max(math.abs(sbuf:sample_data(2,frame_idx)),highest_detected)
    else
      highest_detected = math.max(math.abs(sbuf:sample_data(1,frame_idx)),highest_detected)
    end    
  end
  --print("highest_detected",highest_detected)

  sbuf:prepare_sample_data_changes()
  
  -- apply the peak value to the data
  for frame_idx = 1, sbuf.number_of_frames do
    if (sbuf.number_of_channels == 2) then
      local normalized_sdata = sbuf:sample_data(1,frame_idx) / highest_detected
      sbuf:set_sample_data(1,frame_idx,normalized_sdata)
      local normalized_sdata = sbuf:sample_data(2,frame_idx) / highest_detected
      sbuf:set_sample_data(2,frame_idx,normalized_sdata)
    else
      local normalized_sdata = sbuf:sample_data(1,frame_idx) / highest_detected
      sbuf:set_sample_data(1,frame_idx,normalized_sdata)
    end    
  end
  
  sbuf:finalize_sample_data_changes()  
  
end

highest_detected = math.max(sbuf:sample_data(1,frame_idx),highest_detected)

It’s important to consider situations where the sample’s negative phase may peak louder than its positive phase.

We can of course use math.abs() to handle this quite easily:

highest_detected = math.max(math.abs(sbuf:sample_data(1, frame_idx)), highest_detected)

You are of course right - I realized it immediately after posting :slight_smile:

Hi, someone can create a tool that make these operations on a sample:

maximize volume, set loop to forward, adjust sample to 16 bit, and then open “save sample…” dialog!

I’m going to sample many many one shot wave from my keyboards, virus ti, motif es, nord stage…

once I’ve finished, I’ll put these samples on my web!

Thanks very much!

Hey Ballacr,

at least for saving I have a tip for you: I simply render samples using keyboard shortcut (ctrl-shift-r : render selection). Each time a new sample is created inside Renoise and I rename it. Afterwards I export all samples to disk in flac format using the tool “Export all samples to disk” from vvois.

Regarding normalization: I’m not sure if it makes much sense to maximize samples to zero headroom, because then they are pretty loud when inserted. Though, may be interesting in those cases where a sample uses the the full 16 bit dynamic range. That’s the reason why I prefer 24 bit samples with some headroom.

Hey, thanks for your suggest!