Onset tweaking
See original GitHub issueI’d like to use librosa onsets for separating transients for sampling. I noticed the peaks are always a little later than where I’d usually chop up a sound, so I wrote a little code to walk them back to the most recent local minima:
def tweak_onsets(onset_frames, o_env):
tweaked = []
for onset_frame in onset_frames:
while True:
if onset_frame == 0:
break
cur = o_env[onset_frame]
prev = o_env[onset_frame - 1]
if prev > cur:
break
onset_frame = onset_frame - 1
tweaked.append(onset_frame)
return np.array(tweaked)
Some onsets before:
And after:
It’s not exactly right, but for my application it works pretty well. I’m not sure that this is something librosa is designed for, and therefore not a bug per se, but I can imagine someone else wanting to use librosa to chop up sounds into transient samples, so I thought I’d leave this note here.
Issue Analytics
- State:
- Created 8 years ago
- Comments:17 (16 by maintainers)
Top Results From Across the Web
What Is Tweaking? Tweaking is the 4th stage that meth users ...
Tweaking is the 4th stage that meth users experience, and is also the most dangerous. The condition occurs when the user has come...
Read more >Tweaking From Meth - How To Get Help | Prosperity Haven
In today's guide, we are going to explain the term of tweaking from meth ... as well as the onset of highly unpleasant...
Read more >Urinary HER2, TWEAK and VCAM-1 levels are ... - PubMed
Urinary HER2, TWEAK and VCAM-1 levels are associated with new-onset proteinuria in paediatric lupus nephritis · Authors · Affiliations.
Read more >'Tweaking' the model for understanding and preventing ...
Although this model addresses some of the core areas that can be targeted to drastically reduce maternal and neonatal morbidity and mortality, ...
Read more >Urinary HER2, TWEAK and VCAM-1 levels are associated ...
These biomarkers were not increased in acute kidney injury or JIA. Conclusion All three biomarkers were associated with new onset proteinuria and increased...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Compromise: factor into it’s own function, and optionally call it from
onset_detect
?onset_backtrack(events, energy)
returnsevents
(frame indices) rolled back to the most recent local min ofenergy
onset_detect(..., backtrack=True, energy=None)
calls above withenergy=onset_envelope
onset_detect(..., backtrack=True, energy=e)
calls above withenergy=e
as a pre-computed energy curvee
(eg, output offeature.rmse
)Sound reasonable?
Thanks @kylemcdonald for responding.
I’m thinking about the API here, and it’s not completely obvious how best to implement this.
One option is to add an
energy
argument toonset_detect
. Ifenergy
is given, then backtracking to local min is enabled. Otherwise, we leave it as is. Note: we can’t directly compute energy from withinonset_detect
because it’s input may just be the onset envelope, and not the input signal.Backtracking on the onset envelope itself is probably not correct, but maybe better than nothing? Should we make that an option as well?
Alternately, we could just make backtracking into a separate function that takes in onset times and an energy signal, and does the backtracking.
[Tagging @craffel for thoughts]