Finding onsets in audio buffer

i would like to find the onsets in an audio buffer as a list of timestamps. i see there is a thread about this from last year, but the proposed code doesn’t work for me on SC 3.11.2 / macOS, failing with:

Execution warning: Class 'Deferred' not found
ERROR: Message 'new' not understood.
PATH: /Users/ahihi/SyncBig/sc/onsets.scd
		arg this = <instance of DoesNotUnderstandError>
		arg this = nil
		arg error = <instance of DoesNotUnderstandError>
		arg this = <instance of Thread>
		arg error = <instance of DoesNotUnderstandError>
		arg this = <instance of Routine>
		arg error = <instance of DoesNotUnderstandError>
		arg this = <instance of DoesNotUnderstandError>
		arg this = nil
		arg selector = 'new'
		arg args = [*0]
		arg this = <instance of OfflineProcessRun>
		arg parent = <instance of OfflineProcess>
		arg inFileOrTime = "/Users/ahihi/SyncBig/sc/test..."
		arg inArgs = nil
		arg this = <instance of OfflineProcess>
		arg fileOrTime = "/Users/ahihi/SyncBig/sc/test..."
	< closed FunctionDef >
		var path = "/Users/ahihi/SyncBig/sc/test..."
		arg this = <instance of Routine>
		arg inval = 221.40721391499
^^ The preceding error dump is for ERROR: Message 'new' not understood.

so i’m wondering if anyone knows a working approach.

looks like you don’t have the required “OfflineProcess” quark installed!


no, this is after successfully installing the quark.

i am able to create the OfflineProcess object, but the error occurs when calling .process.

hmmm looks like Scztt’s quark has a dependency - might want to hunt through his other quarks for a class called “Deferred” @Scztt ?

Yep he’s got a quark called “Deferred” guessing that’s it.

A lot of cool (and readable!) stuff in Scztt’s github btw!!

ah, that was it! thanks :slight_smile: after installing Deferred and also it now works.

@pulusound Have you done something else for working with this Quark? Can you share the exact code that you are running ?

I’m trying to run the Quark’s example but it is only returning nil on the .resultFile method:

(Currently this Quark is also installing Log and Defered by the default. I am on mac os and Sc 3.11.2.)

~inFile = "/Users/fsc/Downloads/STE-039 a.wav";

~proc = OfflineProcess();

// Audio-rate process - produces an audio file of equal length to the input
~proc.putAr(\compress, {
    |input|, input, 0.2, 1, 1 / 30);

// Control-rate process - produces an audio file of control-rate signal
~proc.putAr(\amplitude, {

// Triggered process. Output should be of the form [trigger, [a, b, c....]]
// Whenever the value at trigger crosses from non-positive to positive, the subsequent values (i.e. a, b, c)
// are recorded.
~proc.putTrig(\peaks, {
    |input, time, delay=10|
    var amp, peakAmp, reset, peakTime, timeSincePeak, newPeak, recordTrig;

    reset =;

    amp =;
    peakAmp =, reset);
    newPeak =;, peakAmp, "peak");
    peakTime =, newPeak);
    timeSincePeak =;
    recordTrig = > delay), 0.001);;

    [recordTrig, [peakTime, peakAmp]]

~proc.outputPath = "~/Desktop/".standardizePath;

~run1 = ~proc.process(~inFile);

// Get results:



When the class library is compiling I am getting the following warning:

WARNING: SCDoc: OfflineProcess has no categories!