yes.
Onsets is realtime though.
this seems to at least sort of work, if realtime onset cutting is of interest:
Routine {
// input file. must be mono
~input = "path_to_input_file";
// load the input file into a buffer
b = Buffer.read(s, ~input);
// list of onset positions (seconds in buffer)
~onsets = List.new;
// estimate of analysis latency (FIXME: guess smarter)
~latency = 0.005;
// SendTrig will send OSC, here we capture it
o = OSCFunc({
arg msg;
var pos;
pos = msg[3] - ~latency;
~onsets.add(pos);
}, '\tr');
postln("analyzing...");
~syn = {
// play the buffer, and perform FFT required for Onsets
var chain = FFT(LocalBuf(2048), PlayBuf.ar(1, b));
// on each onset, send the time since synth was started
SendTrig.kr(Onsets.kr(chain), value: Sweep.kr(0, 1));
}.play(s);
~syn.postln;
// wait til we're done playing
/// FIXME: i'm getting some weird error if i try to use the actual buf duration.
/// could instead auto-free the synth and use NodeWatcher, or tevuse PlayBuf to send a second trigger, or whatever.
//~dur = b.duration + 1.0;
//~dur.wait;
/// for now, pretend the buffer is 2s long, sorry
2.0.wait;
~syn.free;
postln("done analyzing.");
postln("chopping...");
// current start position in file
t = 0;
~onsets.do({ |x, i|
[x,i].postln;
/// write a new file from the buffer, with appropriate name / offset / duration
b.write( path: ~input ++ ".chop-" ++ i ++ ".aiff",
startFrame: t * b.sampleRate,
numFrames: (x - t) * b.sampleRate);
t = x;
});
postln("done chopping.");
}.play;
you could add DetectSilence and a second tr.igger and stuff
you could also adapt this to non-realtime by launching an NRT supercollider server and doing some other junk to control it. there are probably better options out there for NRT sample analysis, though i donāt know them off the top of my head.