{"action":"created","issue":{"url":"https://api.github.com/repos/librosa/librosa/issues/305","repository_url":"https://api.github.com/repos/librosa/librosa","labels_url":"https://api.github.com/repos/librosa/librosa/issues/305/labels{/name}","comments_url":"https://api.github.com/repos/librosa/librosa/issues/305/comments","events_url":"https://api.github.com/repos/librosa/librosa/issues/305/events","html_url":"https://github.com/librosa/librosa/issues/305","id":133887581,"number":305,"title":"Onset tweaking","user":{"login":"kylemcdonald","id":157106,"avatar_url":"https://avatars.githubusercontent.com/u/157106?v=3","gravatar_id":"","url":"https://api.github.com/users/kylemcdonald","html_url":"https://github.com/kylemcdonald","followers_url":"https://api.github.com/users/kylemcdonald/followers","following_url":"https://api.github.com/users/kylemcdonald/following{/other_user}","gists_url":"https://api.github.com/users/kylemcdonald/gists{/gist_id}","starred_url":"https://api.github.com/users/kylemcdonald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kylemcdonald/subscriptions","organizations_url":"https://api.github.com/users/kylemcdonald/orgs","repos_url":"https://api.github.com/users/kylemcdonald/repos","events_url":"https://api.github.com/users/kylemcdonald/events{/privacy}","received_events_url":"https://api.github.com/users/kylemcdonald/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/librosa/librosa/labels/discussion","name":"discussion","color":"eb6420"},{"url":"https://api.github.com/repos/librosa/librosa/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/librosa/librosa/labels/functionality","name":"functionality","color":"fbca04"},{"url":"https://api.github.com/repos/librosa/librosa/labels/Hacktoberfest","name":"Hacktoberfest","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/librosa/librosa/milestones/8","html_url":"https://github.com/librosa/librosa/milestones/0.5","labels_url":"https://api.github.com/repos/librosa/librosa/milestones/8/labels","id":949792,"number":8,"title":"0.5","description":null,"creator":{"login":"bmcfee","id":1190540,"avatar_url":"https://avatars.githubusercontent.com/u/1190540?v=3","gravatar_id":"","url":"https://api.github.com/users/bmcfee","html_url":"https://github.com/bmcfee","followers_url":"https://api.github.com/users/bmcfee/followers","following_url":"https://api.github.com/users/bmcfee/following{/other_user}","gists_url":"https://api.github.com/users/bmcfee/gists{/gist_id}","starred_url":"https://api.github.com/users/bmcfee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmcfee/subscriptions","organizations_url":"https://api.github.com/users/bmcfee/orgs","repos_url":"https://api.github.com/users/bmcfee/repos","events_url":"https://api.github.com/users/bmcfee/events{/privacy}","received_events_url":"https://api.github.com/users/bmcfee/received_events","type":"User","site_admin":false},"open_issues":20,"closed_issues":42,"state":"open","created_at":"2015-01-24T18:03:39Z","updated_at":"2016-10-08T15:19:41Z","due_on":null,"closed_at":null},"comments":10,"created_at":"2016-02-16T05:09:20Z","updated_at":"2016-10-11T10:59:08Z","closed_at":null,"body":"I'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:\r\n\r\n```python\r\ndef tweak_onsets(onset_frames, o_env):\r\n    tweaked = []\r\n    for onset_frame in onset_frames:\r\n        while True:\r\n            if onset_frame == 0:\r\n                break\r\n            cur = o_env[onset_frame]\r\n            prev = o_env[onset_frame - 1]\r\n            if prev > cur:\r\n                break\r\n            onset_frame = onset_frame - 1\r\n        tweaked.append(onset_frame)\r\n    return np.array(tweaked)\r\n```\r\n\r\nSome onsets before:\r\n\r\n![before](https://cloud.githubusercontent.com/assets/157106/13067714/6cbb68c2-d441-11e5-9a05-fe0e2f3e3ecb.png)\r\n\r\nAnd after:\r\n\r\n![after](https://cloud.githubusercontent.com/assets/157106/13067718/746bb2de-d441-11e5-9120-6c887c2cd3ed.png)\r\n\r\nIt'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."},"comment":{"url":"https://api.github.com/repos/librosa/librosa/issues/comments/252881919","html_url":"https://github.com/librosa/librosa/issues/305#issuecomment-252881919","issue_url":"https://api.github.com/repos/librosa/librosa/issues/305","id":252881919,"user":{"login":"kylemcdonald","id":157106,"avatar_url":"https://avatars.githubusercontent.com/u/157106?v=3","gravatar_id":"","url":"https://api.github.com/users/kylemcdonald","html_url":"https://github.com/kylemcdonald","followers_url":"https://api.github.com/users/kylemcdonald/followers","following_url":"https://api.github.com/users/kylemcdonald/following{/other_user}","gists_url":"https://api.github.com/users/kylemcdonald/gists{/gist_id}","starred_url":"https://api.github.com/users/kylemcdonald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kylemcdonald/subscriptions","organizations_url":"https://api.github.com/users/kylemcdonald/orgs","repos_url":"https://api.github.com/users/kylemcdonald/repos","events_url":"https://api.github.com/users/kylemcdonald/events{/privacy}","received_events_url":"https://api.github.com/users/kylemcdonald/received_events","type":"User","site_admin":false},"created_at":"2016-10-11T10:59:08Z","updated_at":"2016-10-11T10:59:08Z","body":"The time reassignment stuff is interesting, but yes I think it's solving a different problem.\r\n\r\nFundamentally what I was looking for (and what I'm guessing other remix-oriented people are looking for) is a feature akin to Ableton's automatic slicing functionality. From experience, I feel like Ableton is sample-based rather than frame-based in its final decision. `util.match_events` would be useful, but I think looking backward only (not nearest) is essential when talking about onsets.\r\n\r\nRegarding zero-crossings, I can think of at least two counter examples: audio with a significant DC offset (rare) and mid/high frequency sounds where they oscillate/zc faster than their onset time (more common).\r\n\r\nIn short, I feel like an Ableton-quality slicer is not trivial, but you could get close looking for the minimum in a higher resolution \"moving loudness\" sample-accurate estimate.\r\n\r\nSorry to revive this thread I just saw it in my GitHub mentions and had to say something :)"}}
{"actor":{"display_login":"kylemcdonald"}}