Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


getOnsets(start, length, peakThreshold, sensThreshold, minLength)


Function to analyze the onsets in an audio file. You specify the audio file with the AudioFile object that is returned by the function. The onset analysis is performed on the sum of all channels in the audio file. The arguments start  and length  define the time range in the audio file to be analyzed. The peakThreshold  and sensThreshold  arguments determine the minimum level and the weight of an onset, the minLength  argument determines the minimum duration between consecutive onsets.

Available in: Controller.


startThe start position in samples.number
lengthThe duration in samples. Set this to equal to or less than 0 to use all samples from the specified start  to the end of the sample.number
peakThresholdThe minimum level in decibels. Onsets with lower level are skipped. The value range is from -96 to 0.number
sensThresholdThe minimum weight in percent. Onsets with lower weight are skipped. The value range is from 0 to 100.number
minLengthThe minimum duration between consecutive onsets in milliseconds. The value range is from 0 to 10000.number

Return Values

Returns an array with the positions of the detected onsets.


Code Block
fname = "vstsound://271CB2CFA75E4295B1C273FA651FE11D/.Samples/g:/projects/yamahacontentserver/Download/Release/ycj/ME_Waveform/Loop145/samples/Loop145_072(2).wav"

af =

onsets = af:getOnsets(0, -1, -24, 0, 10)
for i, pos in ipairs(onsets) do
   print(i.." ".."Onset: "..pos)


See Also: