# How to access data from onset function (using lambda)?

**URL:** <https://in-thread.sonic-pi.net/t/how-to-access-data-from-onset-function-using-lambda/1542>\
**Category:** Support, Help & Resources\
**Created:** [October 7, 2018, 12:55am UTC](https://in-thread.sonic-pi.net/t/how-to-access-data-from-onset-function-using-lambda/1542 "2018-10-07T00:55:21Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![mrbombmusic](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/mrbombmusic/32/2282_2.png) [@mrbombmusic](https://in-thread.sonic-pi.net/u/mrbombmusic)\
**Post date:** [October 8, 2018, 1:51am UTC](https://in-thread.sonic-pi.net/t/how-to-access-data-from-onset-function-using-lambda/1542/6 "2018-10-08T01:51:19Z")

</div>

Something like that would be great! Ideally, it would be good to be able to get the index length, the start and finish separately as well as the length of each onset in relation to the whole sample (just in relation to the 0 to 1 length, not the actual duration, although that might be interesting too)

```ruby
sample_onsets_index :loop_amen #=> returns index length
sample_onsets_start :loop_amen, 3 #=> returns 4th onset start time
sample_onsets_finish :loop_amen, 3 #=> returns 4th onset finish time
sample_onsets_length :loop_amen, 3 #=> returns 4th onset length

```

Not sure if there would be a less verbose way to write that, but that is the idea.

This all came about because I was trying to make a visual example of how onset works. Here’s what I came up with:

> <https://twitter.com/mrbombmusic/status/1049112681653968896>

---

_[View the full topic](https://in-thread.sonic-pi.net/t/how-to-access-data-from-onset-function-using-lambda/1542)._
