How to Delete unnecessary parts from a sample? (in SP, no external software)

HELLO ALL,
is there any way to delate unnecessary parts of a sample?
lets say I’m sampled 4 second at 96khz, there is a 1 second of silence in the beginning of the recording and 1 second in the end until I pressed stop-recording and i want to load from 96001 sample to 288k sample (96*3) in a new variable or sample,
like in the akai mpc where the first edit is to delete unwanted parts of the sample.
THANKS
edit: for a fast workflow I’m asking about doing this inside sonic-pi on the flow of the code.

Are you talking about using external software to alter (or produce a new sample from) the file in question?
If so, Audacity is a useful open source audio editing tool that I’m sure many folks here on the forum are quite happy with for this sort of thing.

(There are no doubt many alternatives as well :slight_smile:)

1 Like

Thanks but no,
I’m familiar with Audacity but I’m asking about sonic pi capabilities to edit samples with out the need of external software, for a fast workflow…
(I will edit the title)

1 Like

In that case, the documentation for sample shows that you can play sections of samples by using the start: and finish: opts, but they work on a scale of 0 - 1 as a proportion of the sample length, not in units of audio samples. You could use this to calculate the precise audio samples to play. (Or, if you are determined to produce a new sample not containing the silence, wrap the calculated sample region in a :record fx to produce a new sample directly in Sonic Pi).

1 Like

I use the start: and finish: but with num_slices: it slice with the part I don’t want…
I’ll try this :record THANKS!

Sure. A code example of your current attempt (and then an explanation of what you are wanting it to do, if that would help to make it any clearer than what you wrote in your first post) would be helpful for a bit more context :slight_smile:

1 Like

I think however, that possibly, your issue could be related to the following comment in the sample documentation for the slice: opt:

If start: or finish: opts are used in addition to slice: then they will work within the slice rather than the whole sample.

(Unless you are not specifically using the slice: opt)

Hi,

and

the full article written by Sam himself

page 54

1 Like

There is also the sample onset parameter, which may be good enough for your needs. Can someone explain "Onset" - #2 by mrbombmusic

Hi, this is the best I could come up with
[Edit, removed duplicate ticks!]

use_bpm 160
live_loop :test do ; tick
  s = :loop_amen
  s_length = 1.753
  s_start = 0.435 # 0
  s_end = 1.3     # 1.753
  starts = (line s_start, s_end, steps: 16, inclusive: true)
  finishes = (line starts[1], starts[15], steps: 15, inclusive: true)
  
  sample s,
    start: (starts.take(15)[look]/s_length),
    finish: (finishes[look]/s_length),
    amp: 4,
    beat_stretch: 4
  
  sleep 0.25
end