user488792
user488792

Reputation: 2013

Determining Note Durations based on Onset Locations

I have a question regarding how to determine the Duration of notes given their Onset Locations.

So for example, I have an array of amplitude values (containing short) and another array of the same size, that contains a 1 if a note onset is detected, and a 0 if not. So basically, the distance between each 1 will be used to determine the duration.

How can I do this? I know that I have to use the Sample Rate and other attributes of the audio data, but is there a particular formula that I can use?

Thank you!

Upvotes: 1

Views: 120

Answers (2)

Adam
Adam

Reputation: 603

So you are starting with a list of ONSETS, what you are really looking for is a list of OFFSETS.

There are many methods for onset detection (here is a paper on it) https://adamhess.github.io/Onset_Detection_Nov302011.pdf

many of the same methods can be applied to Offset Detection:

Since the onset is marked by an INCREASE in spectral content you can measure a decrease in Spectral content.

  1. take a reasonable time window before and after your onset. (.25-.5s)
  2. Chop up the window into smaller segments and take 50% overlapping Fourier transforms.
  3. compute the difference between the fourier co-efficient between two successive windows decreases and only allow negative changes in SD.
  4. multiple your results by -1.
  5. pick the peaks off of the results
  6. Voila, offsets.

(look at page 7 of the paper listed above for more detail about spectrial difference function, you can apply a modified (as above) version of it_

Upvotes: 1

KlausCPH
KlausCPH

Reputation: 1835

Well, if your samplerate in Hz is fs, then the time between two nodes is equal to

1/fs * <number of zeros between the two node-ones>

Very simple :-)

Regards

Upvotes: 0

Related Questions